本文整理汇总了C++中Datum::getScarabDatum方法的典型用法代码示例。如果您正苦于以下问题:C++ Datum::getScarabDatum方法的具体用法?C++ Datum::getScarabDatum怎么用?C++ Datum::getScarabDatum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Datum
的用法示例。
在下文中一共展示了Datum::getScarabDatum方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateFromCodecDatum
void VariableRegistry::updateFromCodecDatum(const Datum &codec) {
mprintf(M_SYSTEM_MESSAGE_DOMAIN,
"Received new codec, updating variable registry.");
if(!codec.isDictionary()) {
merror(M_SYSTEM_MESSAGE_DOMAIN,
"Invalid codec received. Registry is unchanged.");
return;
}
boost::mutex::scoped_lock s_lock(lock);
master_variable_list.clear();
// add the placeholders
//addPlaceholders();
//////////////////////////////////////////////////////////////////
// now add what's in the codec
ScarabDatum *datum = codec.getScarabDatum();
ScarabDatum ** keys = datum->data.dict->keys;
int size = datum->data.dict->tablesize;
int maxCodecCode = -1;
// find the maximum codec value
for(int i = 0; i < size; ++i) {
if(keys[i]) {
long long code = keys[i]->data.integer;
maxCodecCode = (maxCodecCode < code) ? code : maxCodecCode;
}
}
// add each variable in order to the registry
for(int i = N_RESERVED_CODEC_CODES; i<=maxCodecCode; ++i) {
ScarabDatum *key = scarab_new_integer(i);
ScarabDatum *serializedVariable = scarab_dict_get(datum, key);
scarab_free_datum(key);
if(!serializedVariable) {
shared_ptr<EmptyVariable> empty_var(new EmptyVariable);
master_variable_list.push_back(empty_var);
continue;
} else {
if(serializedVariable->type != SCARAB_DICT) {
// these must be placeholder datums in the package
// that we should ignore.
mwarning(M_SYSTEM_MESSAGE_DOMAIN,
"Bad variable received from network stream");
shared_ptr<EmptyVariable> empty_var(new EmptyVariable);
master_variable_list.push_back(empty_var);
continue;
}
VariableProperties *props =
new VariableProperties(serializedVariable);
if(props == NULL){
mwarning(M_SYSTEM_MESSAGE_DOMAIN,
"Bad variable received from network stream");
shared_ptr<EmptyVariable> empty_var(new EmptyVariable);
master_variable_list.push_back(empty_var);
continue;
}
shared_ptr<Variable> newvar(new GlobalVariable(props));
newvar->setCodecCode(i); //necessary? .. Yup
master_variable_list.push_back(newvar);
std::string tag = newvar->getVariableName();
if(!tag.empty()){
master_variable_dictionary[tag] = newvar;
}
}
}
}