本文整理汇总了C++中UIDSet::AddUID方法的典型用法代码示例。如果您正苦于以下问题:C++ UIDSet::AddUID方法的具体用法?C++ UIDSet::AddUID怎么用?C++ UIDSet::AddUID使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UIDSet
的用法示例。
在下文中一共展示了UIDSet::AddUID方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testMultipleResponders
/**
* Test multiple responders
*/
void DiscoveryAgentTest::testMultipleResponders() {
UIDSet uids;
ResponderList responders;
UID uid_to_remove(0x7a70, 0x00002001);
uids.AddUID(uid_to_remove);
uids.AddUID(UID(0x7a70, 0x00002002));
uids.AddUID(UID(0x7a77, 0x00002002));
PopulateResponderListFromUIDs(uids, &responders);
MockDiscoveryTarget target(responders);
DiscoveryAgent agent(&target);
OLA_INFO << "starting discovery with two responder";
agent.StartFullDiscovery(
ola::NewSingleCallback(this,
&DiscoveryAgentTest::DiscoverySuccessful,
static_cast<const UIDSet*>(&uids)));
CPPUNIT_ASSERT(m_callback_run);
m_callback_run = false;
// now try incremental, adding one uid and removing another
UID uid_to_add(0x8080, 0x00103456);
uids.RemoveUID(uid_to_remove);
uids.AddUID(uid_to_add);
// update the responder list
target.RemoveResponder(uid_to_remove);
target.AddResponder(new MockResponder(uid_to_add));
OLA_INFO << "starting incremental discovery with modified responder list";
agent.StartIncrementalDiscovery(
ola::NewSingleCallback(this,
&DiscoveryAgentTest::DiscoverySuccessful,
static_cast<const UIDSet*>(&uids)));
CPPUNIT_ASSERT(m_callback_run);
}
示例2: testObnoxiousResponder
/**
* Test a responder that continues to responder when muted.
*/
void DiscoveryAgentTest::testObnoxiousResponder() {
UIDSet uids;
ResponderList responders;
uids.AddUID(UID(0x7a70, 0x00002002));
PopulateResponderListFromUIDs(uids, &responders);
// add the ObnoxiousResponders
UID obnoxious_uid = UID(0x7a77, 0x00002002);
UID obnoxious_uid2 = UID(0x7a77, 0x00003030);
uids.AddUID(obnoxious_uid);
uids.AddUID(obnoxious_uid2);
responders.push_back(new ObnoxiousResponder(obnoxious_uid));
responders.push_back(new ObnoxiousResponder(obnoxious_uid2));
MockDiscoveryTarget target(responders);
DiscoveryAgent agent(&target);
OLA_INFO << "starting discovery with obnoxious responder";
agent.StartFullDiscovery(
ola::NewSingleCallback(this,
&DiscoveryAgentTest::DiscoveryFailed,
static_cast<const UIDSet*>(&uids)));
CPPUNIT_ASSERT(m_callback_run);
m_callback_run = false;
// now try incremental, adding one uid and removing another
OLA_INFO << "starting incremental discovery with modified responder list";
agent.StartIncrementalDiscovery(
ola::NewSingleCallback(this,
&DiscoveryAgentTest::DiscoveryFailed,
static_cast<const UIDSet*>(&uids)));
CPPUNIT_ASSERT(m_callback_run);
}
示例3: testRequestAndDiscovery
/*
* Check that interleaving requests and discovery commands work.
*/
void QueueingRDMControllerTest::testRequestAndDiscovery() {
MockRDMController mock_controller;
auto_ptr<ola::rdm::DiscoverableQueueingRDMController> controller(
new ola::rdm::DiscoverableQueueingRDMController(&mock_controller, 1));
UIDSet uids;
UID uid1(2, 3);
UID uid2(10, 11);
uids.AddUID(uid1);
uids.AddUID(uid2);
// Send a request, but don't run the RDM request callback
RDMRequest *get_request = NewGetRequest(m_source, m_destination);
mock_controller.ExpectCallAndCapture(get_request);
RDMReply *expected_reply = new RDMReply(
ola::rdm::RDM_COMPLETED_OK,
NewGetResponse(m_destination, m_source));
controller->SendRDMRequest(
get_request,
ola::NewSingleCallback(
this,
&QueueingRDMControllerTest::VerifyResponse,
expected_reply));
// now queue up a discovery request
controller->RunFullDiscovery(
NewSingleCallback(
this,
&QueueingRDMControllerTest::VerifyDiscoveryComplete,
&uids));
mock_controller.Verify();
OLA_ASSERT_FALSE(m_discovery_complete_count);
// now run the RDM callback, this should unblock the discovery process
mock_controller.AddExpectedDiscoveryCall(true, NULL);
mock_controller.RunRDMCallback(expected_reply);
mock_controller.Verify();
// now queue another RDM request
RDMRequest *get_request2 = NewGetRequest(m_source, m_destination);
RDMReply *expected_reply2 = new RDMReply(
ola::rdm::RDM_COMPLETED_OK,
NewGetResponse(m_destination, m_source));
mock_controller.ExpectCallAndReplyWith(get_request2, expected_reply2);
// discovery is still running so this won't send the request just yet.
controller->SendRDMRequest(
get_request2,
ola::NewSingleCallback(
this,
&QueueingRDMControllerTest::VerifyResponse,
expected_reply2));
// now finish the discovery
mock_controller.RunDiscoveryCallback(uids);
OLA_ASSERT_TRUE(m_discovery_complete_count);
mock_controller.Verify();
}
示例4: testReentrantDiscovery
/*
* Verify reentrant discovery works
*/
void QueueingRDMControllerTest::testReentrantDiscovery() {
MockRDMController mock_controller;
auto_ptr<ola::rdm::DiscoverableQueueingRDMController> controller(
new ola::rdm::DiscoverableQueueingRDMController(&mock_controller, 1));
UIDSet uids;
UID uid1(2, 3);
UID uid2(10, 11);
uids.AddUID(uid1);
uids.AddUID(uid2);
// trigger discovery, the ReentrantDiscovery starts a new discovery from
// within the callback of the first.
mock_controller.AddExpectedDiscoveryCall(true, NULL);
controller->RunFullDiscovery(
NewSingleCallback(
this,
&QueueingRDMControllerTest::ReentrantDiscovery,
controller.get(),
&uids));
mock_controller.Verify();
// this will finish the first discovery attempt, and start the second
mock_controller.AddExpectedDiscoveryCall(true, NULL);
mock_controller.RunDiscoveryCallback(uids);
OLA_ASSERT_TRUE(m_discovery_complete_count);
m_discovery_complete_count = 0;
mock_controller.Verify();
// now unblock the second
mock_controller.RunDiscoveryCallback(uids);
OLA_ASSERT_TRUE(m_discovery_complete_count);
m_discovery_complete_count = 0;
mock_controller.Verify();
}
示例5: testProxy
/**
* Test a proxy.
*/
void DiscoveryAgentTest::testProxy() {
UIDSet proxied_uids, proxied_uids2;
ResponderList proxied_responders, proxied_responders2, responders;
proxied_uids.AddUID(UID(0x7a70, 0x00002002));
proxied_uids.AddUID(UID(0x8080, 0x00001234));
proxied_uids.AddUID(UID(0x9000, 0x00005678));
proxied_uids.AddUID(UID(0x1020, 0x00005678));
PopulateResponderListFromUIDs(proxied_uids, &proxied_responders);
proxied_uids2.AddUID(UID(0x7a71, 0x00002002));
proxied_uids2.AddUID(UID(0x8081, 0x00001234));
proxied_uids2.AddUID(UID(0x9001, 0x00005678));
proxied_uids2.AddUID(UID(0x1021, 0x00005678));
PopulateResponderListFromUIDs(proxied_uids2, &proxied_responders2);
// add the two proxies
UIDSet uids = proxied_uids.Union(proxied_uids2);
UID proxy_uid = UID(0x1010, 0x00002002);
uids.AddUID(proxy_uid);
responders.push_back(new ProxyResponder(proxy_uid, proxied_responders));
UID proxy_uid2 = UID(0x1010, 0x00001999);
uids.AddUID(proxy_uid2);
responders.push_back(new ProxyResponder(proxy_uid2, proxied_responders2));
// add some other responders
UID responder(0x0001, 0x00000001);
UID responder2(0x0001, 0x10000001);
uids.AddUID(responder);
uids.AddUID(responder2);
responders.push_back(new MockResponder(responder));
responders.push_back(new MockResponder(responder2));
MockDiscoveryTarget target(responders);
DiscoveryAgent agent(&target);
OLA_INFO << "starting discovery with Proxy responder";
agent.StartFullDiscovery(
ola::NewSingleCallback(this,
&DiscoveryAgentTest::DiscoverySuccessful,
static_cast<const UIDSet*>(&uids)));
OLA_ASSERT_TRUE(m_callback_run);
m_callback_run = false;
}
示例6: testRamblingResponder
/**
* Test a responder that replies with responses larger than the DUB size
*/
void DiscoveryAgentTest::testRamblingResponder() {
const UID normal_responder_uid(0x7a70, 0x00002002);
const UID rambling_responder_uid(0x7a77, 0x0002002);
UIDSet uids;
ResponderList responders;
uids.AddUID(normal_responder_uid);
PopulateResponderListFromUIDs(uids, &responders);
// add the RamblingResponder
responders.push_back(new RamblingResponder(rambling_responder_uid));
MockDiscoveryTarget target(responders);
DiscoveryAgent agent(&target);
uids.AddUID(rambling_responder_uid);
OLA_INFO << "starting discovery with rambling responder";
agent.StartFullDiscovery(
ola::NewSingleCallback(this,
&DiscoveryAgentTest::DiscoverySuccessful,
static_cast<const UIDSet*>(&uids)));
OLA_ASSERT_TRUE(m_callback_run);
}
示例7: testFlakeyResponder
/**
* Test a responder that only acks a mute request after N attempts.
*/
void DiscoveryAgentTest::testFlakeyResponder() {
UIDSet uids;
ResponderList responders;
uids.AddUID(UID(0x7a70, 0x00002002));
PopulateResponderListFromUIDs(uids, &responders);
// add the NonMutingResponders
UID flakey_uid = UID(0x7a77, 0x00002002);
UID flakey_uid2 = UID(0x7a77, 0x00003030);
uids.AddUID(flakey_uid);
uids.AddUID(flakey_uid2);
FlakeyMutingResponder *flakey_responder1 = new FlakeyMutingResponder(
flakey_uid);
FlakeyMutingResponder *flakey_responder2 = new FlakeyMutingResponder(
flakey_uid2);
responders.push_back(flakey_responder1);
responders.push_back(flakey_responder2);
MockDiscoveryTarget target(responders);
DiscoveryAgent agent(&target);
OLA_INFO << "starting discovery with flakey responder";
agent.StartFullDiscovery(
ola::NewSingleCallback(this,
&DiscoveryAgentTest::DiscoverySuccessful,
static_cast<const UIDSet*>(&uids)));
CPPUNIT_ASSERT(m_callback_run);
m_callback_run = false;
// now try incremental
flakey_responder1->Reset();
flakey_responder2->Reset();
OLA_INFO << "starting incremental discovery with flakey responder list";
agent.StartIncrementalDiscovery(
ola::NewSingleCallback(this,
&DiscoveryAgentTest::DiscoverySuccessful,
static_cast<const UIDSet*>(&uids)));
CPPUNIT_ASSERT(m_callback_run);
}
示例8: testBriefResponder
/**
* Test a responder that replies with too little data.
*/
void DiscoveryAgentTest::testBriefResponder() {
UIDSet uids;
ResponderList responders;
uids.AddUID(UID(0x7a70, 0x00002002));
PopulateResponderListFromUIDs(uids, &responders);
// add the BriefResponder
UID brief_uid = UID(0x7a77, 0x00002002);
responders.push_back(new BriefResponder(brief_uid));
MockDiscoveryTarget target(responders);
DiscoveryAgent agent(&target);
OLA_INFO << "starting discovery with brief responder";
agent.StartFullDiscovery(
ola::NewSingleCallback(this,
&DiscoveryAgentTest::DiscoveryFailed,
static_cast<const UIDSet*>(&uids)));
OLA_ASSERT_TRUE(m_callback_run);
}
示例9: testNonMutingResponder
/**
* Test a responder that doesn't respond to a mute message.
*/
void DiscoveryAgentTest::testNonMutingResponder() {
UIDSet uids;
ResponderList responders;
uids.AddUID(UID(0x7a70, 0x00002002));
PopulateResponderListFromUIDs(uids, &responders);
// add the NonMutingResponders
UID non_muting_uid = UID(0x7a77, 0x00002002);
UID non_muting_uid2 = UID(0x7a77, 0x00003030);
responders.push_back(new NonMutingResponder(non_muting_uid));
responders.push_back(new NonMutingResponder(non_muting_uid2));
MockDiscoveryTarget target(responders);
DiscoveryAgent agent(&target);
OLA_INFO << "starting discovery with NonMutingResponder responder";
agent.StartFullDiscovery(
ola::NewSingleCallback(this,
&DiscoveryAgentTest::DiscoveryFailed,
static_cast<const UIDSet*>(&uids)));
CPPUNIT_ASSERT(m_callback_run);
m_callback_run = false;
}
示例10: testResponderWithBroadcastUID
/**
* Test single responder with a broadcast UID
*/
void DiscoveryAgentTest::testResponderWithBroadcastUID() {
UIDSet uids;
ResponderList responders;
uids.AddUID(UID(0xffff, 0xffffffff));
PopulateResponderListFromUIDs(uids, &responders);
MockDiscoveryTarget target(responders);
DiscoveryAgent agent(&target);
agent.StartFullDiscovery(
ola::NewSingleCallback(this,
&DiscoveryAgentTest::DiscoverySuccessful,
static_cast<const UIDSet*>(&uids)));
OLA_ASSERT_TRUE(m_callback_run);
m_callback_run = false;
// now try incremental
agent.StartIncrementalDiscovery(
ola::NewSingleCallback(this,
&DiscoveryAgentTest::DiscoverySuccessful,
static_cast<const UIDSet*>(&uids)));
OLA_ASSERT_TRUE(m_callback_run);
}
示例11: UIDList
/*
* This is called when we receive uids for a universe
* @param universes a vector of OlaUniverses
*/
void UIDList(const ola::rdm::UIDSet &uids,
const string &error) {
UIDSet vendorcast;
if (error.empty()) {
UIDSet::Iterator iter = uids.Begin();
for (; iter != uids.End(); ++iter) {
cout << *iter << endl;
vendorcast.AddUID(UID::VendorcastAddress(*iter));
}
if (opts.vendorcast) {
iter = vendorcast.Begin();
for (; iter != vendorcast.End(); ++iter) {
cout << *iter << endl;
}
}
if (opts.broadcast) {
cout << UID::AllDevices().ToString() << endl;
}
} else {
cerr << error << endl;
}
ss->Terminate();
}
示例12: testSingleResponder
/**
* Test single responder
*/
void DiscoveryAgentTest::testSingleResponder() {
UIDSet uids;
ResponderList responders;
uids.AddUID(UID(1, 10));
PopulateResponderListFromUIDs(uids, &responders);
MockDiscoveryTarget target(responders);
DiscoveryAgent agent(&target);
OLA_INFO << "starting discovery with one responder";
agent.StartFullDiscovery(
ola::NewSingleCallback(this,
&DiscoveryAgentTest::DiscoverySuccessful,
static_cast<const UIDSet*>(&uids)));
CPPUNIT_ASSERT(m_callback_run);
m_callback_run = false;
// now try incremental
OLA_INFO << "starting incremental discovery with one responder";
agent.StartIncrementalDiscovery(
ola::NewSingleCallback(this,
&DiscoveryAgentTest::DiscoverySuccessful,
static_cast<const UIDSet*>(&uids)));
CPPUNIT_ASSERT(m_callback_run);
}
示例13: testRequestAndDiscovery
/**
* Check that interleaving requests and discovery commands work.
*/
void QueueingRDMControllerTest::testRequestAndDiscovery() {
MockRDMController mock_controller;
auto_ptr<ola::rdm::DiscoverableQueueingRDMController> controller(
new ola::rdm::DiscoverableQueueingRDMController(&mock_controller, 1));
UIDSet uids;
UID uid1(2, 3);
UID uid2(10, 11);
uids.AddUID(uid1);
uids.AddUID(uid2);
UID source(1, 2);
UID destination(3, 4);
// Send a request, but don't run the RDM request callback
RDMRequest *get_request = NewGetRequest(source, destination);
RDMGetResponse expected_command(destination,
source,
0, // transaction #
RDM_ACK,
0, // message count
10, // sub device
296, // param id
NULL, // data
0); // data length
mock_controller.AddExpectedCall(get_request,
ola::rdm::RDM_COMPLETED_OK,
NULL,
"",
false);
vector<string> packets;
packets.push_back("foo");
controller->SendRDMRequest(
get_request,
ola::NewSingleCallback(
this,
&QueueingRDMControllerTest::VerifyResponse,
ola::rdm::RDM_COMPLETED_OK,
static_cast<const RDMResponse*>(&expected_command),
packets,
false));
// now queue up a discovery request
controller->RunFullDiscovery(
NewSingleCallback(
this,
&QueueingRDMControllerTest::VerifyDiscoveryComplete,
&uids));
mock_controller.Verify();
CPPUNIT_ASSERT(!m_discovery_complete_count);
// now run the RDM callback, this should unblock the discovery process
mock_controller.AddExpectedDiscoveryCall(true, NULL);
mock_controller.RunRDMCallback(ola::rdm::RDM_COMPLETED_OK,
&expected_command,
"foo");
mock_controller.Verify();
// now queue another RDM request
RDMRequest *get_request2 = NewGetRequest(source, destination);
RDMGetResponse expected_command2(destination,
source,
0, // transaction #
RDM_ACK,
0, // message count
10, // sub device
296, // param id
NULL, // data
0); // data length
controller->SendRDMRequest(
get_request2,
ola::NewSingleCallback(
this,
&QueueingRDMControllerTest::VerifyResponse,
ola::rdm::RDM_COMPLETED_OK,
static_cast<const RDMResponse*>(&expected_command2),
packets,
false));
// discovery is still running so this won't send the request
mock_controller.Verify();
// now finish the discovery
mock_controller.AddExpectedCall(get_request2,
ola::rdm::RDM_COMPLETED_OK,
&expected_command,
"foo");
mock_controller.RunDiscoveryCallback(uids);
CPPUNIT_ASSERT(m_discovery_complete_count);
mock_controller.Verify();
}