summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin Smith <git@kismith.co.uk>2010-04-21 11:45:51 (GMT)
committerKevin Smith <git@kismith.co.uk>2010-04-23 10:54:04 (GMT)
commit91686a86876553774452d97f3f74d5f147b19164 (patch)
treefd0d601497f0cc757f12ec7c336b5b64213bbfd3 /Swiften
parent6bd72c67896a20041556519548650590553f47c9 (diff)
downloadswift-contrib-91686a86876553774452d97f3f74d5f147b19164.zip
swift-contrib-91686a86876553774452d97f3f74d5f147b19164.tar.bz2
Make latency stats optional.
Includes boost program_options so we can use commandline parameters. Netbook mode is now activated with --netbook-mode. Latency debug is activated with --latency-debug.
Diffstat (limited to 'Swiften')
-rw-r--r--Swiften/Elements/Stanza.h13
-rw-r--r--Swiften/Elements/UnitTest/StanzaTest.cpp16
2 files changed, 29 insertions, 0 deletions
diff --git a/Swiften/Elements/Stanza.h b/Swiften/Elements/Stanza.h
index aa1cf4f..f42048e 100644
--- a/Swiften/Elements/Stanza.h
+++ b/Swiften/Elements/Stanza.h
@@ -32,6 +32,19 @@ namespace Swift {
return boost::shared_ptr<T>();
}
+ template<typename T>
+ std::vector< boost::shared_ptr<T> > getPayloads() const {
+ std::vector< boost::shared_ptr<T> > results;
+ foreach (const boost::shared_ptr<Payload>& i, payloads_) {
+ boost::shared_ptr<T> result(boost::dynamic_pointer_cast<T>(i));
+ if (result) {
+ results.push_back(result);
+ }
+ }
+ return results;
+ }
+
+
const std::vector< boost::shared_ptr<Payload> >& getPayloads() const {
return payloads_;
}
diff --git a/Swiften/Elements/UnitTest/StanzaTest.cpp b/Swiften/Elements/UnitTest/StanzaTest.cpp
index fb9b8a5..1e7e9c4 100644
--- a/Swiften/Elements/UnitTest/StanzaTest.cpp
+++ b/Swiften/Elements/UnitTest/StanzaTest.cpp
@@ -19,6 +19,7 @@ class StanzaTest : public CppUnit::TestFixture
CPPUNIT_TEST_SUITE(StanzaTest);
CPPUNIT_TEST(testConstructor_Copy);
CPPUNIT_TEST(testGetPayload);
+ CPPUNIT_TEST(testGetPayloads);
CPPUNIT_TEST(testGetPayload_NoSuchPayload);
CPPUNIT_TEST(testDestructor);
CPPUNIT_TEST(testDestructor_Copy);
@@ -113,6 +114,21 @@ class StanzaTest : public CppUnit::TestFixture
CPPUNIT_ASSERT(!p);
}
+ void testGetPayloads() {
+ Message m;
+ boost::shared_ptr<MyPayload2> payload1(new MyPayload2());
+ boost::shared_ptr<MyPayload2> payload2(new MyPayload2());
+ m.addPayload(boost::shared_ptr<MyPayload1>(new MyPayload1()));
+ m.addPayload(payload1);
+ m.addPayload(boost::shared_ptr<MyPayload3>(new MyPayload3()));
+ m.addPayload(payload2);
+
+ CPPUNIT_ASSERT_EQUAL((size_t)2, m.getPayloads<MyPayload2>().size());
+ CPPUNIT_ASSERT_EQUAL(payload1, m.getPayloads<MyPayload2>()[0]);
+ CPPUNIT_ASSERT_EQUAL(payload2, m.getPayloads<MyPayload2>()[1]);
+ }
+
+
void testUpdatePayload_ExistingPayload() {
Message m;
m.addPayload(boost::shared_ptr<MyPayload1>(new MyPayload1()));