ERIS CORE

◆ increment()

bool SvcDataDictionary::increment ( const char *  key)

increments the value of a global record
creates a new record if one does not exist and
initializes its value to zero

Parameters
key
Returns
true
false

Definition at line 183 of file svcDataDictionary.cpp.

183  {
184  uint32_t h;
185  h = hash(key);
186 
187  int index = -1;
188  for(int i=0;i<DATADICT_KEYVALUE_PAIRS;i++){
189  //key found
190  if (record[i].key_hash == h){
191  //if ((0==strncmp(record[i].key,key,DATADICT_MAX_KEY_LEN))){
192  index = i;
193  break;
194  }
195  }
196  if (index == -1){
197  if (!create(key,(int32_t)0)) return false;
198  index = next -1;
199  }
200  if (record[index].data_type == DDDT_INT32){
201  record[index].val.int32_val++;
202  }else if (record[index].data_type == DDDT_FLOAT32){
203  record[index].val.float32_val++;
204  }
205  return true;
206 }
@ DDDT_FLOAT32
@ DDDT_INT32
bool create(const char *key, int32_t val, uint32_t *owner)
create a record with ownership
svcDataDictionaryRecord record[DATADICT_KEYVALUE_PAIRS]
uint32_t hash(const char *s)
hashing function used to accelerate searches

References create(), DDDT_FLOAT32, DDDT_INT32, value_container::float32_val, hash(), value_container::int32_val, next, record, and svcDataDictionaryRecord::val.

Referenced by SvcMIDI::publish(), SvcSerialCommandInterface::throttle(), AppCQT::update(), AppManager::update(), and SvcMIDI::update().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: