本文整理汇总了C++中PidStoreLoader类的典型用法代码示例。如果您正苦于以下问题:C++ PidStoreLoader类的具体用法?C++ PidStoreLoader怎么用?C++ PidStoreLoader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PidStoreLoader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DataLocation
const RootPidStore *RootPidStore::LoadFromDirectory(
const std::string &directory,
bool validate) {
PidStoreLoader loader;
string data_source = directory;
if (directory.empty()) {
data_source = DataLocation();
}
return loader.LoadFromDirectory(data_source, validate);
}
示例2: testPidStoreDirectoryLoad
/**
* Check that loading from a directory works. This also tests the override
* mechanism.
*/
void PidStoreTest::testPidStoreDirectoryLoad() {
PidStoreLoader loader;
auto_ptr<const RootPidStore> root_store(loader.LoadFromDirectory(
GetTestDataFile("pids")));
OLA_ASSERT_NOT_NULL(root_store.get());
// check version
OLA_ASSERT_EQ(static_cast<uint64_t>(1302986774), root_store->Version());
// Check all the esta pids are there
const PidStore *esta_store = root_store->EstaStore();
OLA_ASSERT_NOT_NULL(esta_store);
vector<const PidDescriptor*> all_pids;
esta_store->AllPids(&all_pids);
OLA_ASSERT_EQ(static_cast<size_t>(4), all_pids.size());
// check manufacturer pids
const PidStore *open_lighting_store =
root_store->ManufacturerStore(ola::OPEN_LIGHTING_ESTA_CODE);
OLA_ASSERT_NOT_NULL(open_lighting_store);
OLA_ASSERT_EQ(1u, open_lighting_store->PidCount());
// FOO_BAR in the overrides file replaces SERIAL_NUMBER.
const PidDescriptor *serial_number = open_lighting_store->LookupPID(
"SERIAL_NUMBER");
OLA_ASSERT_NULL(serial_number);
const PidDescriptor *foo_bar = open_lighting_store->LookupPID(
"FOO_BAR");
OLA_ASSERT_NOT_NULL(foo_bar);
OLA_ASSERT_EQ(static_cast<uint16_t>(32768), foo_bar->Value());
OLA_ASSERT_EQ(string("FOO_BAR"), foo_bar->Name());
// check descriptors
OLA_ASSERT_TRUE(foo_bar->GetRequest());
OLA_ASSERT_TRUE(foo_bar->GetResponse());
OLA_ASSERT_EQ(static_cast<const Descriptor*>(NULL),
foo_bar->SetRequest());
OLA_ASSERT_EQ(static_cast<const Descriptor*>(NULL),
foo_bar->SetResponse());
ola::messaging::SchemaPrinter printer;
foo_bar->GetResponse()->Accept(&printer);
string expected2 = "baz: uint32\n";
OLA_ASSERT_EQ(expected2, printer.AsString());
}
示例3: testInconsistentData
/**
* Check that loading a file with an inconsistent descriptor fails.
*/
void PidStoreTest::testInconsistentData() {
PidStoreLoader loader;
const RootPidStore *root_store = loader.LoadFromFile(
GetTestDataFile("inconsistent_pid.proto"));
OLA_ASSERT_NULL(root_store);
}
示例4: testPidStoreLoadInvalidEstaPid
/**
* Check that loading a file with an out-of-range ESTA pid fails.
*/
void PidStoreTest::testPidStoreLoadInvalidEstaPid() {
PidStoreLoader loader;
const RootPidStore *root_store = loader.LoadFromFile(
GetTestDataFile("invalid_esta_pid.proto"));
OLA_ASSERT_NULL(root_store);
}
示例5: testPidStoreLoadDuplicateName
/**
* Check that loading a file with duplicate pid names fails.
*/
void PidStoreTest::testPidStoreLoadDuplicateName() {
PidStoreLoader loader;
const RootPidStore *root_store = loader.LoadFromFile(
GetTestDataFile("duplicate_pid_name.proto"));
OLA_ASSERT_NULL(root_store);
}
示例6: testPidStoreLoadDuplicateManufacturer
/**
* Check that loading a file with duplicate manufacturers fails.
*/
void PidStoreTest::testPidStoreLoadDuplicateManufacturer() {
PidStoreLoader loader;
const RootPidStore *root_store = loader.LoadFromFile(
GetTestDataFile("duplicate_manufacturer.proto"));
OLA_ASSERT_NULL(root_store);
}
示例7: testPidStoreLoadMissingFile
/**
* Check that loading a missing file fails.
*/
void PidStoreTest::testPidStoreLoadMissingFile() {
PidStoreLoader loader;
const RootPidStore *root_store = loader.LoadFromFile(
GetTestDataFile("missing_file_pids.proto"));
OLA_ASSERT_NULL(root_store);
}
示例8: testPidStoreFileLoad
/**
* Check that loading from a file works
*/
void PidStoreTest::testPidStoreFileLoad() {
PidStoreLoader loader;
auto_ptr<const RootPidStore> root_store(
loader.LoadFromFile(GetTestDataFile("test_pids.proto")));
OLA_ASSERT_NOT_NULL(root_store.get());
// check version
OLA_ASSERT_EQ(static_cast<uint64_t>(1302986774), root_store->Version());
// Check all the esta pids are there
const PidStore *esta_store = root_store->EstaStore();
OLA_ASSERT_NOT_NULL(esta_store);
vector<const PidDescriptor*> all_pids;
esta_store->AllPids(&all_pids);
OLA_ASSERT_EQ(static_cast<size_t>(70), all_pids.size());
// check for device info
const PidDescriptor *device_info = esta_store->LookupPID("DEVICE_INFO");
OLA_ASSERT_NOT_NULL(device_info);
OLA_ASSERT_EQ(static_cast<uint16_t>(96), device_info->Value());
OLA_ASSERT_EQ(string("DEVICE_INFO"), device_info->Name());
// check descriptors
OLA_ASSERT_TRUE(device_info->GetRequest());
OLA_ASSERT_TRUE(device_info->GetResponse());
OLA_ASSERT_EQ(static_cast<const Descriptor*>(NULL),
device_info->SetRequest());
OLA_ASSERT_EQ(static_cast<const Descriptor*>(NULL),
device_info->SetResponse());
ola::messaging::SchemaPrinter printer;
device_info->GetResponse()->Accept(&printer);
string expected = (
"protocol_major: uint8\nprotocol_minor: uint8\ndevice_model: uint16\n"
"product_category: uint16\nsoftware_version: uint32\n"
"dmx_footprint: uint16\ncurrent_personality: uint8\n"
"personality_count: uint8\ndmx_start_address: uint16\n"
"sub_device_count: uint16\nsensor_count: uint8\n");
OLA_ASSERT_EQ(expected, printer.AsString());
// check manufacturer pids
const PidStore *open_lighting_store =
root_store->ManufacturerStore(ola::OPEN_LIGHTING_ESTA_CODE);
OLA_ASSERT_NOT_NULL(open_lighting_store);
OLA_ASSERT_EQ(1u, open_lighting_store->PidCount());
const PidDescriptor *serial_number = open_lighting_store->LookupPID(
"SERIAL_NUMBER");
OLA_ASSERT_NOT_NULL(serial_number);
OLA_ASSERT_EQ(static_cast<uint16_t>(32768), serial_number->Value());
OLA_ASSERT_EQ(string("SERIAL_NUMBER"), serial_number->Name());
// check descriptors
OLA_ASSERT_EQ(static_cast<const Descriptor*>(NULL),
serial_number->GetRequest());
OLA_ASSERT_EQ(static_cast<const Descriptor*>(NULL),
serial_number->GetResponse());
OLA_ASSERT_TRUE(serial_number->SetRequest());
OLA_ASSERT_TRUE(serial_number->SetResponse());
printer.Reset();
serial_number->SetRequest()->Accept(&printer);
string expected2 = "serial_number: uint32\n";
OLA_ASSERT_EQ(expected2, printer.AsString());
}
示例9: testPidStoreLoad
/**
* Check we can load a PidStore from a string
*/
void PidStoreTest::testPidStoreLoad() {
PidStoreLoader loader;
// This is a stringstream not a ostringstream as the other end needs an
// istream
stringstream str;
// check that this fails to load
const RootPidStore *empty_root_store = loader.LoadFromStream(&str);
OLA_ASSERT_EQ(static_cast<const RootPidStore*>(NULL),
empty_root_store);
// now try a simple pid store config
str.clear();
str << "pid {" << endl <<
" name: \"PROXIED_DEVICES\"" << endl <<
" value: 16" << endl <<
" get_request {" << endl <<
" }" << endl <<
" get_response {" << endl <<
" field {" << endl <<
" type: GROUP" << endl <<
" name: \"uids\"" << endl <<
" field {" << endl <<
" type: UINT16" << endl <<
" name: \"manufacturer_id\"" << endl <<
" }" << endl <<
" field {" << endl <<
" type: UINT32" << endl <<
" name: \"device_id\"" << endl <<
" }" << endl <<
" }" << endl <<
" }" << endl <<
" get_sub_device_range: ROOT_DEVICE" << endl <<
"}" << endl <<
"manufacturer {" << endl <<
" manufacturer_id: 31344" << endl <<
" manufacturer_name: \"Open Lighting\"" << endl <<
"}" << endl <<
"version: 1" << endl;
auto_ptr<const RootPidStore> root_store(loader.LoadFromStream(&str));
OLA_ASSERT_TRUE(root_store.get());
// check version
OLA_ASSERT_EQ(static_cast<uint64_t>(1), root_store->Version());
// check manufacturer pids
const PidStore *open_lighting_store =
root_store->ManufacturerStore(ola::OPEN_LIGHTING_ESTA_CODE);
OLA_ASSERT_TRUE(open_lighting_store);
OLA_ASSERT_EQ(0u, open_lighting_store->PidCount());
// lookup by value
OLA_ASSERT_TRUE(root_store->GetDescriptor(16));
OLA_ASSERT_FALSE(root_store->GetDescriptor(17));
OLA_ASSERT_TRUE(root_store->GetDescriptor(16, ola::OPEN_LIGHTING_ESTA_CODE));
OLA_ASSERT_FALSE(root_store->GetDescriptor(17, ola::OPEN_LIGHTING_ESTA_CODE));
// lookup by name
OLA_ASSERT_TRUE(root_store->GetDescriptor("PROXIED_DEVICES"));
OLA_ASSERT_FALSE(root_store->GetDescriptor("DEVICE_INFO"));
OLA_ASSERT_TRUE(root_store->GetDescriptor("PROXIED_DEVICES",
ola::OPEN_LIGHTING_ESTA_CODE));
OLA_ASSERT_FALSE(root_store->GetDescriptor("DEVICE_INFO",
ola::OPEN_LIGHTING_ESTA_CODE));
// check lookups
const PidStore *esta_store = root_store->EstaStore();
OLA_ASSERT_TRUE(esta_store);
const PidDescriptor *pid_descriptor = esta_store->LookupPID(16);
OLA_ASSERT_TRUE(pid_descriptor);
const PidDescriptor *pid_descriptor2 = esta_store->LookupPID(
"PROXIED_DEVICES");
OLA_ASSERT_TRUE(pid_descriptor2);
OLA_ASSERT_EQ(pid_descriptor, pid_descriptor2);
// check name and value
OLA_ASSERT_EQ(static_cast<uint16_t>(16), pid_descriptor->Value());
OLA_ASSERT_EQ(string("PROXIED_DEVICES"), pid_descriptor->Name());
// check descriptors
OLA_ASSERT_TRUE(pid_descriptor->GetRequest());
OLA_ASSERT_TRUE(pid_descriptor->GetResponse());
OLA_ASSERT_EQ(static_cast<const Descriptor*>(NULL),
pid_descriptor->SetRequest());
OLA_ASSERT_EQ(static_cast<const Descriptor*>(NULL),
pid_descriptor->SetResponse());
// check GET descriptors
const Descriptor *get_request = pid_descriptor->GetRequest();
OLA_ASSERT_EQ(0u, get_request->FieldCount());
const Descriptor *get_response = pid_descriptor->GetResponse();
OLA_ASSERT_EQ(1u, get_response->FieldCount());
const FieldDescriptor *proxied_group = get_response->GetField(0);
OLA_ASSERT_TRUE(proxied_group);
//.........这里部分代码省略.........
示例10:
/**
* Load all pid definition files in a directory
*/
const RootPidStore *RootPidStore::LoadFromDirectory(
const std::string &directory,
bool validate) {
PidStoreLoader loader;
return loader.LoadFromDirectory(directory, validate);
}
示例11: testInconsistentData
/**
* Check that loading a file with an inconsistent descriptor fails.
*/
void PidStoreTest::testInconsistentData() {
PidStoreLoader loader;
const RootPidStore *root_store = loader.LoadFromFile(
"./testdata/inconsistent_pid.proto");
CPPUNIT_ASSERT(!root_store);
}
示例12: testPidStoreLoadInvalidEstaPid
/**
* Check that loading a file with an out-of-range ESTA pid fails.
*/
void PidStoreTest::testPidStoreLoadInvalidEstaPid() {
PidStoreLoader loader;
const RootPidStore *root_store = loader.LoadFromFile(
"./testdata/invalid_esta_pid.proto");
CPPUNIT_ASSERT(!root_store);
}
示例13: testPidStoreLoadDuplicateName
/**
* Check that loading a file with duplicate pid names fails.
*/
void PidStoreTest::testPidStoreLoadDuplicateName() {
PidStoreLoader loader;
const RootPidStore *root_store = loader.LoadFromFile(
"./testdata/duplicate_pid_name.proto");
CPPUNIT_ASSERT(!root_store);
}
示例14: testPidStoreLoadDuplicateManufacturer
/**
* Check that loading a file with duplicate manufacturers fails.
*/
void PidStoreTest::testPidStoreLoadDuplicateManufacturer() {
PidStoreLoader loader;
const RootPidStore *root_store = loader.LoadFromFile(
"./testdata/duplicate_manufacturer.proto");
CPPUNIT_ASSERT(!root_store);
}
示例15: testPidStoreLoadMissingFile
/**
* Check that loading a missing file fails.
*/
void PidStoreTest::testPidStoreLoadMissingFile() {
PidStoreLoader loader;
const RootPidStore *root_store = loader.LoadFromFile(
"./testdata/missing_file_pids.proto");
CPPUNIT_ASSERT(!root_store);
}