本文整理汇总了C++中Counter::Set方法的典型用法代码示例。如果您正苦于以下问题:C++ Counter::Set方法的具体用法?C++ Counter::Set怎么用?C++ Counter::Set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Counter
的用法示例。
在下文中一共展示了Counter::Set方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AdvanceConfigure
void xPLChrono::AdvanceConfigure()
{
int i;
int nb;
LOG_ENTER;
ConfigsDelete();
nb = m_AdvanceConfig.GetNbConfig();
for(i=0; i<nb; i++)
{
std::map<std::string, std::string>* config;
string configName;
string source;
string unit;
string razPeriod;
string razUnit;
string strBool;
bool saveValue;
Counter counter;
config = m_AdvanceConfig.GetConfig(i);
configName = (*config)["configname"];
source = (*config)["source"];
unit = (*config)["unit"];
razPeriod = (*config)["resetperiod"];
razUnit = (*config)["resetunit"];
strBool = (*config)["savevalue"];
saveValue = (strBool=="1") ? true : false;
if(source=="")
{
LOG_WARNING(m_Log) << "Counter " << configName << ": No source, Counter ignored";
continue;
}
LOG_VERBOSE(m_Log) << "New Counter " << configName << ":" << source << " unit " << unit << ", razPeriod " << razPeriod << " " <<razUnit;
counter.Set(source, unit, razPeriod, razUnit, saveValue);
m_Counters[configName] = counter;
m_DeviceCount[source]++;
m_Sensors.AddSensorMessage(configName, xPL::SchemaSensorTypeUtility::count, 0);
RequestValue(source);
}
LoadData();
LOG_EXIT_OK;
}
示例2: ConfigChange
void xPLChrono::ConfigChange(const string& configName)
{
std::map<std::string, std::string>* config;
std::map<std::string, Counter>::iterator it;
string source;
string unit;
string razPeriod;
string razUnit;
string strBool;
bool saveValue;
Counter counter;
config = m_AdvanceConfig.GetConfig(configName);
source = (*config)["source"];
unit = (*config)["unit"];
razPeriod = (*config)["resetperiod"];
razUnit = (*config)["resetunit"];
strBool = (*config)["savevalue"];
saveValue = (strBool=="1") ? true : false;
it = m_Counters.find(configName);
if(it==m_Counters.end())
{
LOG_VERBOSE(m_Log) << "New counter " << configName << ":" << source;
counter.Set(source, unit, razPeriod, razUnit, saveValue);
m_Counters[configName] = counter;
m_DeviceCount[source]++;
m_Sensors.AddSensorMessage(configName, xPL::SchemaSensorTypeUtility::count, 0);
}
else
{
LOG_VERBOSE(m_Log) << "Modify counter " << configName << ":" << source;
m_DeviceCount[it->second.GetSource()]--;
it->second.Set(source, unit, razPeriod, razUnit, saveValue);
m_DeviceCount[source]++;
}
if(source=="")
LOG_WARNING(m_Log) << "Counter " << configName << ": No source, Counter ignored";
else
RequestValue(source);
}