diff options
author | Kenneth Anthony Giusti <kgiusti@apache.org> | 2010-07-08 20:29:52 +0000 |
---|---|---|
committer | Kenneth Anthony Giusti <kgiusti@apache.org> | 2010-07-08 20:29:52 +0000 |
commit | 459f48df9d6b62a0f72be50c8ce082c1317c736e (patch) | |
tree | 144cf9f423de1fb798868ed22229ce159738d714 /cpp/src | |
parent | df239e9f6987f45162d7ccd6459f1b73a81b39f9 (diff) | |
download | qpid-python-459f48df9d6b62a0f72be50c8ce082c1317c736e.tar.gz |
QMF: add api to get agent id, and new object id constructor that uses agent id.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@961919 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/qpid/agent/ManagementAgentImpl.cpp | 15 | ||||
-rw-r--r-- | cpp/src/qpid/agent/ManagementAgentImpl.h | 2 | ||||
-rw-r--r-- | cpp/src/qpid/management/ManagementAgent.cpp | 20 | ||||
-rw-r--r-- | cpp/src/qpid/management/ManagementAgent.h | 3 | ||||
-rw-r--r-- | cpp/src/tests/ManagementTest.cpp | 7 |
5 files changed, 47 insertions, 0 deletions
diff --git a/cpp/src/qpid/agent/ManagementAgentImpl.cpp b/cpp/src/qpid/agent/ManagementAgentImpl.cpp index bc841ca3ee..351e0bfd00 100644 --- a/cpp/src/qpid/agent/ManagementAgentImpl.cpp +++ b/cpp/src/qpid/agent/ManagementAgentImpl.cpp @@ -144,6 +144,21 @@ void ManagementAgentImpl::setName(const string& vendor, const string& product, c attrMap["_name"] = name_address; } + +void ManagementAgentImpl::getName(string& vendor, string& product, string& instance) +{ + vendor = std::string(attrMap["_vendor"]); + product = std::string(attrMap["_product"]); + instance = std::string(attrMap["_instance"]); +} + + +const std::string& ManagementAgentImpl::getAddress() +{ + return name_address; +} + + void ManagementAgentImpl::init(const string& brokerHost, uint16_t brokerPort, uint16_t intervalSeconds, diff --git a/cpp/src/qpid/agent/ManagementAgentImpl.h b/cpp/src/qpid/agent/ManagementAgentImpl.h index 7d4531f1b8..4a58807e98 100644 --- a/cpp/src/qpid/agent/ManagementAgentImpl.h +++ b/cpp/src/qpid/agent/ManagementAgentImpl.h @@ -54,6 +54,8 @@ class ManagementAgentImpl : public ManagementAgent, public client::MessageListen void setName(const std::string& vendor, const std::string& product, const std::string& instance=""); + void getName(std::string& vendor, std::string& product, std::string& instance); + const std::string& getAddress(); void init(const std::string& brokerHost = "localhost", uint16_t brokerPort = 5672, uint16_t intervalSeconds = 10, diff --git a/cpp/src/qpid/management/ManagementAgent.cpp b/cpp/src/qpid/management/ManagementAgent.cpp index 8818a4c3ac..9e4e9665ac 100644 --- a/cpp/src/qpid/management/ManagementAgent.cpp +++ b/cpp/src/qpid/management/ManagementAgent.cpp @@ -197,6 +197,12 @@ void ManagementAgent::pluginsInitialized() { void ManagementAgent::setName(const string& vendor, const string& product, const string& instance) { + if (vendor.find(':') != vendor.npos) { + throw Exception("vendor string cannot contain a ':' character."); + } + if (product.find(':') != product.npos) { + throw Exception("product string cannot contain a ':' character."); + } attrMap["_vendor"] = vendor; attrMap["_product"] = product; string inst; @@ -218,6 +224,20 @@ void ManagementAgent::setName(const string& vendor, const string& product, const } +void ManagementAgent::getName(string& vendor, string& product, string& instance) +{ + vendor = std::string(attrMap["_vendor"]); + product = std::string(attrMap["_product"]); + instance = std::string(attrMap["_instance"]); +} + + +const std::string& ManagementAgent::getAddress() +{ + return name_address; +} + + void ManagementAgent::writeData () { string filename (dataDir + "/.mbrokerdata"); diff --git a/cpp/src/qpid/management/ManagementAgent.h b/cpp/src/qpid/management/ManagementAgent.h index 44e3eb1a35..a6e906e2a8 100644 --- a/cpp/src/qpid/management/ManagementAgent.h +++ b/cpp/src/qpid/management/ManagementAgent.h @@ -77,6 +77,9 @@ public: void setName(const std::string& vendor, const std::string& product, const std::string& instance=""); + void getName(std::string& vendor, std::string& product, std::string& instance); + const std::string& getAddress(); + void setInterval(uint16_t _interval) { interval = _interval; } void setExchange(qpid::broker::Exchange::shared_ptr mgmtExchange, qpid::broker::Exchange::shared_ptr directExchange); diff --git a/cpp/src/tests/ManagementTest.cpp b/cpp/src/tests/ManagementTest.cpp index e9b8ac32b9..8944c084c0 100644 --- a/cpp/src/tests/ManagementTest.cpp +++ b/cpp/src/tests/ManagementTest.cpp @@ -86,6 +86,13 @@ QPID_AUTO_TEST_CASE(testObjectIdAttach) { BOOST_CHECK_EQUAL(out2.str(), "10-20-30-MrSmith-0(GabbaGabbaHey)"); } +QPID_AUTO_TEST_CASE(testObjectIdCreate) { + ObjectId oid("some-agent-name", "an-object-name"); + + BOOST_CHECK_EQUAL(oid.getAgentName(), "some-agent-name"); + BOOST_CHECK_EQUAL(oid.getV2Key(), "an-object-name"); +} + QPID_AUTO_TEST_CASE(testConsoleObjectId) { qpid::console::ObjectId oid1, oid2; |