AudioManager  7.6.6
Native Application Runtime Environment
CAmDatabaseHandlerMap.cpp
Go to the documentation of this file.
1 
24 #include <iostream>
25 #include <cassert>
26 #include <stdexcept>
27 #include <vector>
28 #include <fstream>
29 #include <sstream>
30 #include <string>
31 #include <limits>
32 #include "CAmDatabaseHandlerMap.h"
33 #include "CAmRouter.h"
34 #include "CAmDltWrapper.h"
35 
36 #define __METHOD_NAME__ std::string (std::string("CAmDatabaseHandlerMap::") + __func__)
37 
38 
39 #ifdef WITH_DATABASE_CHANGE_CHECK
40 # define DB_COND_UPDATE_RIE(x,y) \
41  if (isDataEqual(x,y)) return (E_NO_CHANGE); else x = y
42 # define DB_COND_UPDATE_INIT \
43  bool modified = false
44 # define DB_COND_UPDATE(x,y) \
45  if (!isDataEqual(x,y)) { x = y; modified = true; }
46 # define DB_COND_ISMODIFIED \
47  (modified == true)
48 #else
49 # define DB_COND_UPDATE_RIE(x,y) \
50  x = y
51 # define DB_COND_UPDATE_INIT
52 # define DB_COND_UPDATE(x,y) \
53  x = y
54 # define DB_COND_ISMODIFIED \
55  (true)
56 #endif
57 
58 
59 #define NOTIFY_OBSERVERS(CALL)\
60  for(AmDatabaseObserverCallbacks * nextObserver: mDatabaseObservers)\
61  if(nextObserver->CALL)\
62  nextObserver->CALL();
63 
64 #define NOTIFY_OBSERVERS1(CALL, ARG1)\
65  for(AmDatabaseObserverCallbacks * nextObserver: mDatabaseObservers)\
66  if(nextObserver->CALL)\
67  nextObserver->CALL(ARG1);
68 
69 #define NOTIFY_OBSERVERS2(CALL, ARG1, ARG2)\
70  for(AmDatabaseObserverCallbacks * nextObserver: mDatabaseObservers)\
71  if(nextObserver->CALL)\
72  nextObserver->CALL(ARG1, ARG2);
73 
74 #define NOTIFY_OBSERVERS3(CALL, ARG1, ARG2, ARG3)\
75  for(AmDatabaseObserverCallbacks * nextObserver: mDatabaseObservers)\
76  if(nextObserver->CALL)\
77  nextObserver->CALL(ARG1, ARG2, ARG3);
78 
79 #define NOTIFY_OBSERVERS4(CALL, ARG1, ARG2, ARG3, ARG4)\
80  for(AmDatabaseObserverCallbacks * nextObserver: mDatabaseObservers)\
81  if(nextObserver->CALL)\
82  nextObserver->CALL(ARG1, ARG2, ARG3, ARG4);
83 
84 namespace am
85 {
86 
87 /*
88  * Checks if content of data is equal
89  */
90 template <typename T> bool isDataEqual(const T & left, const T & right)
91 {
92  return static_cast<bool>(!std::memcmp(&left, &right, sizeof(T)));
93 }
94 
95 template <typename T, typename L = std::vector<T> > bool isDataEqual(const L & left, const L & right)
96 {
97  return std::equal(left.begin(), left.end(), right.begin(), isDataEqual);
98 }
99 
100 
101 /*
102  * Returns an object for given key
103  */
104 template <typename TMapKeyType, class TMapObjectType> TMapObjectType const * objectForKeyIfExistsInMap(const TMapKeyType & key, const std::unordered_map<TMapKeyType,TMapObjectType> & map)
105 {
106  typename std::unordered_map<TMapKeyType,TMapObjectType>::const_iterator iter = map.find(key);
107  if( iter!=map.end() )
108  return &iter->second;
109  return NULL;
110 }
111 
112 /*
113  * Checks whether any object with key exists in a given map
114  */
115 template <typename TMapKeyType, class TMapObjectType> bool existsObjectWithKeyInMap(const TMapKeyType & key, const std::unordered_map<TMapKeyType,TMapObjectType> & map)
116 {
117  return objectForKeyIfExistsInMap(key, map)!=NULL;
118 }
119 
129 template <class TReturn, typename TIdentifier> const TReturn * objectMatchingPredicate(const std::unordered_map<TIdentifier, TReturn> & map,
130  std::function<bool(const TReturn & refObject)> comparator)
131 {
132  typename std::unordered_map<TIdentifier, TReturn>::const_iterator elementIterator = map.begin();
133  for (;elementIterator != map.end(); ++elementIterator)
134  {
135  if( comparator(elementIterator->second) )
136  return &elementIterator->second;
137  }
138  return NULL;
139 }
140 
141 
142 /* Domain */
143 
144 void CAmDatabaseHandlerMap::AmDomain::getDescription (std::string & outString) const
145 {
146  std::ostringstream fmt;
147  fmt << "Domain(" << name.c_str() << ") id(" << domainID << ")" << std::endl <<
148  "bus name(" << busname.c_str() <<
149  ") node name(" << nodename.c_str() <<
150  ") early(" << early <<
151  ") domainID(" << domainID <<
152  ") complete(" << complete <<
153  ") state(" << state <<
154  ") reserved(" << reserved << ")" << std::endl;
155  outString = fmt.str();
156 }
157 
158 /* Source */
159 
160 void CAmDatabaseHandlerMap::AmSource::getSourceType(am_SourceType_s & sourceType) const
161 {
162  sourceType.name = name;
163  sourceType.sourceClassID = sourceClassID;
164  sourceType.availability = available;
165  sourceType.sourceID = sourceID;
166 }
167 
168 void CAmDatabaseHandlerMap::AmSource::getDescription (std::string & outString) const
169 {
170  std::ostringstream fmt;
171  fmt << "Source(" << name.c_str() << ") id(" << sourceID << ")" << std::endl <<
172  "sourceClassID(" << sourceClassID <<
173  ") domainID(" << domainID <<
174  ") visible(" << visible <<
175  ") volume(" << volume <<
176  ") interruptState(" << interruptState <<
177  ") sourceState(" << sourceState <<
178  ") reserved(" << reserved << ")" <<
179  ") available([availability:" << available.availability << " availabilityReason:" << available.availabilityReason << "]"
180  ") listSoundProperties (";
181  std::for_each(listSoundProperties.begin(), listSoundProperties.end(), [&](const am_SoundProperty_s & ref) {
182  fmt << "[type:" << ref.type << " value:" << ref.value <<"]";
183  });
184  fmt << ") listConnectionFormats (";
185  std::for_each(listConnectionFormats.begin(), listConnectionFormats.end(), [&](const am_CustomConnectionFormat_t & ref) {
186  fmt << "[" << ref << "]";
187  });
188  fmt << ") listMainSoundProperties (";
189  std::for_each(listMainSoundProperties.begin(), listMainSoundProperties.end(), [&](const am_MainSoundProperty_s & ref) {
190  fmt << "[type:" << ref.type << " value:" << ref.value <<"]";
191  });
192  fmt << ") listMainNotificationConfigurations (";
193  std::for_each(listMainNotificationConfigurations.begin(), listMainNotificationConfigurations.end(), [&](const am_NotificationConfiguration_s & ref) {
194  fmt << "[type:" << ref.type << " status:" << ref.status << " parameter:" << ref.parameter <<"]";
195  });
196  fmt << ") listNotificationConfigurations (";
197  std::for_each(listNotificationConfigurations.begin(), listNotificationConfigurations.end(), [&](const am_NotificationConfiguration_s & ref) {
198  fmt << "[type:" << ref.type << " status:" << ref.status << " parameter:" << ref.parameter <<"]";
199  });
200  fmt << ")" << std::endl;
201  outString = fmt.str();
202 }
203 
204 /* Sink */
205 
206 void CAmDatabaseHandlerMap::AmSink::getDescription (std::string & outString) const
207 {
208  std::ostringstream fmt;
209  fmt << "Sink(" << name.c_str() << ") id(" << sinkID << ")" << std::endl <<
210  "sinkClassID(" << sinkClassID <<
211  ") domainID(" << domainID <<
212  ") visible(" << visible <<
213  ") volume(" << volume <<
214  ") muteState(" << muteState <<
215  ") mainVolume(" << mainVolume <<
216  ") reserved(" << reserved << ")" <<
217  ") available([availability:" << available.availability << " availabilityReason:" << available.availabilityReason << "]"
218  ") listSoundProperties (";
219  std::for_each(listSoundProperties.begin(), listSoundProperties.end(), [&](const am_SoundProperty_s & ref) {
220  fmt << "[type:" << ref.type << " value:" << ref.value <<"]";
221  });
222  fmt << ") listConnectionFormats (";
223  std::for_each(listConnectionFormats.begin(), listConnectionFormats.end(), [&](const am_CustomConnectionFormat_t & ref) {
224  fmt << "[" << ref << "]";
225  });
226  fmt << ") listMainSoundProperties (";
227  std::for_each(listMainSoundProperties.begin(), listMainSoundProperties.end(), [&](const am_MainSoundProperty_s & ref) {
228  fmt << "[type:" << ref.type << " value:" << ref.value <<"]";
229  });
230  fmt << ") listMainNotificationConfigurations (";
231  std::for_each(listMainNotificationConfigurations.begin(), listMainNotificationConfigurations.end(), [&](const am_NotificationConfiguration_s & ref) {
232  fmt << "[type:" << ref.type << " status:" << ref.status << " parameter:" << ref.parameter <<"]";
233  });
234  fmt << ") listNotificationConfigurations (";
235  std::for_each(listNotificationConfigurations.begin(), listNotificationConfigurations.end(), [&](const am_NotificationConfiguration_s & ref) {
236  fmt << "[type:" << ref.type << " status:" << ref.status << " parameter:" << ref.parameter <<"]";
237  });
238  fmt << ")" << std::endl;
239  outString = fmt.str();
240 }
241 
242 void CAmDatabaseHandlerMap::AmSink::getSinkType(am_SinkType_s & sinkType) const
243 {
244  sinkType.name = name;
245  sinkType.sinkID = sinkID;
246  sinkType.availability = available;
247  sinkType.muteState = muteState;
248  sinkType.volume = mainVolume;
249  sinkType.sinkClassID = sinkClassID;
250 }
251 
252 /* Connection */
253 
254 void CAmDatabaseHandlerMap::AmConnection::getDescription (std::string & outString) const
255 {
256  std::ostringstream fmt;
257  fmt << "Connection id(" << connectionID << ") " << std::endl <<
258  "sourceID(" << sourceID <<
259  ") sinkID(" << sinkID <<
260  ") delay(" << delay <<
261  ") connectionFormat(" << connectionFormat <<
262  ") reserved(" << reserved << ")" << std::endl;
263  outString = fmt.str();
264 }
265 
266 /* Main Connection */
267 
268 void CAmDatabaseHandlerMap::AmMainConnection::getDescription (std::string & outString) const
269 {
270  std::ostringstream fmt;
271  fmt << "MainConnection id(" << mainConnectionID << ") " << std::endl <<
272  "connectionState(" << connectionState <<
273  ") sinkID(" << sinkID <<
274  ") sourceID(" << sourceID <<
275  ") delay(" << delay <<
276  ") listConnectionID (";
277  std::for_each(listConnectionID.begin(), listConnectionID.end(), [&](const am_connectionID_t & connID) {
278  fmt << "["<< connID << "]";
279  });
280  fmt << ")" << std::endl;
281  outString = fmt.str();
282 }
283 
284 void CAmDatabaseHandlerMap::am_MainConnection_Database_s::getMainConnectionType(am_MainConnectionType_s & connectionType) const
285 {
286  connectionType.mainConnectionID = mainConnectionID;
287  connectionType.sourceID = sourceID;
288  connectionType.sinkID = sinkID;
289  connectionType.connectionState = connectionState;
290  connectionType.delay = delay;
291 }
292 
293 /* Source Class */
294 
295 void CAmDatabaseHandlerMap::AmSourceClass::getDescription (std::string & outString) const
296 {
297  std::ostringstream fmt;
298  fmt << "Source class(" << name.c_str() << ") id(" << sourceClassID << ")\n" <<
299  ") listClassProperties (";
300  std::for_each(listClassProperties.begin(), listClassProperties.end(), [&](const am_ClassProperty_s & ref) {
301  fmt << "[classProperty:" << ref.classProperty << " value:" << ref.value << "]";
302  });
303  fmt << ")" << std::endl;
304  outString = fmt.str();
305 }
306 
307 /* Sink Class */
308 
309 void CAmDatabaseHandlerMap::AmSinkClass::getDescription (std::string & outString) const
310 {
311  std::ostringstream fmt;
312  fmt << "Sink class(" << name.c_str() << ") id(" << sinkClassID << ")\n" <<
313  ") listClassProperties (";
314  std::for_each(listClassProperties.begin(), listClassProperties.end(), [&](const am_ClassProperty_s & ref) {
315  fmt << "[classProperty:" << ref.classProperty << " value:" << ref.value << "]";
316  });
317  fmt << ")" << std::endl;
318  outString = fmt.str();
319 }
320 
321 
322 /* Gateway */
323 
324 void CAmDatabaseHandlerMap::AmGateway::getDescription (std::string & outString) const
325 {
326  std::ostringstream fmt;
327  fmt << "Gateway(" << name.c_str() << ") id(" << gatewayID << ")\n" <<
328  "sinkID(" << sinkID <<
329  ") sourceID(" << sourceID <<
330  ") domainSinkID(" << domainSinkID <<
331  ") domainSourceID(" << domainSourceID <<
332  ") controlDomainID(" << controlDomainID <<
333  ") listSourceFormats (";
334  std::for_each(listSourceFormats.begin(), listSourceFormats.end(), [&](const am_CustomConnectionFormat_t & ref) {
335  fmt << "[" << ref << "]";
336  });
337  fmt << ") listSinkFormats (";
338  std::for_each(listSinkFormats.begin(), listSinkFormats.end(), [&](const am_CustomConnectionFormat_t & ref) {
339  fmt << "[" << ref << "]";
340  });
341  fmt << ") convertionMatrix (";
342  std::for_each(convertionMatrix.begin(), convertionMatrix.end(), [&](const bool & ref) {
343  fmt << "[" << ref << "]";
344  });
345  fmt << ")" << std::endl;
346  outString = fmt.str();
347 }
348 
349 /* Converter */
350 
351 void CAmDatabaseHandlerMap::AmConverter::getDescription (std::string & outString) const
352 {
353  std::ostringstream fmt;
354  fmt << "Converter(" << name.c_str() << ") id(" << converterID << ")\n" <<
355  "sinkID(" << sinkID <<
356  ") sourceID(" << sourceID <<
357  ") domainSinkID(" << domainID <<
358  ") listSourceFormats (";
359  std::for_each(listSourceFormats.begin(), listSourceFormats.end(), [&](const am_CustomConnectionFormat_t & ref) {
360  fmt << "[" << ref << "]";
361  });
362  fmt << ") listSinkFormats (";
363  std::for_each(listSinkFormats.begin(), listSinkFormats.end(), [&](const am_CustomConnectionFormat_t & ref) {
364  fmt << "[" << ref << "]";
365  });
366  fmt << ") convertionMatrix (";
367  std::for_each(convertionMatrix.begin(), convertionMatrix.end(), [&](const bool & ref) {
368  fmt << "[" << ref << "]";
369  });
370  fmt << ")" << std::endl;
371  outString = fmt.str();
372 }
373 
374 /* Crossfader */
375 
376 void CAmDatabaseHandlerMap::AmCrossfader::getDescription (std::string & outString) const
377 {
378  std::ostringstream fmt;
379  fmt << "Crossfader(" << name.c_str() << ") id(" << crossfaderID << ")\n" <<
380  "sinkID_A(" << sinkID_A <<
381  ") sinkID_B(" << sinkID_B <<
382  ") sourceID(" << sourceID <<
383  ") hotSink(" << hotSink <<
384  ")" << std::endl;
385  outString = fmt.str();
386 }
387 
388 bool CAmDatabaseHandlerMap::AmMappedData::increaseID(int16_t & resultID, AmIdentifier & elementID,
389  int16_t const desiredStaticID = 0)
390 {
391  if( desiredStaticID > 0 && desiredStaticID < elementID.mMin )
392  {
393  resultID = desiredStaticID;
394  return true;
395  }
396  else if( elementID.mCurrentValue < elementID.mMax ) //The last used value is 'limit' - 1. e.g. SHRT_MAX - 1, SHRT_MAX is reserved.
397  {
398  resultID = elementID.mCurrentValue++;
399  return true;
400  }
401  else
402  {
403  resultID = -1;
404  return false;
405  }
406 }
407 
408 template <typename TMapKey,class TMapObject> bool CAmDatabaseHandlerMap::AmMappedData::getNextConnectionID(int16_t & resultID, AmIdentifier & connID,
409  const std::unordered_map<TMapKey, TMapObject> & map)
410 {
411  TMapKey nextID;
412  int16_t const lastID = connID.mCurrentValue;
413  if( connID.mCurrentValue < connID.mMax )
414  nextID = connID.mCurrentValue++;
415  else
416  nextID = connID.mCurrentValue = connID.mMin;
417 
418  bool notFreeIDs = false;
419  while( existsObjectWithKeyInMap(nextID, map) )
420  {
421 
422  if( connID.mCurrentValue < connID.mMax )
423  nextID = connID.mCurrentValue++;
424  else
425  {
426  connID.mCurrentValue = connID.mMin;
427  nextID = connID.mCurrentValue;
428  }
429 
430  if( connID.mCurrentValue == lastID )
431  {
432  notFreeIDs = true;
433  break;
434  }
435  }
436  if(notFreeIDs)
437  {
438  resultID = -1;
439  return false;
440  }
441  resultID = nextID;
442  return true;
443 }
444 
445 bool CAmDatabaseHandlerMap::AmMappedData::increaseMainConnectionID(int16_t & resultID)
446 {
447  return getNextConnectionID(resultID, mCurrentMainConnectionID, mMainConnectionMap);
448 }
449 
450 bool CAmDatabaseHandlerMap::AmMappedData::increaseConnectionID(int16_t & resultID)
451 {
452  return getNextConnectionID(resultID, mCurrentConnectionID, mConnectionMap);
453 }
454 
455 
457  mFirstStaticSink(true), //
458  mFirstStaticSource(true), //
459  mFirstStaticGateway(true), //
460  mFirstStaticConverter(true), //
461  mFirstStaticSinkClass(true), //
462  mFirstStaticSourceClass(true), //
463  mFirstStaticCrossfader(true), //
464  mListConnectionFormat(), //
465  mMappedData(),
466  mDatabaseObservers()
467 {
468  logVerbose(__METHOD_NAME__,"Init ");
469 }
470 
472 {
473  logVerbose(__METHOD_NAME__,"Destroy");
474  for(AmDatabaseObserverCallbacks * ptr: mDatabaseObservers)
475  ptr->mpDatabaseHandler=nullptr;
476 }
477 
479 {
480  if(domainData.name.empty())
481  {
482  logError(__METHOD_NAME__,"DomainName must not be emtpy!");
483  return (E_NOT_POSSIBLE);
484  }
485  if(domainData.busname.empty())
486  {
487  logError(__METHOD_NAME__,"Busname must not be emtpy!");
488  return (E_NOT_POSSIBLE);
489  }
490  if(!(domainData.state>=DS_UNKNOWN && domainData.state<=DS_MAX))
491  {
492  logError(__METHOD_NAME__,"State must not be valid!");
493  return (E_NOT_POSSIBLE);
494  }
495  //first check for a reserved domain
496  am_Domain_s const *reservedDomain = objectMatchingPredicate<AmDomain, am_domainID_t>(mMappedData.mDomainMap, [&](const AmDomain & obj){
497  return domainData.name.compare(obj.name)==0;
498  });
499 
500  int16_t nextID = 0;
501 
502  if( NULL != reservedDomain )
503  {
504  nextID = reservedDomain->domainID;
505  domainID = nextID;
506  mMappedData.mDomainMap[nextID] = domainData;
507  mMappedData.mDomainMap[nextID].domainID = nextID;
508  mMappedData.mDomainMap[nextID].reserved = 0;
509  logVerbose("DatabaseHandler::enterDomainDB entered reserved domain with name=", domainData.name, "busname=", domainData.busname, "nodename=", domainData.nodename, "reserved ID:", domainID);
510 
511  NOTIFY_OBSERVERS1(dboNewDomain, mMappedData.mDomainMap[nextID])
512 
513  return (E_OK);
514  }
515  else
516  {
517  if(mMappedData.increaseID(nextID, mMappedData.mCurrentDomainID, domainData.domainID))
518  {
519  domainID = nextID;
520  mMappedData.mDomainMap[nextID] = domainData;
521  mMappedData.mDomainMap[nextID].domainID = nextID;
522  logVerbose("DatabaseHandler::enterDomainDB entered new domain with name=", domainData.name, "busname=", domainData.busname, "nodename=", domainData.nodename, "assigned ID:", domainID);
523 
524  NOTIFY_OBSERVERS1(dboNewDomain, mMappedData.mDomainMap[nextID])
525 
526  return (E_OK);
527  }
528  else
529  {
530  domainID = 0;
531  logVerbose(__METHOD_NAME__,"Max limit reached.");
532  return (E_UNKNOWN);
533  }
534  }
535 }
536 
537 int16_t CAmDatabaseHandlerMap::calculateDelayForRoute(const std::vector<am_connectionID_t>& listConnectionID)
538 {
539  int16_t delay = 0;
540  std::vector<am_connectionID_t>::const_iterator elementIterator = listConnectionID.begin();
541  for (; elementIterator < listConnectionID.end(); ++elementIterator)
542  {
543  am_connectionID_t key = *elementIterator;
544  std::unordered_map<am_connectionID_t, am_Connection_Database_s>::const_iterator it = mMappedData.mConnectionMap.find(key);
545  if (it!=mMappedData.mConnectionMap.end())
546  {
547  int16_t temp_delay = it->second.delay;
548  if (temp_delay != -1 && delay != -1)
549  delay += temp_delay;
550  else
551  delay = -1;
552  }
553  }
554  return delay;
555 }
556 
558 {
559  if(mainConnectionData.mainConnectionID!=0)
560  {
561  logError(__METHOD_NAME__,"mainConnectionID must be 0!");
562  return (E_NOT_POSSIBLE);
563  }
564  if(!(mainConnectionData.connectionState>=CS_UNKNOWN && mainConnectionData.connectionState<=CS_MAX))
565  {
566  logError(__METHOD_NAME__,"connectionState must be valid!");
567  return (E_NOT_POSSIBLE);
568  }
569  if(!existSink(mainConnectionData.sinkID))
570  {
571  logError(__METHOD_NAME__,"sinkID must be valid!");
572  return (E_NOT_POSSIBLE);
573  }
574  if(!existSource(mainConnectionData.sourceID))
575  {
576  logError(__METHOD_NAME__,"sourceID must be valid!");
577  return (E_NOT_POSSIBLE);
578  }
579 
580  int16_t delay = 0;
581  int16_t nextID = 0;
582  if(mMappedData.increaseMainConnectionID(nextID))
583  {
584  connectionID = nextID;
585  mMappedData.mMainConnectionMap[nextID] = mainConnectionData;
586  mMappedData.mMainConnectionMap[nextID].mainConnectionID = nextID;
587  }
588  else
589  {
590  connectionID = 0;
591  logVerbose(__METHOD_NAME__,"Max limit reached.");
592  return (E_UNKNOWN);
593  }
594 
595  //now check the connectionTable for all connections in the route. IF connectionID exist
596  delay = calculateDelayForRoute(mainConnectionData.listConnectionID);
597  logVerbose("DatabaseHandler::enterMainConnectionDB entered new mainConnection with sourceID", mainConnectionData.sourceID, "sinkID:", mainConnectionData.sinkID, "delay:", delay, "assigned ID:", connectionID);
598 
599 
600  if (mDatabaseObservers.size())
601  {
602  am_MainConnectionType_s mainConnection;
603  mMappedData.mMainConnectionMap[nextID].getMainConnectionType(mainConnection);
604 
605  NOTIFY_OBSERVERS1(dboNewMainConnection, mainConnection)
606  NOTIFY_OBSERVERS2(dboMainConnectionStateChanged, connectionID, mMappedData.mMainConnectionMap[nextID].connectionState)
607  }
608 
609  //finally, we update the delay value for the maintable
610  if (delay == 0)
611  delay = -1;
612  (void)changeDelayMainConnection(delay, connectionID);
613 
614  return (E_OK);
615 }
616 
621 bool CAmDatabaseHandlerMap::insertSinkDB(const am_Sink_s & sinkData, am_sinkID_t & sinkID)
622 {
623  int16_t nextID = 0;
624  if( mMappedData.increaseID(nextID, mMappedData.mCurrentSinkID, sinkData.sinkID) )
625  {
626  sinkID = nextID;
627  mMappedData.mSinkMap[nextID] = sinkData;
628  mMappedData.mSinkMap[nextID].sinkID = nextID;
629  filterDuplicateNotificationConfigurationTypes(mMappedData.mSinkMap[nextID].listNotificationConfigurations);
630  filterDuplicateNotificationConfigurationTypes(mMappedData.mSinkMap[nextID].listMainNotificationConfigurations);
631  return (true);
632  }
633  else
634  {
635  sinkID = 0;
636  logVerbose(__METHOD_NAME__,"Max limit reached!");
637  return (false);
638  }
639 }
640 
642 {
643  if(sinkData.sinkID>=DYNAMIC_ID_BOUNDARY)
644  {
645  logError(__METHOD_NAME__,"sinkID must be below:",DYNAMIC_ID_BOUNDARY);
646  return (E_NOT_POSSIBLE);
647  }
648  if(!existDomain(sinkData.domainID))
649  {
650  logError(__METHOD_NAME__,"domainID must be valid");
651  return (E_NOT_POSSIBLE);
652  }
653  if(sinkData.name.empty())
654  {
655  logError(__METHOD_NAME__,"sinkName must not be zero");
656  return (E_NOT_POSSIBLE);
657  }
658  if(!existSinkClass(sinkData.sinkClassID))
659  {
660  logError(__METHOD_NAME__,"sinkClass must be valid");
661  return (E_NOT_POSSIBLE);
662  }
663 
664  if(!(sinkData.muteState>=MS_UNKNOWN && sinkData.muteState<=MS_MAX))
665  {
666  logError(__METHOD_NAME__,"muteState must be valid");
667  return (E_NOT_POSSIBLE);
668  }
669 
670  am_sinkID_t temp_SinkID = 0;
671  am_sinkID_t temp_SinkIndex = 0;
672  //if sinkID is zero and the first Static Sink was already entered, the ID is created
673  am_Sink_s const *reservedDomain = objectMatchingPredicate<AmSink, am_sinkID_t>(mMappedData.mSinkMap, [&](const AmSink & obj){
674  return true==obj.reserved && obj.name.compare(sinkData.name)==0;
675  });
676  if( NULL!=reservedDomain )
677  {
678  am_sinkID_t oldSinkID = reservedDomain->sinkID;
679  mMappedData.mSinkMap[oldSinkID] = sinkData;
680  mMappedData.mSinkMap[oldSinkID].reserved = 0;
681  temp_SinkID = oldSinkID;
682  temp_SinkIndex = oldSinkID;
683  }
684  else
685  {
686  bool result;
687  if ( sinkData.sinkID != 0 || mFirstStaticSink )
688  {
689  //check if the ID already exists
690  if (existSinkNameOrID(sinkData.sinkID, sinkData.name))
691  {
692  sinkID = sinkData.sinkID;
693  return (E_ALREADY_EXISTS);
694  }
695  }
696  result = insertSinkDB(sinkData, temp_SinkID);
697  if( false == result )
698  return (E_UNKNOWN);
699  temp_SinkIndex = temp_SinkID;
700  }
701  //if the first static sink is entered, we need to set it onto the boundary
702  if (sinkData.sinkID == 0 && mFirstStaticSink)
703  {
704  mFirstStaticSink = false;
705  }
706  mMappedData.mSinkMap[temp_SinkIndex].sinkID = temp_SinkID;
707  sinkID = temp_SinkID;
708 
709  am_Sink_s & sink = mMappedData.mSinkMap[temp_SinkID];
710  logVerbose("DatabaseHandler::enterSinkDB entered new sink with name", sink.name, "domainID:", sink.domainID, "classID:", sink.sinkClassID, "volume:", sink.volume, "assigned ID:", sink.sinkID);
711 
712  sink.sinkID=sinkID;
713  NOTIFY_OBSERVERS1(dboNewSink, sink)
714 
715  return (E_OK);
716 }
717 
718 bool CAmDatabaseHandlerMap::insertCrossfaderDB(const am_Crossfader_s & crossfaderData, am_crossfaderID_t & crossfaderID)
719 {
720  int16_t nextID = 0;
721  if(mMappedData.increaseID(nextID, mMappedData.mCurrentCrossfaderID, crossfaderData.crossfaderID))
722  {
723  crossfaderID = nextID;
724  mMappedData.mCrossfaderMap[nextID] = crossfaderData;
725  mMappedData.mCrossfaderMap[nextID].crossfaderID = nextID;
726  return (true);
727  }
728  else
729  {
730  crossfaderID = 0;
731  logVerbose(__METHOD_NAME__,"Max limit reached.");
732  return (false);
733  }
734 }
735 
737 {
738  if(crossfaderData.crossfaderID>=DYNAMIC_ID_BOUNDARY)
739  {
740  logError(__METHOD_NAME__,"crossfaderID must be below:",DYNAMIC_ID_BOUNDARY);
741  return (E_NOT_POSSIBLE);
742  }
743 
744  if(!(crossfaderData.hotSink>=HS_UNKNOWN && crossfaderData.hotSink<=HS_MAX))
745  {
746  logError(__METHOD_NAME__,"hotSink must be valid");
747  return (E_NOT_POSSIBLE);
748  }
749  if(crossfaderData.name.empty())
750  {
751  logError(__METHOD_NAME__,"crossfaderName must not be zero");
752  return (E_NOT_POSSIBLE);
753  }
754 
755  if(!existSink(crossfaderData.sinkID_A))
756  {
757  logError(__METHOD_NAME__,"sinkID_A must exist");
758  return (E_NOT_POSSIBLE);
759  }
760  if(!existSink(crossfaderData.sinkID_B))
761  {
762  logError(__METHOD_NAME__,"sinkID_B must exist");
763  return (E_NOT_POSSIBLE);
764  }
765  if(!existSource(crossfaderData.sourceID))
766  {
767  logError(__METHOD_NAME__,"sourceID must exist");
768  return (E_NOT_POSSIBLE);
769  }
770 
771  am_crossfaderID_t temp_CrossfaderID = 0;
772  am_crossfaderID_t temp_CrossfaderIndex = 0;
773 
774  bool result;
775  //if gatewayData is zero and the first Static Sink was already entered, the ID is created
776  if (crossfaderData.crossfaderID != 0 || mFirstStaticCrossfader)
777  {
778  //check if the ID already exists
779  if (existCrossFader(crossfaderData.crossfaderID))
780  {
781  crossfaderID = crossfaderData.crossfaderID;
782  return (E_ALREADY_EXISTS);
783  }
784  }
785  result = insertCrossfaderDB(crossfaderData, temp_CrossfaderID);
786  if( false == result )
787  return (E_UNKNOWN);
788  temp_CrossfaderIndex = temp_CrossfaderID;
789 
790  //if the first static sink is entered, we need to set it onto the boundary
791  if ( 0==crossfaderData.crossfaderID && mFirstStaticCrossfader)
792  {
793  mFirstStaticCrossfader = false;
794  }
795 
796  mMappedData.mCrossfaderMap[temp_CrossfaderIndex].crossfaderID = temp_CrossfaderID;
797  crossfaderID = temp_CrossfaderID;
798  logVerbose("DatabaseHandler::enterCrossfaderDB entered new crossfader with name=", crossfaderData.name, "sinkA= ", crossfaderData.sinkID_A, "sinkB=", crossfaderData.sinkID_B, "source=", crossfaderData.sourceID, "assigned ID:", crossfaderID);
799 
800  NOTIFY_OBSERVERS1(dboNewCrossfader, mMappedData.mCrossfaderMap[temp_CrossfaderIndex])
801 
802  return (E_OK);
803 }
804 
805 bool CAmDatabaseHandlerMap::insertGatewayDB(const am_Gateway_s & gatewayData, am_gatewayID_t & gatewayID)
806 {
807  int16_t nextID = 0;
808  if(mMappedData.increaseID(nextID, mMappedData.mCurrentGatewayID, gatewayData.gatewayID))
809  {
810  gatewayID = nextID;
811  mMappedData.mGatewayMap[nextID] = gatewayData;
812  mMappedData.mGatewayMap[nextID].gatewayID = nextID;
813  return (true);
814  }
815  else
816  {
817  gatewayID = 0;
818  logVerbose(__METHOD_NAME__,"Max limit reached.");
819  return (false);
820  }
821 }
822 
824 {
825 
826  if(gatewayData.gatewayID>=DYNAMIC_ID_BOUNDARY)
827  {
828  logError(__METHOD_NAME__,"gatewayID must be below:",DYNAMIC_ID_BOUNDARY);
829  return (E_NOT_POSSIBLE);
830  }
831 
832  if(!existDomain(gatewayData.controlDomainID))
833  {
834  logError(__METHOD_NAME__,"controlDomainID must be exist");
835  return (E_NOT_POSSIBLE);
836  }
837 
838  if(gatewayData.name.empty())
839  {
840  logError(__METHOD_NAME__,"gatewayName must not be empty");
841  return (E_NOT_POSSIBLE);
842  }
843 
844  //might be that the sinks and sources are not there during registration time
845  //assert(existSink(gatewayData.sinkID));
846  //assert(existSource(gatewayData.sourceID));
847 
848  am_gatewayID_t temp_GatewayID = 0;
849  am_gatewayID_t temp_GatewayIndex = 0;
850  //if gatewayData is zero and the first Static Sink was already entered, the ID is created
851  bool result;
852  if (gatewayData.gatewayID != 0 || mFirstStaticGateway)
853  {
854  //check if the ID already exists
855  if (existGateway(gatewayData.gatewayID))
856  {
857  gatewayID = gatewayData.gatewayID;
858  return (E_ALREADY_EXISTS);
859  }
860  }
861  result = insertGatewayDB(gatewayData, temp_GatewayID);
862  if( false == result )
863  return (E_UNKNOWN);
864 
865  temp_GatewayIndex = temp_GatewayID;
866  //if the ID is not created, we add it to the query
867  if (gatewayData.gatewayID == 0 && mFirstStaticGateway)
868  {
869  mFirstStaticGateway = false;
870  }
871  mMappedData.mGatewayMap[temp_GatewayIndex].gatewayID = temp_GatewayID;
872  gatewayID = temp_GatewayID;
873 
874  logVerbose("DatabaseHandler::enterGatewayDB entered new gateway with name", gatewayData.name, "sourceID:", gatewayData.sourceID, "sinkID:", gatewayData.sinkID, "assigned ID:", gatewayID);
875 
876  NOTIFY_OBSERVERS1(dboNewGateway, mMappedData.mGatewayMap[temp_GatewayIndex])
877  return (E_OK);
878 }
879 
880 bool CAmDatabaseHandlerMap::insertConverterDB(const am_Converter_s & converteData, am_converterID_t & converterID)
881 {
882  int16_t nextID = 0;
883  if(mMappedData.increaseID(nextID, mMappedData.mCurrentConverterID, converteData.converterID))
884  {
885  converterID = nextID;
886  mMappedData.mConverterMap[nextID] = converteData;
887  mMappedData.mConverterMap[nextID].converterID = nextID;
888  return (true);
889  }
890  else
891  {
892  converterID = 0;
893  logVerbose(__METHOD_NAME__,"Max limit reached.");
894  return (false);
895  }
896 }
897 
899 {
900  if(converterData.converterID>=DYNAMIC_ID_BOUNDARY)
901  {
902  logError(__METHOD_NAME__,"converterID must be below:",DYNAMIC_ID_BOUNDARY);
903  return (E_NOT_POSSIBLE);
904  }
905 
906  if(!existSink(converterData.sinkID))
907  {
908  logError(__METHOD_NAME__,"sinkID must exists");
909  return (E_NOT_POSSIBLE);
910  }
911 
912  if(!existSource(converterData.sourceID))
913  {
914  logError(__METHOD_NAME__,"sourceID must exists");
915  return (E_NOT_POSSIBLE);
916  }
917 
918  if(!existDomain(converterData.domainID))
919  {
920  logError(__METHOD_NAME__,"domainID must exists");
921  return (E_NOT_POSSIBLE);
922  }
923 
924  if(converterData.name.empty())
925  {
926  logError(__METHOD_NAME__,"converterName must not be empty");
927  return (E_NOT_POSSIBLE);
928  }
929 
930  //might be that the sinks and sources are not there during registration time
931  //assert(existSink(gatewayData.sinkID));
932  //assert(existSource(gatewayData.sourceID));
933 
934  am_converterID_t tempID = 0;
935  am_converterID_t tempIndex = 0;
936  //if gatewayData is zero and the first Static Sink was already entered, the ID is created
937  bool result;
938  if (converterData.converterID != 0 || mFirstStaticConverter)
939  {
940  //check if the ID already exists
941  if (existConverter(converterData.converterID))
942  {
943  converterID = converterData.converterID;
944  return (E_ALREADY_EXISTS);
945  }
946  }
947  result = insertConverterDB(converterData, tempID);
948  if( false == result )
949  return (E_UNKNOWN);
950 
951  tempIndex = tempID;
952  //if the ID is not created, we add it to the query
953  if (converterData.converterID == 0 && mFirstStaticConverter)
954  {
955  mFirstStaticConverter = false;
956  }
957  mMappedData.mConverterMap[tempIndex].converterID = tempID;
958  converterID = tempID;
959 
960  logVerbose("DatabaseHandler::enterConverterDB entered new converter with name", converterData.name, "sourceID:", converterData.sourceID, "sinkID:", converterData.sinkID, "assigned ID:", converterID);
961  NOTIFY_OBSERVERS1(dboNewConverter, mMappedData.mConverterMap[tempIndex])
962 
963  return (E_OK);
964 }
965 
966 void CAmDatabaseHandlerMap::dump( std::ostream & output ) const
967 {
968  output << std::endl << "****************** DUMP START ******************" << std::endl;
969  AmMappedData::printMap(mMappedData.mDomainMap, output);
970  AmMappedData::printMap(mMappedData.mSourceMap, output);
971  AmMappedData::printMap(mMappedData.mSinkMap, output);
972  AmMappedData::printMap(mMappedData.mSourceClassesMap, output);
973  AmMappedData::printMap(mMappedData.mSinkClassesMap, output);
974  AmMappedData::printMap(mMappedData.mConnectionMap, output);
975  AmMappedData::printMap(mMappedData.mMainConnectionMap, output);
976  AmMappedData::printMap(mMappedData.mCrossfaderMap, output);
977  AmMappedData::printMap(mMappedData.mGatewayMap, output);
978  AmVectorSystemProperties::const_iterator iter = mMappedData.mSystemProperties.begin();
979  output << "System properties" << "\n";
980  for(; iter!=mMappedData.mSystemProperties.end(); iter++)
981  output << "[type:" << iter->type << " value:" << iter->value << "]";
982  output << std::endl << "****************** DUMP END ******************" << std::endl;
983 }
984 
985 bool CAmDatabaseHandlerMap::insertSourceDB(const am_Source_s & sourceData, am_sourceID_t & sourceID)
986 {
987  int16_t nextID = 0;
988  if(mMappedData.increaseID(nextID, mMappedData.mCurrentSourceID, sourceData.sourceID))
989  {
990  sourceID = nextID;
991  mMappedData.mSourceMap[nextID] = sourceData;
992  mMappedData.mSourceMap[nextID].sourceID = nextID;
993  filterDuplicateNotificationConfigurationTypes(mMappedData.mSourceMap[nextID].listNotificationConfigurations);
994  filterDuplicateNotificationConfigurationTypes(mMappedData.mSourceMap[nextID].listMainNotificationConfigurations);
995  return (true);
996  }
997  else
998  {
999  sourceID = 0;
1000  logVerbose(__METHOD_NAME__,"Max limit reached.");
1001  return (false);
1002  }
1003 }
1004 
1006 {
1007  if(sourceData.sourceID>=DYNAMIC_ID_BOUNDARY)
1008  {
1009  logError(__METHOD_NAME__,"sourceID must be below:",DYNAMIC_ID_BOUNDARY);
1010  return (E_NOT_POSSIBLE);
1011  }
1012  if(!existDomain(sourceData.domainID))
1013  {
1014  logError(__METHOD_NAME__,"domainID must be valid");
1015  return (E_NOT_POSSIBLE);
1016  }
1017  if(sourceData.name.empty())
1018  {
1019  logError(__METHOD_NAME__,"sourceName must not be zero");
1020  return (E_NOT_POSSIBLE);
1021  }
1022  if(!existSourceClass(sourceData.sourceClassID))
1023  {
1024  logError(__METHOD_NAME__,"sourceClassID must be valid");
1025  return (E_NOT_POSSIBLE);
1026  }
1027 
1028  if(!(sourceData.sourceState>=SS_UNKNNOWN && sourceData.sourceState<=SS_MAX))
1029  {
1030  logError(__METHOD_NAME__,"sourceState must be valid");
1031  return (E_NOT_POSSIBLE);
1032  }
1033 
1034  bool isFirstStatic = sourceData.sourceID == 0 && mFirstStaticSource;
1035  am_sourceID_t temp_SourceID = 0;
1036  am_sourceID_t temp_SourceIndex = 0;
1037  AmSource const *reservedSource = objectMatchingPredicate<AmSource, am_sourceID_t>(mMappedData.mSourceMap, [&](const AmSource & obj){
1038  return true==obj.reserved && obj.name.compare(sourceData.name)==0;
1039  });
1040  if( NULL != reservedSource )
1041  {
1042  am_sourceID_t oldSourceID = reservedSource->sourceID;
1043  mMappedData.mSourceMap[oldSourceID] = sourceData;
1044  mMappedData.mSourceMap[oldSourceID].reserved = 0;
1045  temp_SourceID = oldSourceID;
1046  temp_SourceIndex = oldSourceID;
1047  }
1048  else
1049  {
1050  bool result;
1051  if ( !isFirstStatic )
1052  {
1053  //check if the ID already exists
1054  if (existSourceNameOrID(sourceData.sourceID, sourceData.name))
1055  {
1056  sourceID = sourceData.sourceID;
1057  return (E_ALREADY_EXISTS);
1058  }
1059  }
1060  result = insertSourceDB(sourceData, temp_SourceID);
1061  if( false == result )
1062  return (E_UNKNOWN);
1063  temp_SourceIndex = temp_SourceID;
1064  }
1065 
1066  if ( isFirstStatic )
1067  {
1068  //if the first static sink is entered, we need to set it onto the boundary if needed
1069  mFirstStaticSource = false;
1070  }
1071  mMappedData.mSourceMap[temp_SourceIndex].sourceID = temp_SourceID;
1072  sourceID = temp_SourceID;
1073 
1074  logVerbose("DatabaseHandler::enterSourceDB entered new source with name", sourceData.name, "domainID:", sourceData.domainID, "classID:", sourceData.sourceClassID, "visible:", sourceData.visible, "assigned ID:", sourceID);
1075 
1076  NOTIFY_OBSERVERS1(dboNewSource, mMappedData.mSourceMap[temp_SourceIndex])
1077 
1078  return (E_OK);
1079 }
1080 
1082 {
1083  if(connection.connectionID!=0)
1084  {
1085  logError(__METHOD_NAME__,"connectionID must be 0!");
1086  return (E_NOT_POSSIBLE);
1087  }
1088 
1089  if(!existSink(connection.sinkID))
1090  {
1091  logError(__METHOD_NAME__,"sinkID must exist!");
1092  return (E_NOT_POSSIBLE);
1093  }
1094 
1095  if(!existSource(connection.sourceID))
1096  {
1097  logError(__METHOD_NAME__,"sourceID must exist!");
1098  return (E_NOT_POSSIBLE);
1099  }
1100  //connection format is not checked, because it's project specific
1101  int16_t nextID = 0;
1102  if(mMappedData.increaseConnectionID(nextID))
1103  {
1104  connectionID = nextID;
1105  mMappedData.mConnectionMap[nextID] = connection;
1106  mMappedData.mConnectionMap[nextID].connectionID = nextID;
1107  mMappedData.mConnectionMap[nextID].reserved = true;
1108  }
1109  else
1110  {
1111  connectionID = 0;
1112  logVerbose(__METHOD_NAME__,"Max limit reached.");
1113  return (E_UNKNOWN);
1114  }
1115 
1116  logVerbose("DatabaseHandler::enterConnectionDB entered new connection sinkID=", connection.sinkID, "sourceID=", connection.sourceID, "connectionFormat=", connection.connectionFormat, "assigned ID=", connectionID);
1117  return (E_OK);
1118 }
1119 
1120 bool CAmDatabaseHandlerMap::insertSinkClassDB(const am_SinkClass_s & sinkClass, am_sinkClass_t & sinkClassID)
1121 {
1122  int16_t nextID = 0;
1123  if(mMappedData.increaseID(nextID, mMappedData.mCurrentSinkClassesID, sinkClass.sinkClassID))
1124  {
1125  sinkClassID = nextID;
1126  mMappedData.mSinkClassesMap[nextID] = sinkClass;
1127  mMappedData.mSinkClassesMap[nextID].sinkClassID = nextID;
1128  return (true);
1129  }
1130  else
1131  {
1132  sinkClassID = 0;
1133  logVerbose(__METHOD_NAME__,"Max limit reached.");
1134  return (false);
1135  }
1136 }
1137 
1139 {
1140  if(sinkClass.sinkClassID>=DYNAMIC_ID_BOUNDARY)
1141  {
1142  logError(__METHOD_NAME__,"sinkClassID must be <",DYNAMIC_ID_BOUNDARY);
1143  return (E_NOT_POSSIBLE);
1144  }
1145 
1146  if(sinkClass.name.empty())
1147  {
1148  logError(__METHOD_NAME__,"name must not be empty");
1149  return (E_NOT_POSSIBLE);
1150  }
1151 
1152  am_sinkClass_t temp_SinkClassID = 0;
1153  am_sinkClass_t temp_SinkClassIndex = 0;
1154 
1155  bool result;
1156  if (sinkClass.sinkClassID != 0 || mFirstStaticSinkClass)
1157  {
1158  //check if the ID already exists
1159  if (existSinkClass(sinkClass.sinkClassID))
1160  {
1161  sinkClassID = sinkClass.sinkClassID;
1162  return (E_ALREADY_EXISTS);
1163  }
1164  }
1165  result = insertSinkClassDB(sinkClass, temp_SinkClassID);
1166  if( false == result )
1167  return (E_UNKNOWN);
1168 
1169  temp_SinkClassIndex = temp_SinkClassID;
1170  //if the ID is not created, we add it to the query
1171  if (sinkClass.sinkClassID == 0 && mFirstStaticSinkClass)
1172  {
1173  mFirstStaticSinkClass = false;
1174  }
1175  mMappedData.mSinkClassesMap[temp_SinkClassIndex].sinkClassID = temp_SinkClassID;
1176  sinkClassID = temp_SinkClassID;
1177 
1178  //todo:change last_insert implementations for multithreaded usage...
1179  logVerbose("DatabaseHandler::enterSinkClassDB entered new sinkClass");
1180  NOTIFY_OBSERVERS(dboNumberOfSinkClassesChanged)
1181  return (E_OK);
1182 }
1183 
1184 bool CAmDatabaseHandlerMap::insertSourceClassDB(am_sourceClass_t & sourceClassID, const am_SourceClass_s & sourceClass)
1185 {
1186  int16_t nextID = 0;
1187  if(mMappedData.increaseID(nextID, mMappedData.mCurrentSourceClassesID, sourceClass.sourceClassID))
1188  {
1189  sourceClassID = nextID;
1190  mMappedData.mSourceClassesMap[nextID] = sourceClass;
1191  mMappedData.mSourceClassesMap[nextID].sourceClassID = nextID;
1192  return (true);
1193  }
1194  else
1195  {
1196  sourceClassID = 0;
1197  logVerbose(__METHOD_NAME__,"Max limit reached.");
1198  return (false);
1199  }
1200 }
1201 
1203 {
1204  if(sourceClass.sourceClassID>=DYNAMIC_ID_BOUNDARY)
1205  {
1206  logError(__METHOD_NAME__,"sourceClassID must be <",DYNAMIC_ID_BOUNDARY);
1207  return (E_NOT_POSSIBLE);
1208  }
1209 
1210  if(sourceClass.name.empty())
1211  {
1212  logError(__METHOD_NAME__,"name must not be empty");
1213  return (E_NOT_POSSIBLE);
1214  }
1215 
1216 
1217  am_sourceClass_t temp_SourceClassID = 0;
1218  am_sourceClass_t temp_SourceClassIndex = 0;
1219 
1220  bool result;
1221  if (sourceClass.sourceClassID != 0 || mFirstStaticSourceClass)
1222  {
1223  //check if the ID already exists
1224  if (existSourceClass(sourceClass.sourceClassID))
1225  {
1226  sourceClassID = sourceClass.sourceClassID;
1227  return (E_ALREADY_EXISTS);
1228  }
1229  }
1230  result = insertSourceClassDB(temp_SourceClassID, sourceClass);
1231  if( false == result )
1232  return (E_UNKNOWN);
1233 
1234  temp_SourceClassIndex = temp_SourceClassID;
1235  //if the ID is not created, we add it to the query
1236  if (sourceClass.sourceClassID == 0 && mFirstStaticSourceClass)
1237  {
1238  mFirstStaticSinkClass = false;
1239  }
1240  mMappedData.mSourceClassesMap[temp_SourceClassIndex].sourceClassID = temp_SourceClassID;
1241  sourceClassID = temp_SourceClassID;
1242 
1243  //todo:change last_insert implementations for multithread usage...
1244 
1245  logVerbose("DatabaseHandler::enterSourceClassDB entered new sourceClass");
1246 
1247  NOTIFY_OBSERVERS(dboNumberOfSourceClassesChanged)
1248 
1249  return (E_OK);
1250 }
1251 
1252 am_Error_e CAmDatabaseHandlerMap::enterSystemProperties(const std::vector<am_SystemProperty_s> & listSystemProperties)
1253 {
1254  if(listSystemProperties.empty())
1255  {
1256  logError(__METHOD_NAME__,"listSystemProperties must not be empty");
1257  return (E_NOT_POSSIBLE);
1258  }
1259 
1260  mMappedData.mSystemProperties = listSystemProperties;
1261 
1262  logVerbose("DatabaseHandler::enterSystemProperties entered system properties");
1263  return (E_OK);
1264 }
1265 
1266 am_Error_e CAmDatabaseHandlerMap::changeMainConnectionRouteDB(const am_mainConnectionID_t mainconnectionID, const std::vector<am_connectionID_t>& listConnectionID)
1267 {
1268  if(mainconnectionID==0)
1269  {
1270  logError(__METHOD_NAME__,"mainconnectionID must not be 0");
1271  return (E_NOT_POSSIBLE);
1272  }
1273 
1274  if (!existMainConnection(mainconnectionID))
1275  {
1276  logError(__METHOD_NAME__,"existMainConnection must exist");
1277  return (E_NON_EXISTENT);
1278  }
1279 
1280  int16_t delay = calculateDelayForRoute(listConnectionID);
1281 
1282  //now we replace the data in the main connection object with the new one
1283  mMappedData.mMainConnectionMap[mainconnectionID].listConnectionID = listConnectionID;
1284 
1285  if (changeDelayMainConnection(delay,mainconnectionID) == E_NO_CHANGE)
1286  logError("DatabaseHandler::changeMainConnectionRouteDB error while changing mainConnectionDelay to ", delay);
1287 
1288  logVerbose("DatabaseHandler::changeMainConnectionRouteDB entered new route:", mainconnectionID);
1289  return (E_OK);
1290 }
1291 
1293 {
1294  if(mainconnectionID==0)
1295  {
1296  logError(__METHOD_NAME__,"mainconnectionID must not be 0");
1297  return (E_NOT_POSSIBLE);
1298  }
1299 
1300  if(!(connectionState>=CS_UNKNOWN && connectionState<=CS_MAX))
1301  {
1302  logError(__METHOD_NAME__,"connectionState must be valid");
1303  return (E_NOT_POSSIBLE);
1304  }
1305 
1306  if (!existMainConnection(mainconnectionID))
1307  {
1308  logError(__METHOD_NAME__,"existMainConnection must exist");
1309  return (E_NON_EXISTENT);
1310  }
1311 
1312  DB_COND_UPDATE_RIE(mMappedData.mMainConnectionMap[mainconnectionID].connectionState, connectionState);
1313 
1314  logVerbose("DatabaseHandler::changeMainConnectionStateDB changed mainConnectionState of MainConnection:", mainconnectionID, "to:", connectionState);
1315  NOTIFY_OBSERVERS2(dboMainConnectionStateChanged, mainconnectionID, connectionState)
1316  return (E_OK);
1317 }
1318 
1320 {
1321  if (!existSink(sinkID))
1322  {
1323  logError(__METHOD_NAME__,"sinkID must exist");
1324  return (E_NON_EXISTENT);
1325  }
1326 
1327  DB_COND_UPDATE_RIE(mMappedData.mSinkMap[sinkID].mainVolume, mainVolume);
1328 
1329  logVerbose("DatabaseHandler::changeSinkMainVolumeDB changed mainVolume of sink:", sinkID, "to:", mainVolume);
1330 
1331  NOTIFY_OBSERVERS2(dboVolumeChanged, sinkID, mainVolume)
1332 
1333  return (E_OK);
1334 }
1335 
1337 {
1338  if (!(availability.availability>=A_UNKNOWN && availability.availability<=A_MAX))
1339  {
1340  logError(__METHOD_NAME__,"availability must be valid");
1341  return (E_NOT_POSSIBLE);
1342  }
1343 
1344  if (!existSink(sinkID))
1345  {
1346  logError(__METHOD_NAME__,"sinkID must exist");
1347  return (E_NON_EXISTENT);
1348  }
1349 
1350  DB_COND_UPDATE_RIE(mMappedData.mSinkMap[sinkID].available, availability);
1351 
1352  logVerbose("DatabaseHandler::changeSinkAvailabilityDB changed sinkAvailability of sink:", sinkID, "to:", availability.availability, "Reason:", availability.availabilityReason);
1353 
1354  if (sinkVisible(sinkID))
1355  {
1356  NOTIFY_OBSERVERS2(dboSinkAvailabilityChanged,sinkID, availability)
1357  }
1358  return (E_OK);
1359 }
1360 
1362 {
1363 
1364  if(!(domainState>=DS_UNKNOWN && domainState<=DS_MAX))
1365  {
1366  logError(__METHOD_NAME__,"domainState must be valid");
1367  return (E_NOT_POSSIBLE);
1368  }
1369 
1370  if (!existDomain(domainID))
1371  {
1372  logError(__METHOD_NAME__,"domainID must exist");
1373  return (E_NON_EXISTENT);
1374  }
1375 
1376  DB_COND_UPDATE_RIE(mMappedData.mDomainMap[domainID].state, domainState);
1377 
1378  logVerbose("DatabaseHandler::changDomainStateDB changed domainState of domain:", domainID, "to:", domainState);
1379  return (E_OK);
1380 }
1381 
1383 {
1384 
1385  if(!(muteState>=MS_UNKNOWN && muteState<=MS_MAX))
1386  {
1387  logError(__METHOD_NAME__,"muteState must be valid");
1388  return (E_NOT_POSSIBLE);
1389  }
1390 
1391  if (!existSink(sinkID))
1392  {
1393  logError(__METHOD_NAME__,"sinkID must exist");
1394  return (E_NON_EXISTENT);
1395  }
1396 
1397  DB_COND_UPDATE_RIE(mMappedData.mSinkMap[sinkID].muteState, muteState);
1398 
1399  logVerbose("DatabaseHandler::changeSinkMuteStateDB changed sinkMuteState of sink:", sinkID, "to:", muteState);
1400 
1401  NOTIFY_OBSERVERS2(dboSinkMuteStateChanged, sinkID, muteState)
1402 
1403  return (E_OK);
1404 }
1405 
1407 {
1408 
1409  if (!existSink(sinkID))
1410  {
1411  logError(__METHOD_NAME__,"sinkID must exist");
1412  return (E_NON_EXISTENT);
1413  }
1414  am_Sink_Database_s & sink = mMappedData.mSinkMap[sinkID];
1415  std::vector<am_MainSoundProperty_s>::iterator elementIterator = sink.listMainSoundProperties.begin();
1416  for (;elementIterator != sink.listMainSoundProperties.end(); ++elementIterator)
1417  {
1418  if (elementIterator->type == soundProperty.type)
1419  {
1420  DB_COND_UPDATE_RIE(elementIterator->value, soundProperty.value);
1421  if(sink.cacheMainSoundProperties.size())
1422  sink.cacheMainSoundProperties[soundProperty.type] = soundProperty.value;
1423  break;
1424  }
1425  }
1426 
1427  logVerbose("DatabaseHandler::changeMainSinkSoundPropertyDB changed MainSinkSoundProperty of sink:", sinkID, "type:", soundProperty.type, "to:", soundProperty.value);
1428  NOTIFY_OBSERVERS2(dboMainSinkSoundPropertyChanged, sinkID, soundProperty)
1429  return (E_OK);
1430 }
1431 
1433 {
1434 
1435  if (!existSource(sourceID))
1436  {
1437  logError(__METHOD_NAME__,"sourceID must exist");
1438  return (E_NON_EXISTENT);
1439  }
1440  am_Source_Database_s & source = mMappedData.mSourceMap.at(sourceID);
1441  std::vector<am_MainSoundProperty_s>::iterator elementIterator = source.listMainSoundProperties.begin();
1442  for (;elementIterator != source.listMainSoundProperties.end(); ++elementIterator)
1443  {
1444  if (elementIterator->type == soundProperty.type)
1445  {
1446  DB_COND_UPDATE_RIE(elementIterator->value, soundProperty.value);
1447  if(source.cacheMainSoundProperties.size())
1448  source.cacheMainSoundProperties[soundProperty.type] = soundProperty.value;
1449  break;
1450  }
1451  }
1452 
1453  logVerbose("DatabaseHandler::changeMainSourceSoundPropertyDB changed MainSinkSoundProperty of source:", sourceID, "type:", soundProperty.type, "to:", soundProperty.value);
1454 
1455  NOTIFY_OBSERVERS2(dboMainSourceSoundPropertyChanged, sourceID, soundProperty)
1456  return (E_OK);
1457 }
1458 
1460 {
1461  if(!(availability.availability>=A_UNKNOWN && availability.availability<=A_MAX))
1462  {
1463  logError(__METHOD_NAME__,"availability must be valid");
1464  return (E_NOT_POSSIBLE);
1465  }
1466 
1467  if (!existSource(sourceID))
1468  {
1469  logError(__METHOD_NAME__,"sourceID must exist");
1470  return (E_NON_EXISTENT);
1471  }
1472 
1473  DB_COND_UPDATE_RIE(mMappedData.mSourceMap[sourceID].available, availability);
1474 
1475  logVerbose("DatabaseHandler::changeSourceAvailabilityDB changed changeSourceAvailabilityDB of source:", sourceID, "to:", availability.availability, "Reason:", availability.availabilityReason);
1476 
1477  if (sourceVisible(sourceID))
1478  {
1479  NOTIFY_OBSERVERS2(dboSourceAvailabilityChanged, sourceID, availability)
1480  }
1481  return (E_OK);
1482 }
1483 
1485 {
1486  std::vector<am_SystemProperty_s>::iterator elementIterator = mMappedData.mSystemProperties.begin();
1487  for (;elementIterator != mMappedData.mSystemProperties.end(); ++elementIterator)
1488  {
1489  if (elementIterator->type == property.type)
1490  DB_COND_UPDATE_RIE(elementIterator->value, property.value);
1491  }
1492 
1493  logVerbose("DatabaseHandler::changeSystemPropertyDB changed system property");
1494 
1495  NOTIFY_OBSERVERS1(dboSystemPropertyChanged, property)
1496 
1497  return (E_OK);
1498 }
1499 
1501 {
1502 
1503  if (!existMainConnection(mainConnectionID))
1504  {
1505  logError(__METHOD_NAME__,"mainConnectionID must exist");
1506  return (E_NON_EXISTENT);
1507  }
1508 
1510  DB_COND_UPDATE(mMappedData.mMainConnectionMap[mainConnectionID].mainConnectionID, CS_DISCONNECTED);
1511  if (DB_COND_ISMODIFIED)
1512  NOTIFY_OBSERVERS2(dboMainConnectionStateChanged, mainConnectionID, CS_DISCONNECTED)
1513 
1514  mMappedData.mMainConnectionMap.erase(mainConnectionID);
1515  logVerbose("DatabaseHandler::removeMainConnectionDB removed:", mainConnectionID);
1516  NOTIFY_OBSERVERS1(dboRemovedMainConnection, mainConnectionID)
1517 
1518  return (E_OK);
1519 }
1520 
1522 {
1523 
1524  if (!existSink(sinkID))
1525  {
1526  logError(__METHOD_NAME__,"sinkID must exist");
1527  return (E_NON_EXISTENT);
1528  }
1529 
1530  bool visible = sinkVisible(sinkID);
1531 
1532  mMappedData.mSinkMap.erase(sinkID);
1533  // todo: Check the tables SinkMainSoundProperty and SinkMainNotificationConfiguration with 'visible' set to true
1534  //if visible is true then delete SinkMainSoundProperty and SinkMainNotificationConfiguration ????
1535  logVerbose("DatabaseHandler::removeSinkDB removed:", sinkID);
1536 
1537  NOTIFY_OBSERVERS2(dboRemovedSink, sinkID, visible)
1538 
1539  return (E_OK);
1540 }
1541 
1543 {
1544 
1545  if (!existSource(sourceID))
1546  {
1547  logError(__METHOD_NAME__,"sourceID must exist");
1548  return (E_NON_EXISTENT);
1549  }
1550 
1551  bool visible = sourceVisible(sourceID);
1552 
1553  mMappedData.mSourceMap.erase(sourceID);
1554 
1555  // todo: Check the tables SourceMainSoundProperty and SourceMainNotificationConfiguration with 'visible' set to true
1556  //if visible is true then delete SourceMainSoundProperty and SourceMainNotificationConfiguration ????
1557 
1558  logVerbose("DatabaseHandler::removeSourceDB removed:", sourceID);
1559  NOTIFY_OBSERVERS2(dboRemovedSource, sourceID, visible)
1560  return (E_OK);
1561 }
1562 
1564 {
1565 
1566  if (!existGateway(gatewayID))
1567  {
1568  logError(__METHOD_NAME__,"gatewayID must exist");
1569  return (E_NON_EXISTENT);
1570  }
1571 
1572  mMappedData.mGatewayMap.erase(gatewayID);
1573 
1574  logVerbose("DatabaseHandler::removeGatewayDB removed:", gatewayID);
1575  NOTIFY_OBSERVERS1(dboRemoveGateway, gatewayID)
1576  return (E_OK);
1577 }
1578 
1580 {
1581 
1582  if (!existConverter(converterID))
1583  {
1584  logError(__METHOD_NAME__,"converterID must exist");
1585  return (E_NON_EXISTENT);
1586  }
1587 
1588  mMappedData.mConverterMap.erase(converterID);
1589 
1590  logVerbose("DatabaseHandler::removeConverterDB removed:", converterID);
1591  NOTIFY_OBSERVERS1(dboRemoveConverter, converterID)
1592  return (E_OK);
1593 }
1594 
1596 {
1597 
1598  if (!existCrossFader(crossfaderID))
1599  {
1600  logError(__METHOD_NAME__,"crossfaderID must exist");
1601  return (E_NON_EXISTENT);
1602  }
1603  mMappedData.mCrossfaderMap.erase(crossfaderID);
1604 
1605  logVerbose("DatabaseHandler::removeCrossfaderDB removed:", crossfaderID);
1606  NOTIFY_OBSERVERS1(dboRemoveCrossfader, crossfaderID)
1607 
1608  return (E_OK);
1609 }
1610 
1612 {
1613 
1614  if (!existDomain(domainID))
1615  {
1616  logError(__METHOD_NAME__,"domainID must exist");
1617  return (E_NON_EXISTENT);
1618  }
1619  mMappedData.mDomainMap.erase(domainID);
1620 
1621  logVerbose("DatabaseHandler::removeDomainDB removed:", domainID);
1622  NOTIFY_OBSERVERS1(dboRemoveDomain, domainID)
1623 
1624  return (E_OK);
1625 }
1626 
1628 {
1629 
1630  if (!existSinkClass(sinkClassID))
1631  {
1632  logError(__METHOD_NAME__,"sinkClassID must exist");
1633  return (E_NON_EXISTENT);
1634  }
1635 
1636  mMappedData.mSinkClassesMap.erase(sinkClassID);
1637 
1638  logVerbose("DatabaseHandler::removeSinkClassDB removed:", sinkClassID);
1639  NOTIFY_OBSERVERS(dboNumberOfSinkClassesChanged)
1640  return (E_OK);
1641 }
1642 
1644 {
1645 
1646  if (!existSourceClass(sourceClassID))
1647  {
1648  logError(__METHOD_NAME__,"sourceClassID must exist");
1649  return (E_NON_EXISTENT);
1650  }
1651 
1652  mMappedData.mSourceClassesMap.erase(sourceClassID);
1653  logVerbose("DatabaseHandler::removeSourceClassDB removed:", sourceClassID);
1654  NOTIFY_OBSERVERS(dboNumberOfSourceClassesChanged)
1655  return (E_OK);
1656 }
1657 
1659 {
1660  if (!existConnectionID(connectionID))
1661  {
1662  logError(__METHOD_NAME__,"connectionID must exist",connectionID);
1663  return (E_NON_EXISTENT);
1664  }
1665 
1666  mMappedData.mConnectionMap.erase(connectionID);
1667 
1668  logVerbose("DatabaseHandler::removeConnection removed:", connectionID);
1669  return (E_OK);
1670 }
1671 
1673 {
1674 
1675  if (!existSource(sourceID))
1676  {
1677  logWarning(__METHOD_NAME__,"sourceID must exist");
1678  return (E_NON_EXISTENT);
1679  }
1680  am_Source_Database_s source = mMappedData.mSourceMap.at(sourceID);
1681  classInfo.sourceClassID = source.sourceClassID;
1682 
1683  if (!existSourceClass(classInfo.sourceClassID))
1684  {
1685  return (E_NON_EXISTENT);
1686  }
1687  am_SourceClass_s tmpClass = mMappedData.mSourceClassesMap.at(classInfo.sourceClassID);
1688  classInfo = tmpClass;
1689 
1690  return (E_OK);
1691 }
1692 
1694 {
1695 
1696  if (!existSink(sinkID))
1697  {
1698  logWarning(__METHOD_NAME__,"sinkID",sinkID,"does not exist");
1699  return (E_NON_EXISTENT);
1700  }
1701 
1702  am_Sink_Database_s mappedSink = mMappedData.mSinkMap.at(sinkID);
1703  if( true == mappedSink.reserved )
1704  return (E_NON_EXISTENT);
1705  sinkData = mappedSink;
1706 
1707  return (E_OK);
1708 }
1709 
1711 {
1712 
1713  if (!existSource(sourceID))
1714  {
1715  logWarning(__METHOD_NAME__,"sourceID",sourceID,"does not exist");
1716  return (E_NON_EXISTENT);
1717  }
1718 
1719  am_Source_Database_s mappedSource = mMappedData.mSourceMap.at(sourceID);
1720  if( true == mappedSource.reserved )
1721  return (E_NON_EXISTENT);
1722 
1723  sourceData = mappedSource;
1724 
1725  return (E_OK);
1726 }
1727 
1729 {
1730  if (!existMainConnection(mainConnectionID))
1731  {
1732  logError(__METHOD_NAME__,"mainConnectionID must exist");
1733  return (E_NON_EXISTENT);
1734  }
1735  am_MainConnection_s temp = mMappedData.mMainConnectionMap.at(mainConnectionID);
1736  mainConnectionData = temp;
1737 
1738  return (E_OK);
1739 }
1740 
1742 {
1743  if(sinkClass.listClassProperties.empty())
1744  {
1745  logError(__METHOD_NAME__,"listClassProperties must not be empty");
1746  return (E_NOT_POSSIBLE);
1747  }
1748 
1749  //check if the ID already exists
1750  if (!existSinkClass(sinkClass.sinkClassID))
1751  {
1752  logError(__METHOD_NAME__,"sinkClassID must exist");
1753  return (E_NON_EXISTENT);
1754  }
1755 
1756  DB_COND_UPDATE_RIE(mMappedData.mSinkClassesMap[sinkClass.sinkClassID].listClassProperties, sinkClass.listClassProperties);
1757 
1758  logVerbose("DatabaseHandler::setSinkClassInfoDB set setSinkClassInfo");
1759  return (E_OK);
1760 }
1761 
1763 {
1764  if(sourceClass.listClassProperties.empty())
1765  {
1766  logError(__METHOD_NAME__,"listClassProperties must not be empty");
1767  return (E_NOT_POSSIBLE);
1768  }
1769 
1770  //check if the ID already exists
1771  if (!existSourceClass(sourceClass.sourceClassID))
1772  {
1773  logError(__METHOD_NAME__,"sourceClassID must exist");
1774  return (E_NON_EXISTENT);
1775  }
1776 
1777  DB_COND_UPDATE_RIE(mMappedData.mSourceClassesMap[sourceClass.sourceClassID].listClassProperties, sourceClass.listClassProperties);
1778 
1779  logVerbose("DatabaseHandler::setSinkClassInfoDB set setSinkClassInfo");
1780  return (E_OK);
1781 }
1782 
1784 {
1785 
1786  if (!existSink(sinkID))
1787  {
1788  logWarning(__METHOD_NAME__,"sinkID must exist");
1789  return (E_NON_EXISTENT);
1790  }
1791  am_Sink_Database_s sink = mMappedData.mSinkMap.at(sinkID);
1792  sinkClass.sinkClassID = sink.sinkClassID;
1793 
1794  if (!existSinkClass(sinkClass.sinkClassID))
1795  {
1796  logWarning(__METHOD_NAME__,"sinkClassID must exist");
1797  return (E_NON_EXISTENT);
1798  }
1799  am_SinkClass_s tmpSinkClass = mMappedData.mSinkClassesMap.at(sinkClass.sinkClassID);
1800  sinkClass = tmpSinkClass;
1801 
1802  return (E_OK);
1803 }
1804 
1806 {
1807  if (!existGateway(gatewayID))
1808  {
1809  logWarning(__METHOD_NAME__,"gatewayID must exist");
1810  return (E_NON_EXISTENT);
1811  }
1812 
1813  gatewayData = mMappedData.mGatewayMap.at(gatewayID);
1814 
1815  return (E_OK);
1816 
1817 }
1818 
1820 {
1821  if (!existConverter(converterID))
1822  {
1823  logWarning(__METHOD_NAME__,"converterID must exist");
1824  return (E_NON_EXISTENT);
1825  }
1826 
1827  converterData = mMappedData.mConverterMap.at(converterID);
1828 
1829  return (E_OK);
1830 
1831 }
1832 
1834 {
1835  if (!existCrossFader(crossfaderID))
1836  {
1837  logWarning(__METHOD_NAME__,"crossfaderID must exist");
1838  return (E_NON_EXISTENT);
1839  }
1840 
1841  crossfaderData = mMappedData.mCrossfaderMap.at(crossfaderID);
1842 
1843  return (E_OK);
1844 }
1845 
1846 am_Error_e CAmDatabaseHandlerMap::getListSinksOfDomain(const am_domainID_t domainID, std::vector<am_sinkID_t> & listSinkID) const
1847 {
1848  listSinkID.clear();
1849  if (!existDomain(domainID))
1850  {
1851  logWarning(__METHOD_NAME__,"domainID must exist");
1852  return (E_NON_EXISTENT);
1853  }
1854 
1855  std::unordered_map<am_sinkID_t, am_Sink_Database_s>::const_iterator elementIterator = mMappedData.mSinkMap.begin();
1856  for (;elementIterator != mMappedData.mSinkMap.end(); ++elementIterator)
1857  {
1858  if (0==elementIterator->second.reserved && domainID==elementIterator->second.domainID)
1859  listSinkID.push_back(elementIterator->second.sinkID);
1860  }
1861  return (E_OK);
1862 }
1863 
1864 am_Error_e CAmDatabaseHandlerMap::getListSourcesOfDomain(const am_domainID_t domainID, std::vector<am_sourceID_t> & listSourceID) const
1865 {
1866  listSourceID.clear();
1867  if (!existDomain(domainID))
1868  {
1869  logWarning(__METHOD_NAME__,"domainID must exist");
1870  return (E_NON_EXISTENT);
1871  }
1872  AmMapSource::const_iterator elementIterator = mMappedData.mSourceMap.begin();
1873  for (;elementIterator != mMappedData.mSourceMap.end(); ++elementIterator)
1874  {
1875  if (0==elementIterator->second.reserved && domainID==elementIterator->second.domainID)
1876  listSourceID.push_back(elementIterator->second.sourceID);
1877  }
1878 
1879  return (E_OK);
1880 }
1881 
1882 am_Error_e CAmDatabaseHandlerMap::getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector<am_crossfaderID_t> & listCrossfader) const
1883 {
1884  listCrossfader.clear();
1885  if (!existDomain(domainID))
1886  {
1887  logWarning(__METHOD_NAME__,"domainID must exist");
1888  return (E_NON_EXISTENT);
1889  }
1890 
1891  AmMapSource::const_iterator sourceIterator = mMappedData.mSourceMap.begin();
1892  for (;sourceIterator != mMappedData.mSourceMap.end(); ++sourceIterator)
1893  {
1894  if (domainID==sourceIterator->second.domainID)
1895  {
1896  AmMapCrossfader::const_iterator elementIterator = mMappedData.mCrossfaderMap.begin();
1897  for (;elementIterator != mMappedData.mCrossfaderMap.end(); ++elementIterator)
1898  {
1899  if ( sourceIterator->second.sourceID==elementIterator->second.sourceID )
1900  listCrossfader.push_back(elementIterator->second.crossfaderID);
1901  }
1902  }
1903  }
1904 
1905  return (E_OK);
1906 
1907 }
1908 
1909 am_Error_e CAmDatabaseHandlerMap::getListGatewaysOfDomain(const am_domainID_t domainID, std::vector<am_gatewayID_t> & listGatewaysID) const
1910 {
1911  listGatewaysID.clear();
1912  if (!existDomain(domainID))
1913  {
1914  logWarning(__METHOD_NAME__,"domainID must exist");
1915  return (E_NON_EXISTENT);
1916  }
1917 
1918  AmMapGateway::const_iterator elementIterator = mMappedData.mGatewayMap.begin();
1919  for (;elementIterator != mMappedData.mGatewayMap.end(); ++elementIterator)
1920  {
1921  if (domainID==elementIterator->second.controlDomainID)
1922  listGatewaysID.push_back(elementIterator->second.gatewayID);
1923  }
1924  return (E_OK);
1925 }
1926 
1927 am_Error_e CAmDatabaseHandlerMap::getListConvertersOfDomain(const am_domainID_t domainID, std::vector<am_converterID_t>& listConvertersID) const
1928 {
1929  listConvertersID.clear();
1930  if (!existDomain(domainID))
1931  {
1932  logWarning(__METHOD_NAME__,"domainID must exist");
1933  return (E_NON_EXISTENT);
1934  }
1935 
1936  AmMapConverter::const_iterator elementIterator = mMappedData.mConverterMap.begin();
1937  for (;elementIterator != mMappedData.mConverterMap.end(); ++elementIterator)
1938  {
1939  if (domainID==elementIterator->second.domainID)
1940  listConvertersID.push_back(elementIterator->second.converterID);
1941  }
1942  return (E_OK);
1943 }
1944 
1945 am_Error_e CAmDatabaseHandlerMap::getListMainConnections(std::vector<am_MainConnection_s> & listMainConnections) const
1946 {
1947  listMainConnections.clear();
1948 
1949  AmMapMainConnection::const_iterator elementIterator = mMappedData.mMainConnectionMap.begin();
1950  for (;elementIterator != mMappedData.mMainConnectionMap.end(); ++elementIterator)
1951  {
1952  listMainConnections.push_back(elementIterator->second);
1953  }
1954 
1955  return (E_OK);
1956 }
1957 
1958 am_Error_e CAmDatabaseHandlerMap::getListDomains(std::vector<am_Domain_s> & listDomains) const
1959 {
1960  listDomains.clear();
1961 
1962  AmMapDomain::const_iterator elementIterator = mMappedData.mDomainMap.begin();
1963  for (;elementIterator != mMappedData.mDomainMap.end(); ++elementIterator)
1964  {
1965  if( 0==elementIterator->second.reserved )
1966  listDomains.push_back(elementIterator->second);
1967  }
1968 
1969  return (E_OK);
1970 }
1971 
1972 am_Error_e CAmDatabaseHandlerMap::getListConnections(std::vector<am_Connection_s> & listConnections) const
1973 {
1974  listConnections.clear();
1975 
1976  AmMapConnection::const_iterator elementIterator = mMappedData.mConnectionMap.begin();
1977  for (;elementIterator != mMappedData.mConnectionMap.end(); ++elementIterator)
1978  {
1979  if( 0==elementIterator->second.reserved )
1980  listConnections.push_back(elementIterator->second);
1981  }
1982 
1983  return (E_OK);
1984 }
1985 
1986 am_Error_e CAmDatabaseHandlerMap::getListConnectionsReserved(std::vector<am_Connection_s> & listConnections) const
1987 {
1988  listConnections.clear();
1989 
1990  AmMapConnection::const_iterator elementIterator = mMappedData.mConnectionMap.begin();
1991  for (;elementIterator != mMappedData.mConnectionMap.end(); ++elementIterator)
1992  {
1993  if( elementIterator->second.reserved )
1994  listConnections.push_back(elementIterator->second);
1995  }
1996 
1997  return (E_OK);
1998 }
1999 
2000 am_Error_e CAmDatabaseHandlerMap::getListSinks(std::vector<am_Sink_s> & listSinks) const
2001 {
2002  listSinks.clear();
2003 
2004  std::for_each(mMappedData.mSinkMap.begin(), mMappedData.mSinkMap.end(), [&](const std::pair<am_sinkID_t, am_Sink_Database_s>& ref) {
2005  if( 0==ref.second.reserved )
2006  listSinks.push_back(ref.second);
2007  });
2008 
2009  return (E_OK);
2010 }
2011 
2012 am_Error_e CAmDatabaseHandlerMap::getListSources(std::vector<am_Source_s> & listSources) const
2013 {
2014  listSources.clear();
2015 
2016  std::for_each(mMappedData.mSourceMap.begin(), mMappedData.mSourceMap.end(), [&](const std::pair<am_sourceID_t, am_Source_Database_s>& ref) {
2017  if( 0==ref.second.reserved )
2018  {
2019  listSources.push_back(ref.second);
2020  }
2021  });
2022  return (E_OK);
2023 }
2024 
2025 am_Error_e CAmDatabaseHandlerMap::getListSourceClasses(std::vector<am_SourceClass_s> & listSourceClasses) const
2026 {
2027  listSourceClasses.clear();
2028 
2029  std::for_each(mMappedData.mSourceClassesMap.begin(), mMappedData.mSourceClassesMap.end(), [&](const std::pair<am_sourceClass_t, am_SourceClass_s>& ref) {
2030  listSourceClasses.push_back(ref.second);
2031  });
2032 
2033  return (E_OK);
2034 }
2035 
2036 am_Error_e CAmDatabaseHandlerMap::getListCrossfaders(std::vector<am_Crossfader_s> & listCrossfaders) const
2037 {
2038  listCrossfaders.clear();
2039 
2040  std::for_each(mMappedData.mCrossfaderMap.begin(), mMappedData.mCrossfaderMap.end(), [&](const std::pair<am_crossfaderID_t, am_Crossfader_s>& ref) {
2041  listCrossfaders.push_back(ref.second);
2042  });
2043 
2044  return (E_OK);
2045 }
2046 
2047 am_Error_e CAmDatabaseHandlerMap::getListGateways(std::vector<am_Gateway_s> & listGateways) const
2048 {
2049  listGateways.clear();
2050 
2051  std::for_each(mMappedData.mGatewayMap.begin(), mMappedData.mGatewayMap.end(), [&](const std::pair<am_gatewayID_t, am_Gateway_s>& ref) {
2052  listGateways.push_back(ref.second);
2053  });
2054 
2055  return (E_OK);
2056 }
2057 
2058 am_Error_e CAmDatabaseHandlerMap::getListConverters(std::vector<am_Converter_s> & listConverters) const
2059 {
2060  listConverters.clear();
2061 
2062  std::for_each(mMappedData.mConverterMap.begin(), mMappedData.mConverterMap.end(), [&](const std::pair<am_converterID_t, am_Converter_s>& ref) {
2063  listConverters.push_back(ref.second);
2064  });
2065 
2066  return (E_OK);
2067 }
2068 
2069 am_Error_e CAmDatabaseHandlerMap::getListSinkClasses(std::vector<am_SinkClass_s> & listSinkClasses) const
2070 {
2071  listSinkClasses.clear();
2072 
2073  std::for_each(mMappedData.mSinkClassesMap.begin(), mMappedData.mSinkClassesMap.end(), [&](const std::pair<am_gatewayID_t, am_SinkClass_s>& ref) {
2074  listSinkClasses.push_back(ref.second);
2075  });
2076 
2077  return (E_OK);
2078 }
2079 
2080 am_Error_e CAmDatabaseHandlerMap::getListVisibleMainConnections(std::vector<am_MainConnectionType_s> & listConnections) const
2081 {
2082  listConnections.clear();
2083  std::for_each(mMappedData.mMainConnectionMap.begin(), mMappedData.mMainConnectionMap.end(), [&](const std::pair<am_mainConnectionID_t, am_MainConnection_Database_s>& ref) {
2084  listConnections.emplace_back();
2085  ref.second.getMainConnectionType(listConnections.back());
2086  });
2087 
2088  return (E_OK);
2089 }
2090 
2091 am_Error_e CAmDatabaseHandlerMap::getListMainSinks(std::vector<am_SinkType_s> & listMainSinks) const
2092 {
2093  listMainSinks.clear();
2094  std::for_each(mMappedData.mSinkMap.begin(), mMappedData.mSinkMap.end(), [&](const std::pair<am_sinkID_t, am_Sink_Database_s>& ref) {
2095  if( 0==ref.second.reserved && 1==ref.second.visible )
2096  {
2097  listMainSinks.emplace_back();
2098  ref.second.getSinkType(listMainSinks.back());
2099  }
2100  });
2101 
2102  return (E_OK);
2103 }
2104 
2105 am_Error_e CAmDatabaseHandlerMap::getListMainSources(std::vector<am_SourceType_s> & listMainSources) const
2106 {
2107  listMainSources.clear();
2108  std::for_each(mMappedData.mSourceMap.begin(), mMappedData.mSourceMap.end(), [&](const std::pair<am_sourceID_t, am_Source_Database_s>& ref) {
2109  if( 0==ref.second.reserved && 1==ref.second.visible )
2110  {
2111  listMainSources.emplace_back();
2112  ref.second.getSourceType(listMainSources.back());
2113  }
2114  });
2115 
2116  return (E_OK);
2117 }
2118 
2119 am_Error_e CAmDatabaseHandlerMap::getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_MainSoundProperty_s> & listSoundProperties) const
2120 {
2121  if (!existSink(sinkID))
2122  {
2123  logWarning(__METHOD_NAME__,"sinkID must exist");
2124  return E_NON_EXISTENT;
2125  }
2126 
2127  const am_Sink_s & sink = mMappedData.mSinkMap.at(sinkID);
2128  listSoundProperties = sink.listMainSoundProperties;
2129 
2130  return (E_OK);
2131 }
2132 
2133 am_Error_e CAmDatabaseHandlerMap::getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_MainSoundProperty_s> & listSourceProperties) const
2134 {
2135  if (!existSource(sourceID))
2136  {
2137  logWarning(__METHOD_NAME__,"sourceID must exist");
2138  return E_NON_EXISTENT;
2139  }
2140  const am_Source_s & source = mMappedData.mSourceMap.at(sourceID);
2141  listSourceProperties = source.listMainSoundProperties;
2142 
2143  return (E_OK);
2144 }
2145 
2146 am_Error_e CAmDatabaseHandlerMap::getListSinkSoundProperties(const am_sinkID_t sinkID, std::vector<am_SoundProperty_s>& listSoundproperties) const
2147 {
2148  if (!existSink(sinkID))
2149  {
2150  logWarning(__METHOD_NAME__,"sinkID must exist");
2151  return E_NON_EXISTENT;
2152  }
2153 
2154  const am_Sink_Database_s & sink = mMappedData.mSinkMap.at(sinkID);
2155  listSoundproperties = sink.listSoundProperties;
2156 
2157  return (E_OK);
2158 }
2159 
2160 am_Error_e CAmDatabaseHandlerMap::getListSourceSoundProperties(const am_sourceID_t sourceID, std::vector<am_SoundProperty_s>& listSoundproperties) const
2161 {
2162  if (!existSource(sourceID))
2163  {
2164  logWarning(__METHOD_NAME__,"sourceID must exist");
2165  return E_NON_EXISTENT;
2166  }
2167 
2168  const am_Source_Database_s & source = mMappedData.mSourceMap.at(sourceID);
2169  listSoundproperties = source.listSoundProperties;
2170 
2171  return (E_OK);
2172 }
2173 
2174 am_Error_e CAmDatabaseHandlerMap::getListSystemProperties(std::vector<am_SystemProperty_s> & listSystemProperties) const
2175 {
2176  listSystemProperties = mMappedData.mSystemProperties;
2177  return (E_OK);
2178 }
2179 
2180 am_Error_e am::CAmDatabaseHandlerMap::getListSinkConnectionFormats(const am_sinkID_t sinkID, std::vector<am_CustomConnectionFormat_t> & listConnectionFormats) const
2181 {
2182  if (!existSink(sinkID))
2183  {
2184  logWarning(__METHOD_NAME__,"sinkID must exist");
2185  return E_NON_EXISTENT;
2186  }
2187  const am_Sink_s & sink = mMappedData.mSinkMap.at(sinkID);
2188  listConnectionFormats = sink.listConnectionFormats;
2189 
2190  return (E_OK);
2191 }
2192 
2193 am_Error_e am::CAmDatabaseHandlerMap::getListSourceConnectionFormats(const am_sourceID_t sourceID, std::vector<am_CustomConnectionFormat_t> & listConnectionFormats) const
2194 {
2195  if (!existSource(sourceID))
2196  {
2197  logWarning(__METHOD_NAME__,"sourceID must exist");
2198  return E_NON_EXISTENT;
2199  }
2200  const am_Source_s & source = mMappedData.mSourceMap.at(sourceID);
2201  listConnectionFormats = source.listConnectionFormats;
2202 
2203  return (E_OK);
2204 }
2205 
2206 am_Error_e am::CAmDatabaseHandlerMap::getListGatewayConnectionFormats(const am_gatewayID_t gatewayID, std::vector<bool> & listConnectionFormat) const
2207 {
2208  if (!existGateway(gatewayID))
2209  {
2210  logWarning(__METHOD_NAME__,"gatewayID must exist");
2211  return E_NON_EXISTENT;
2212  }
2213  ListConnectionFormat::const_iterator iter = mListConnectionFormat.begin();
2214  iter = mListConnectionFormat.find(gatewayID);
2215  if (iter == mListConnectionFormat.end())
2216  {
2217  logWarning("DatabaseHandler::getListGatewayConnectionFormats database error with convertionFormat");
2218 
2219  return E_NON_EXISTENT;
2220  }
2221  listConnectionFormat = iter->second;
2222 
2223  return (E_OK);
2224 }
2225 
2227 {
2228  if (!existMainConnection(mainConnectionID))
2229  {
2230  logWarning(__METHOD_NAME__,"mainConnectionID must exist");
2231  return E_NON_EXISTENT;
2232  }
2233  delay = -1;
2234 
2235  const am_MainConnection_s & mainConnection = mMappedData.mMainConnectionMap.at(mainConnectionID);
2236  delay = mainConnection.delay;
2237 
2238  if (delay == -1)
2239  return (E_NOT_POSSIBLE);
2240 
2241  return (E_OK);
2242 }
2243 
2245 {
2246  if (!existMainConnection(connectionID))
2247  {
2248  logError(__METHOD_NAME__,"connectionID must exist");
2249  return E_NON_EXISTENT;
2250  }
2251  DB_COND_UPDATE_RIE(mMappedData.mMainConnectionMap[connectionID].delay, delay);
2252  NOTIFY_OBSERVERS2(dboTimingInformationChanged, connectionID, delay)
2253  return (E_OK);
2254 }
2255 
2262 {
2263  return existsObjectWithKeyInMap(mainConnectionID, mMappedData.mMainConnectionMap);
2264 }
2265 
2272 {
2273  am_Source_Database_s const * source = objectForKeyIfExistsInMap(sourceID, mMappedData.mSourceMap);
2274  if( NULL!=source )
2275  return (0==source->reserved);
2276 
2277  return false;
2278 }
2279 
2286 bool CAmDatabaseHandlerMap::existSourceNameOrID(const am_sourceID_t sourceID, const std::string & name) const
2287 {
2288  return sourceWithNameOrID(sourceID, name);
2289 }
2290 
2296 bool CAmDatabaseHandlerMap::existSourceName(const std::string & name) const
2297 {
2298  return existSourceNameOrID(mMappedData.mCurrentSourceID.mMax, name);
2299 }
2300 
2307 {
2308  bool returnVal = false;
2309  AmMapSink::const_iterator elementIterator = mMappedData.mSinkMap.begin();
2310  for (;elementIterator != mMappedData.mSinkMap.end(); ++elementIterator)
2311  {
2312  if( 0==elementIterator->second.reserved &&
2313  sinkID==elementIterator->second.sinkID)
2314  {
2315  returnVal = true;
2316  break;
2317  }
2318  }
2319  return (returnVal);
2320 }
2321 
2328 const CAmDatabaseHandlerMap::am_Source_Database_s * CAmDatabaseHandlerMap::sourceWithNameOrID(const am_sourceID_t sourceID, const std::string & name) const
2329 {
2330  std::function<bool(const CAmDatabaseHandlerMap::am_Source_Database_s & refObject)> comparator = [&](const CAmDatabaseHandlerMap::am_Source_Database_s & source)->bool{
2331  return ( 0==source.reserved &&
2332  (sourceID==source.sourceID || name.compare(source.name)==0));
2333  };
2334  return objectMatchingPredicate(mMappedData.mSourceMap, comparator);
2335 }
2336 
2343 const CAmDatabaseHandlerMap::am_Sink_Database_s * CAmDatabaseHandlerMap::sinkWithNameOrID(const am_sinkID_t sinkID, const std::string & name) const
2344 {
2345  std::function<bool(const CAmDatabaseHandlerMap::am_Sink_Database_s & refObject)> comparator = [&](const CAmDatabaseHandlerMap::am_Sink_Database_s & sink)->bool{
2346  return ( 0==sink.reserved &&
2347  (sinkID==sink.sinkID || name.compare(sink.name)==0));
2348  };
2349  return objectMatchingPredicate(mMappedData.mSinkMap, comparator);
2350 }
2351 
2358 bool CAmDatabaseHandlerMap::existSinkNameOrID(const am_sinkID_t sinkID, const std::string & name) const
2359 {
2360  return sinkWithNameOrID( sinkID, name)!=NULL;
2361 }
2362 
2368 bool CAmDatabaseHandlerMap::existSinkName(const std::string & name) const
2369 {
2370  return existSinkNameOrID(mMappedData.mCurrentSinkID.mMax, name);
2371 }
2372 
2379 {
2380  am_Domain_Database_s const * source = objectForKeyIfExistsInMap(domainID, mMappedData.mDomainMap);
2381  if( NULL!=source )
2382  return (0==source->reserved);
2383 
2384  return false;
2385 }
2386 
2393 {
2394  return existsObjectWithKeyInMap(gatewayID, mMappedData.mGatewayMap);
2395 }
2396 
2398 {
2399  return existsObjectWithKeyInMap(converterID, mMappedData.mConverterMap);
2400 }
2401 
2403 {
2404  domainID=0;
2405 
2406  am_Source_Database_s const * source = objectForKeyIfExistsInMap(sourceID, mMappedData.mSourceMap);
2407  if( NULL!=source )
2408  {
2409  domainID = source->domainID;
2410  return E_OK;
2411  }
2412  return E_NON_EXISTENT;
2413 }
2414 
2416 {
2417  domainID=0;
2418 
2419  am_Sink_Database_s const * source = objectForKeyIfExistsInMap(sinkID, mMappedData.mSinkMap);
2420  if( NULL!=source )
2421  {
2422  domainID = source->domainID;
2423  return E_OK;
2424  }
2425  return E_NON_EXISTENT;
2426 }
2427 
2429 {
2430  domainID=0;
2431 
2432  am_Crossfader_Database_s const * cross = objectForKeyIfExistsInMap(crossfader, mMappedData.mCrossfaderMap);
2433  if( NULL!=cross )
2434  {
2435  getDomainOfSource(cross->sinkID_A,domainID);
2436  return E_OK;
2437  }
2438  return E_NON_EXISTENT;
2439 }
2440 
2447 {
2448  return existsObjectWithKeyInMap(sinkClassID, mMappedData.mSinkClassesMap);
2449 }
2450 
2457 {
2458  return existsObjectWithKeyInMap(sourceClassID, mMappedData.mSourceClassesMap);
2459 }
2460 
2462 {
2463  if(!existConnectionID(connectionID))
2464  {
2465  logError(__METHOD_NAME__,"connectionID must exist");
2466  return (E_NON_EXISTENT);
2467  }
2468 
2469  mMappedData.mConnectionMap[connectionID].delay = delay;
2470 
2471  //now we need to find all mainConnections that use the changed connection and update their timing
2472 
2473  //first get all route tables for all mainconnections
2474  am_Error_e error = E_OK;
2475  AmMapMainConnection::const_iterator iter = mMappedData.mMainConnectionMap.begin();
2476  for(; iter != mMappedData.mMainConnectionMap.end(); ++iter)
2477  {
2478  const am_MainConnection_s & mainConnection = iter->second;
2479  if (std::find(mainConnection.listConnectionID.begin(), mainConnection.listConnectionID.end(), connectionID) != mainConnection.listConnectionID.end())
2480  {
2481  // Got it.
2482  error = changeDelayMainConnection(calculateMainConnectionDelay(mainConnection.mainConnectionID), mainConnection.mainConnectionID);
2483  }
2484  }
2485 
2486  return error;
2487 }
2488 
2490 {
2491  am_Connection_Database_s const * connection = objectForKeyIfExistsInMap(connectionID, mMappedData.mConnectionMap);
2492  if( NULL!=connection )
2493  {
2494  mMappedData.mConnectionMap.at(connectionID).reserved = false;
2495  return E_OK;
2496  }
2497  logError(__METHOD_NAME__,"connectionID must exist");
2498  return (E_NON_EXISTENT);
2499 }
2500 
2501 am_timeSync_t CAmDatabaseHandlerMap::calculateMainConnectionDelay(const am_mainConnectionID_t mainConnectionID) const
2502 {
2503  if (!existMainConnection(mainConnectionID))
2504  return -1;
2505  const am_MainConnection_s & mainConnection = mMappedData.mMainConnectionMap.at(mainConnectionID);
2506  am_timeSync_t delay = 0;
2507  std::vector<am_connectionID_t>::const_iterator iter = mainConnection.listConnectionID.begin();
2508  for(;iter<mainConnection.listConnectionID.end(); ++iter)
2509  {
2510  am_Connection_Database_s const * source = objectForKeyIfExistsInMap(*iter, mMappedData.mConnectionMap);
2511  if( NULL!=source )
2512  {
2513  delay += std::max(source->delay, static_cast<am_timeSync_t>(0));
2514  }
2515  }
2516  return (delay == 0 ? -1 : std::min(delay, static_cast<am_timeSync_t>(SHRT_MAX)));
2517 }
2518 
2530 {
2531  if (!existSource(sourceID))
2532  {
2533  logError(__METHOD_NAME__,"sourceID must exist");
2534  return false;
2535  }
2536  am_Source_Database_s source = mMappedData.mSourceMap.at(sourceID);
2537  return source.visible;
2538 }
2539 
2546 {
2547  am_Sink_Database_s const * source = objectForKeyIfExistsInMap(sinkID, mMappedData.mSinkMap);
2548  if( NULL!=source )
2549  {
2550  if(0==source->reserved)
2551  return source->visible;
2552  }
2553  return false;
2554 }
2555 
2563 {
2564  am_Connection_Database_s const * connectionObject = objectMatchingPredicate<am_Connection_Database_s, am_connectionID_t>(mMappedData.mConnectionMap, [&](const am_Connection_Database_s & obj){
2565  return false==obj.reserved &&
2566  connection.sinkID == obj.sinkID &&
2567  connection.sourceID == obj.sourceID &&
2568  connection.connectionFormat == obj.connectionFormat;
2569  });
2570  return ( NULL!=connectionObject );
2571 }
2572 
2579 {
2580  am_Connection_Database_s const * connection = objectForKeyIfExistsInMap(connectionID, mMappedData.mConnectionMap);
2581  if( NULL!=connection )
2582  {
2583  return (true);
2584  }
2585  return false;
2586 }
2587 
2594 {
2595  return existsObjectWithKeyInMap(crossfaderID, mMappedData.mCrossfaderMap);
2596 }
2597 
2599 {
2600  am_Source_Database_s const * source = objectForKeyIfExistsInMap(sourceID, mMappedData.mSourceMap);
2601  if( NULL!=source )
2602  {
2603  sourceState = source->sourceState;
2604  return (E_OK);
2605  }
2606  else
2607  {
2608  sourceState = SS_UNKNNOWN;
2609  return (E_NON_EXISTENT);
2610  }
2611 }
2612 
2614 {
2615  if(!(sourceState>=SS_UNKNNOWN && sourceState<=SS_MAX))
2616  {
2617  logError(__METHOD_NAME__,"sourceState must be valid");
2618  return (E_NOT_POSSIBLE);
2619  }
2620 
2621  if(existSource(sourceID))
2622  {
2623  mMappedData.mSourceMap.at(sourceID).sourceState = sourceState;
2624  return (E_OK);
2625  }
2626  logError(__METHOD_NAME__,"sourceID must exist");
2627  return (E_NON_EXISTENT);
2628 }
2629 
2631 {
2632  assert(sourceID!=0);
2633  assert(interruptState>=IS_UNKNOWN && interruptState<=IS_MAX);
2634  if(existSource(sourceID))
2635  {
2636  mMappedData.mSourceMap.at(sourceID).interruptState = interruptState;
2637  return (E_OK);
2638  }
2639  return (E_NON_EXISTENT);
2640 }
2641 
2642 
2644 
2645 
2646  am_Sink_Database_s const * source = objectForKeyIfExistsInMap(sinkID, mMappedData.mSinkMap);
2647  if( NULL!=source )
2648  {
2649  mainVolume = source->mainVolume;
2650  return (E_OK);
2651  }
2652  mainVolume = -1;
2653  logWarning(__METHOD_NAME__,"sinkID must be valid");
2654  return (E_NON_EXISTENT);
2655 }
2656 
2658 {
2659 
2660  am_Sink_Database_s const * source = objectForKeyIfExistsInMap(sinkID, mMappedData.mSinkMap);
2661  if( NULL!=source )
2662  {
2663  volume = source->volume;
2664  return (E_OK);
2665  }
2666  volume = -1;
2667  logWarning(__METHOD_NAME__,"sinkID must be valid");
2668  return (E_NON_EXISTENT);
2669 }
2670 
2672 {
2673  am_Source_Database_s const * source = objectForKeyIfExistsInMap(sourceID, mMappedData.mSourceMap);
2674  if( NULL!=source )
2675  {
2676  volume = source->volume;
2677  return (E_OK);
2678  }
2679  volume = -1;
2680  logWarning(__METHOD_NAME__,"sourceID must be valid");
2681  return (E_NON_EXISTENT);
2682 }
2683 
2685 {
2686 
2687  am_Sink_Database_s * pObject = (am_Sink_Database_s *)objectForKeyIfExistsInMap(sinkID, mMappedData.mSinkMap);
2688  if( NULL!=pObject )
2689  {
2690  if(pObject->listSoundProperties.size()>0 && 0==pObject->cacheSoundProperties.size())
2691  {
2692  std::vector<am_SoundProperty_s>::const_iterator iter = pObject->listSoundProperties.begin();
2693  for(; iter<pObject->listSoundProperties.end(); ++iter)
2694  pObject->cacheSoundProperties[iter->type] = iter->value;
2695  }
2696  auto it = pObject->cacheSoundProperties.find(propertyType);
2697  if(it!=pObject->cacheSoundProperties.end())
2698  {
2699  value = it->second;
2700  return (E_OK);
2701  }
2702  }
2703  value = -1;
2704  logWarning(__METHOD_NAME__,"sinkID must be valid");
2705  return (E_NON_EXISTENT);
2706 }
2707 
2709 {
2710  am_Source_Database_s * pObject = (am_Source_Database_s *)objectForKeyIfExistsInMap(sourceID, mMappedData.mSourceMap);
2711  if( NULL!=pObject )
2712  {
2713  if(pObject->listSoundProperties.size()>0 && 0==pObject->cacheSoundProperties.size())
2714  {
2715  std::vector<am_SoundProperty_s>::const_iterator iter = pObject->listSoundProperties.begin();
2716  for(; iter<pObject->listSoundProperties.end(); ++iter)
2717  pObject->cacheSoundProperties[iter->type] = iter->value;
2718  }
2719  auto it = pObject->cacheSoundProperties.find(propertyType);
2720  if(it!=pObject->cacheSoundProperties.end())
2721  {
2722  value = it->second;
2723  return (E_OK);
2724  }
2725  }
2726  value = -1;
2727  logWarning(__METHOD_NAME__,"sourceID must be valid");
2728  return (E_NON_EXISTENT);
2729 }
2730 
2732 {
2733  am_Sink_Database_s * pObject = (am_Sink_Database_s *)objectForKeyIfExistsInMap(sinkID, mMappedData.mSinkMap);
2734  if( NULL!=pObject )
2735  {
2736  if(pObject->listMainSoundProperties.size()>0 && 0==pObject->cacheMainSoundProperties.size())
2737  {
2738  std::vector<am_MainSoundProperty_s>::const_iterator iter = pObject->listMainSoundProperties.begin();
2739  for(; iter<pObject->listMainSoundProperties.end(); ++iter)
2740  pObject->cacheMainSoundProperties[iter->type] = iter->value;
2741  }
2742  auto it = pObject->cacheMainSoundProperties.find(propertyType);
2743  if(it!=pObject->cacheMainSoundProperties.end())
2744  {
2745  value = it->second;
2746  return (E_OK);
2747  }
2748  }
2749  value = -1;
2750  logWarning(__METHOD_NAME__,"sinkID must be valid");
2751  return (E_NON_EXISTENT);
2752 }
2753 
2755 {
2756 
2757  am_Source_Database_s * pObject = (am_Source_Database_s *)objectForKeyIfExistsInMap(sourceID, mMappedData.mSourceMap);
2758  if( NULL!=pObject )
2759  {
2760  if(pObject->listMainSoundProperties.size()>0 && 0==pObject->cacheMainSoundProperties.size())
2761  {
2762  std::vector<am_MainSoundProperty_s>::const_iterator iter = pObject->listMainSoundProperties.begin();
2763  for(; iter<pObject->listMainSoundProperties.end(); ++iter)
2764  pObject->cacheMainSoundProperties[iter->type] = iter->value;
2765  }
2766  auto it = pObject->cacheMainSoundProperties.find(propertyType);
2767  if(it!=pObject->cacheMainSoundProperties.end())
2768  {
2769  value = it->second;
2770  return (E_OK);
2771  }
2772  }
2773 
2774  value = -1;
2775  logWarning(__METHOD_NAME__,"sourceID must be valid");
2776  return (E_NON_EXISTENT);
2777 }
2778 
2780 {
2781 
2782  am_Domain_Database_s const * source = objectForKeyIfExistsInMap(domainID, mMappedData.mDomainMap);
2783  if( NULL!=source )
2784  {
2785  state = source->state;
2786  return (E_OK);
2787  }
2788  state = DS_UNKNOWN;
2789  logWarning(__METHOD_NAME__,"domainID must be valid");
2790  return (E_NON_EXISTENT);
2791 }
2792 
2793 am_Error_e CAmDatabaseHandlerMap::peekDomain(const std::string & name, am_domainID_t & domainID)
2794 {
2795  domainID=0;
2796 
2797  am_Domain_Database_s const *reservedDomain = objectMatchingPredicate<am_Domain_Database_s, am_domainID_t>(mMappedData.mDomainMap, [&](const am_Domain_Database_s & obj){
2798  return name.compare(obj.name)==0;
2799  });
2800 
2801  if( NULL != reservedDomain )
2802  {
2803  domainID = reservedDomain->domainID;
2804  return E_OK;
2805  }
2806  else
2807  {
2808  int16_t nextID = 0;
2809  if( mMappedData.increaseID( nextID, mMappedData.mCurrentDomainID) )
2810  {
2811  domainID = nextID;
2812  am_Domain_Database_s domain;
2813  domain.domainID = nextID;
2814  domain.name = name;
2815  domain.reserved = 1;
2816  mMappedData.mDomainMap[nextID] = domain;
2817  return E_OK;
2818  }
2819  return E_UNKNOWN;
2820  }
2821  return (E_OK);
2822 }
2823 
2824 am_Error_e CAmDatabaseHandlerMap::peekSink(const std::string & name, am_sinkID_t & sinkID)
2825 {
2826  am_Sink_Database_s const *reservedSink = objectMatchingPredicate<am_Sink_Database_s, am_sinkID_t>(mMappedData.mSinkMap, [&](const am_Sink_Database_s & obj){
2827  return name.compare(obj.name)==0;
2828  });
2829  if( NULL!=reservedSink )
2830  {
2831  sinkID = reservedSink->sinkID;
2832  return E_OK;
2833  }
2834  else
2835  {
2836  int16_t nextID = 0;
2837  if(mMappedData.increaseID(nextID, mMappedData.mCurrentSinkID))
2838  {
2839  if(mFirstStaticSink)
2840  {
2841  nextID = DYNAMIC_ID_BOUNDARY;
2842  mFirstStaticSink = false;
2843  }
2844  sinkID = nextID;
2845  am_Sink_Database_s object;
2846  object.sinkID = nextID;
2847  object.name = name;
2848  object.reserved = 1;
2849  mMappedData.mSinkMap[nextID] = object;
2850  return E_OK;
2851  }
2852  return E_UNKNOWN;
2853  }
2854 }
2855 
2856 am_Error_e CAmDatabaseHandlerMap::peekSource(const std::string & name, am_sourceID_t & sourceID)
2857 {
2858  am_Source_Database_s const *reservedSrc = objectMatchingPredicate<am_Source_Database_s, am_sourceID_t>(mMappedData.mSourceMap, [&](const am_Source_Database_s & obj){
2859  return name.compare(obj.name)==0;
2860  });
2861  if( NULL!=reservedSrc )
2862  {
2863  sourceID = reservedSrc->sourceID;
2864  return E_OK;
2865  }
2866  else
2867  {
2868  int16_t nextID = 0;
2869  if(mMappedData.increaseID(nextID, mMappedData.mCurrentSourceID))
2870  {
2871  if(mFirstStaticSource)
2872  {
2873 // nextID = DYNAMIC_ID_BOUNDARY;
2874  mFirstStaticSource = false;
2875  }
2876  sourceID = nextID;
2877  am_Source_Database_s object;
2878  object.sourceID = nextID;
2879  object.name = name;
2880  object.reserved = 1;
2881  mMappedData.mSourceMap[nextID] = object;
2882  return E_OK;
2883  }
2884  else
2885  return E_UNKNOWN;
2886  }
2887 }
2888 
2890 {
2891  if (!existSink(sinkID))
2892  {
2893  logError(__METHOD_NAME__,"sinkID must be valid");
2894  return (E_NON_EXISTENT);
2895  }
2896 
2897  mMappedData.mSinkMap[sinkID].volume = volume;
2898  return (E_OK);
2899 }
2900 
2902 {
2903  if (!existSource(sourceID))
2904  {
2905  logError(__METHOD_NAME__,"sourceID must be valid");
2906  return (E_NON_EXISTENT);
2907  }
2908  mMappedData.mSourceMap[sourceID].volume = volume;
2909 
2910  return (E_OK);
2911 }
2912 
2914 {
2915  if (!existSource(sourceID))
2916  {
2917  logError(__METHOD_NAME__,"sourceID must be valid");
2918  return (E_NON_EXISTENT);
2919  }
2920 
2921  am_Source_Database_s & source = mMappedData.mSourceMap[sourceID];
2922  std::vector<am_SoundProperty_s>::iterator iter = source.listSoundProperties.begin();
2923  for(; iter<source.listSoundProperties.end(); ++iter)
2924  {
2925  if( soundProperty.type == iter->type )
2926  {
2927  iter->value = soundProperty.value;
2928  if(source.cacheSoundProperties.size())
2929  source.cacheSoundProperties[soundProperty.type] = soundProperty.value;
2930  return (E_OK);
2931  }
2932  }
2933  logError(__METHOD_NAME__,"soundproperty type must be valid source:",sourceID,"type",soundProperty.type);
2934  return (E_NON_EXISTENT);
2935 }
2936 
2938 {
2939 
2940  if (!existSink(sinkID))
2941  {
2942  logError(__METHOD_NAME__,"sinkID must be valid");
2943  return (E_NON_EXISTENT);
2944  }
2945  am_Sink_Database_s & sink = mMappedData.mSinkMap[sinkID];
2946  std::vector<am_SoundProperty_s>::iterator iter = sink.listSoundProperties.begin();
2947  for(; iter<sink.listSoundProperties.end(); ++iter)
2948  {
2949  if( soundProperty.type == iter->type )
2950  {
2951  iter->value = soundProperty.value;
2952  if(sink.cacheSoundProperties.size())
2953  sink.cacheSoundProperties[soundProperty.type] = soundProperty.value;
2954  return (E_OK);
2955  }
2956  }
2957  logError(__METHOD_NAME__,"soundproperty type must be valid sinkID:",sinkID,"type",soundProperty.type);
2958  return (E_NON_EXISTENT);
2959 }
2960 
2962 {
2963 
2964  if (!existCrossFader(crossfaderID))
2965  {
2966  logError(__METHOD_NAME__,"crossfaderID must be valid");
2967  return (E_NON_EXISTENT);
2968  }
2969 
2970  mMappedData.mCrossfaderMap[crossfaderID].hotSink = hotsink;
2971  return (E_OK);
2972 }
2973 
2975 {
2976  bool ret = isConnected(gateway);
2977  return ret;
2978 }
2979 
2981 {
2982  bool ret = isConnected(converter);
2983  return ret;
2984 }
2985 
2987 {
2988  if (name.empty())
2989  return (E_NON_EXISTENT);
2990  am_SinkClass_Database_s const *reserved = objectMatchingPredicate<am_SinkClass_Database_s, am_sinkClass_t>(mMappedData.mSinkClassesMap, [&](const am_SinkClass_Database_s & obj){
2991  return name.compare(obj.name)==0;
2992  });
2993  if( NULL!=reserved )
2994  {
2995  sinkClassID = reserved->sinkClassID;
2996  return E_OK;
2997  }
2998  return (E_NON_EXISTENT);
2999 }
3000 
3002 {
3003  if (name.empty())
3004  return (E_NON_EXISTENT);
3005  am_SourceClass_Database_s const *ptrSource = objectMatchingPredicate<am_SourceClass_Database_s, am_sourceClass_t>(mMappedData.mSourceClassesMap, [&](const am_SourceClass_Database_s & obj){
3006  return name.compare(obj.name)==0;
3007  });
3008  if( NULL!=ptrSource )
3009  {
3010  sourceClassID = ptrSource->sourceClassID;
3011  return E_OK;
3012  }
3013  return (E_NON_EXISTENT);
3014 }
3015 
3016 
3017 am_Error_e CAmDatabaseHandlerMap::changeSourceDB(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_CustomConnectionFormat_t>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties)
3018 {
3019 
3020  if (!existSource(sourceID))
3021  {
3022  logError(__METHOD_NAME__,"sourceID must be valid");
3023  return (E_NON_EXISTENT);
3024  }
3025 
3027  am_sourceClass_t sourceClassOut(sourceClassID);
3028  std::vector<am_MainSoundProperty_s> listMainSoundPropertiesOut(listMainSoundProperties);
3029  //check if sinkClass needs to be changed
3030 
3031  std::unordered_map<am_sourceID_t, am_Source_Database_s>::iterator iter = mMappedData.mSourceMap.begin();
3032  for(; iter!=mMappedData.mSourceMap.end(); ++iter)
3033  {
3034  if( iter->second.sourceID == sourceID )
3035  {
3036  if (sourceClassID != 0)
3037  {
3038  DB_COND_UPDATE(iter->second.sourceClassID, sourceClassID);
3039  }
3040  else if (0 == iter->second.reserved)
3041  {
3042  sourceClassOut = iter->second.sourceClassID;
3043  }
3044  break;
3045  }
3046  }
3047 
3048  //check if soundProperties need to be updated
3049  if (!listSoundProperties.empty())
3050  {
3051  mMappedData.mSourceMap.at(sourceID).listSoundProperties = listSoundProperties;
3052  mMappedData.mSourceMap.at(sourceID).cacheSoundProperties.clear();
3053  }
3054 
3055  //check if we have to update the list of connectionformats
3056  if (!listConnectionFormats.empty())
3057  {
3058  mMappedData.mSourceMap.at(sourceID).listConnectionFormats = listConnectionFormats;
3059  }
3060 
3061  //then we need to check if we need to update the listMainSoundProperties
3062  if (sourceVisible(sourceID))
3063  {
3064  if (!listMainSoundProperties.empty())
3065  {
3066  DB_COND_UPDATE(mMappedData.mSourceMap.at(sourceID).listMainSoundProperties, listMainSoundProperties);
3067  mMappedData.mSourceMap.at(sourceID).cacheMainSoundProperties.clear();
3068  }
3069  else
3070  {
3071  getListMainSourceSoundProperties(sourceID,listMainSoundPropertiesOut);
3072  }
3073  }
3074 
3075  if (DB_COND_ISMODIFIED)
3076  {
3077  logVerbose("DatabaseHandler::changeSource changed changeSource of source:", sourceID);
3078 
3079  NOTIFY_OBSERVERS4(dboSourceUpdated, sourceID,sourceClassOut,listMainSoundPropertiesOut,sourceVisible(sourceID))
3080 
3081  }
3082 
3083  return (E_OK);
3084 
3085 }
3086 
3087 am_Error_e CAmDatabaseHandlerMap::changeSinkDB(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector<am_SoundProperty_s>& listSoundProperties, const std::vector<am_CustomConnectionFormat_t>& listConnectionFormats, const std::vector<am_MainSoundProperty_s>& listMainSoundProperties)
3088 {
3089 
3091  am_sinkClass_t sinkClassOut(sinkClassID);
3092  std::vector<am_MainSoundProperty_s> listMainSoundPropertiesOut(listMainSoundProperties);
3093 
3094  if (!existSink(sinkID))
3095  {
3096  logError(__METHOD_NAME__,"sinkID must be valid");
3097  return (E_NON_EXISTENT);
3098  }
3099 
3100  std::unordered_map<am_sinkID_t, am_Sink_Database_s>::iterator iter = mMappedData.mSinkMap.begin();
3101  for(; iter!=mMappedData.mSinkMap.end(); ++iter)
3102  {
3103  if (iter->second.sinkID == sinkID)
3104  {
3105  if (sinkClassID != 0)
3106  {
3107  DB_COND_UPDATE(iter->second.sinkClassID, sinkClassID);
3108  }
3109  else if (0 == iter->second.reserved)
3110  {
3111  sinkClassOut = iter->second.sinkClassID;
3112  }
3113  break;
3114  }
3115  }
3116 
3117  //check if soundProperties need to be updated
3118  if (!listSoundProperties.empty())
3119  {
3120  mMappedData.mSinkMap.at(sinkID).listSoundProperties = listSoundProperties;
3121  mMappedData.mSinkMap.at(sinkID).cacheSoundProperties.clear();
3122  }
3123 
3124  //check if we have to update the list of connectionformats
3125  if (!listConnectionFormats.empty())
3126  {
3127  mMappedData.mSinkMap.at(sinkID).listConnectionFormats = listConnectionFormats;
3128  }
3129 
3130  //then we need to check if we need to update the listMainSoundProperties
3131  if (sinkVisible(sinkID))
3132  {
3133  if (!listMainSoundProperties.empty())
3134  {
3135  DB_COND_UPDATE(mMappedData.mSinkMap.at(sinkID).listMainSoundProperties, listMainSoundProperties);
3136  mMappedData.mSinkMap.at(sinkID).cacheMainSoundProperties.clear();
3137  }
3138  else //read out the properties
3139  {
3140  getListMainSinkSoundProperties(sinkID,listMainSoundPropertiesOut);
3141  }
3142  }
3143 
3144  if (DB_COND_ISMODIFIED)
3145  {
3146  logVerbose("DatabaseHandler::changeSink changed changeSink of sink:", sinkID);
3147 
3148  NOTIFY_OBSERVERS4(dboSinkUpdated, sinkID,sinkClassOut,listMainSoundPropertiesOut,sinkVisible(sinkID))
3149  }
3150 
3151  return (E_OK);
3152 }
3153 
3154 am_Error_e CAmDatabaseHandlerMap::getListMainSinkNotificationConfigurations(const am_sinkID_t sinkID, std::vector<am_NotificationConfiguration_s>& listMainNotificationConfigurations)
3155 {
3156 
3157  if (!existSink(sinkID))
3158  {
3159  logWarning(__METHOD_NAME__,"sinkID must be valid");
3160  return (E_DATABASE_ERROR);
3161  }
3162  listMainNotificationConfigurations.clear();
3163 
3164  listMainNotificationConfigurations = mMappedData.mSinkMap.at(sinkID).listMainNotificationConfigurations;
3165 
3166  return (E_OK);
3167 }
3168 
3169 am_Error_e CAmDatabaseHandlerMap::getListMainSourceNotificationConfigurations(const am_sourceID_t sourceID, std::vector<am_NotificationConfiguration_s>& listMainNotificationConfigurations)
3170 {
3171 
3172  if (!existSource(sourceID))
3173  {
3174  logWarning(__METHOD_NAME__,"sourceID must be valid");
3175  return (E_DATABASE_ERROR);
3176  }
3177 
3178  listMainNotificationConfigurations = mMappedData.mSourceMap.at(sourceID).listMainNotificationConfigurations;
3179 
3180  return (E_OK);
3181 }
3182 
3183 bool changeMainNotificationConfiguration(std::vector<am_NotificationConfiguration_s> & listMainNotificationConfigurations,
3184  const am_NotificationConfiguration_s & mainNotificationConfiguration)
3185 {
3186  std::vector<am_NotificationConfiguration_s>::iterator iter = listMainNotificationConfigurations.begin();
3187  for(; iter<listMainNotificationConfigurations.end(); ++iter)
3188  {
3189  if( mainNotificationConfiguration.type == iter->type )
3190  {
3191 #ifdef WITH_DATABASE_CHANGE_CHECK
3192  if( iter->status == mainNotificationConfiguration.status && iter->parameter == mainNotificationConfiguration.parameter )
3193  return false;
3194 #endif
3195  *iter = mainNotificationConfiguration;
3196  return true;
3197  }
3198  }
3199  return false;
3200 }
3201 
3203 {
3204 
3205  if (!existSink(sinkID))
3206  {
3207  logError(__METHOD_NAME__,"sinkID must be valid");
3208  return (E_NON_EXISTENT);
3209  }
3210  if(!changeMainNotificationConfiguration(mMappedData.mSinkMap.at(sinkID).listMainNotificationConfigurations, mainNotificationConfiguration))
3211  return (E_NO_CHANGE);
3212 
3213  logVerbose("DatabaseHandler::changeMainSinkNotificationConfigurationDB changed MainNotificationConfiguration of source:", sinkID, "type:", mainNotificationConfiguration.type, "to status=", mainNotificationConfiguration.status, "and parameter=",mainNotificationConfiguration.parameter);
3214 
3215  NOTIFY_OBSERVERS2(dboSinkMainNotificationConfigurationChanged, sinkID, mainNotificationConfiguration)
3216 
3217  return (E_OK);
3218 }
3219 
3221 {
3222 
3223  if (!existSource(sourceID))
3224  {
3225  logError(__METHOD_NAME__,"sourceID must be valid");
3226  return (E_NON_EXISTENT);
3227  }
3228 
3229  if(!changeMainNotificationConfiguration(mMappedData.mSourceMap.at(sourceID).listMainNotificationConfigurations, mainNotificationConfiguration))
3230  return (E_NO_CHANGE);
3231 
3232  logVerbose("DatabaseHandler::changeMainSourceNotificationConfigurationDB changed MainNotificationConfiguration of source:", sourceID, "type:", mainNotificationConfiguration.type, "to status=", mainNotificationConfiguration.status, "and parameter=",mainNotificationConfiguration.parameter);
3233 
3234  NOTIFY_OBSERVERS2(dboSourceMainNotificationConfigurationChanged, sourceID, mainNotificationConfiguration)
3235 
3236  return (E_OK);
3237 }
3238 
3239 am_Error_e CAmDatabaseHandlerMap::changeGatewayDB(const am_gatewayID_t gatewayID, const std::vector<am_CustomConnectionFormat_t>& listSourceConnectionFormats, const std::vector<am_CustomConnectionFormat_t>& listSinkConnectionFormats, const std::vector<bool>& convertionMatrix)
3240 {
3241 
3242  if (!existGateway(gatewayID))
3243  {
3244  logError(__METHOD_NAME__,"gatewayID must be valid");
3245  return (E_NON_EXISTENT);
3246  }
3247 
3248  if (!listSourceConnectionFormats.empty())
3249  {
3250  mMappedData.mGatewayMap.at(gatewayID).listSourceFormats = listSourceConnectionFormats;
3251  }
3252 
3253  if (!listSinkConnectionFormats.empty())
3254  {
3255  mMappedData.mGatewayMap.at(gatewayID).listSinkFormats = listSinkConnectionFormats;
3256  }
3257 
3258  if (!convertionMatrix.empty())
3259  {
3260  mListConnectionFormat.clear();
3261  mListConnectionFormat.insert(std::make_pair(gatewayID, convertionMatrix));
3262  }
3263 
3264  logVerbose("DatabaseHandler::changeGatewayDB changed Gateway with ID", gatewayID);
3265 
3266  //todo: check if observer needs to be adopted.
3267  return (E_OK);
3268 }
3269 
3270 am_Error_e CAmDatabaseHandlerMap::changeConverterDB(const am_converterID_t converterID, const std::vector<am_CustomConnectionFormat_t>& listSourceConnectionFormats, const std::vector<am_CustomConnectionFormat_t>& listSinkConnectionFormats, const std::vector<bool>& convertionMatrix)
3271 {
3272 
3273  if (!existConverter(converterID))
3274  {
3275  logError(__METHOD_NAME__,"converterID must be valid");
3276  return (E_NON_EXISTENT);
3277  }
3278 
3279  if (!listSourceConnectionFormats.empty())
3280  {
3281  mMappedData.mConverterMap.at(converterID).listSourceFormats = listSourceConnectionFormats;
3282  }
3283 
3284  if (!listSinkConnectionFormats.empty())
3285  {
3286  mMappedData.mConverterMap.at(converterID).listSinkFormats = listSinkConnectionFormats;
3287  }
3288 
3289  if (!convertionMatrix.empty())
3290  {
3291  mListConnectionFormat.clear();
3292  mListConnectionFormat.insert(std::make_pair(converterID, convertionMatrix));
3293  }
3294 
3295  logVerbose("DatabaseHandler::changeConverterDB changed Gateway with ID", converterID);
3296 
3297  //todo: check if observer needs to be adopted.
3298  return (E_OK);
3299 }
3300 
3301 bool changeNotificationConfiguration(std::vector<am_NotificationConfiguration_s> & listNotificationConfigurations, const am_NotificationConfiguration_s & notificationConfiguration)
3302 {
3303  bool changed = false;
3304  std::vector<am_NotificationConfiguration_s>::iterator iter = listNotificationConfigurations.begin();
3305  for(; iter<listNotificationConfigurations.end(); ++iter)
3306  {
3307  if( notificationConfiguration.type == iter->type )
3308  {
3309  iter->status = notificationConfiguration.status;
3310  iter->parameter = notificationConfiguration.parameter;
3311  changed |= true;
3312  }
3313  }
3314  return changed;
3315 }
3316 
3318 {
3319 
3320  if (!existSink(sinkID))
3321  {
3322  logError(__METHOD_NAME__,"sinkID must be valid");
3323  return (E_NON_EXISTENT);
3324  }
3325  if(!changeNotificationConfiguration(mMappedData.mSinkMap.at(sinkID).listNotificationConfigurations, notificationConfiguration))
3326  return (E_NO_CHANGE);
3327 
3328  logVerbose("DatabaseHandler::changeMainSinkNotificationConfigurationDB changed MainNotificationConfiguration of source:", sinkID, "type:", notificationConfiguration.type, "to status=", notificationConfiguration.status, "and parameter=",notificationConfiguration.parameter);
3329 
3330  //todo:: inform obsever here...
3331  return (E_NON_EXISTENT);
3332 }
3333 
3335 {
3336 
3337  if (!existSource(sourceID))
3338  {
3339  logError(__METHOD_NAME__,"sourceID must be valid");
3340  return (E_NON_EXISTENT);
3341  }
3342 
3343  if(!changeNotificationConfiguration(mMappedData.mSourceMap.at(sourceID).listNotificationConfigurations, notificationConfiguration))
3344  return (E_NO_CHANGE);
3345 
3346  logVerbose("DatabaseHandler::changeSourceNotificationConfigurationDB changed MainNotificationConfiguration of source:", sourceID, "type:", notificationConfiguration.type, "to status=", notificationConfiguration.status, "and parameter=",notificationConfiguration.parameter);
3347 
3348  //todo:: implement observer function
3349  return (E_NON_EXISTENT);
3350 }
3351 
3352 am_Error_e CAmDatabaseHandlerMap::enumerateSources(std::function<void(const am_Source_s & element)> cb) const
3353 {
3354  for(auto it = mMappedData.mSourceMap.begin(); it!=mMappedData.mSourceMap.end(); it++)
3355  {
3356  const am_Source_Database_s *pObject = &it->second;
3357  if( 0==pObject->reserved )
3358  cb(*pObject);
3359  }
3360  return E_OK;
3361 }
3362 
3363 am_Error_e CAmDatabaseHandlerMap::enumerateSinks(std::function<void(const am_Sink_s & element)> cb) const
3364 {
3365  for(auto it = mMappedData.mSinkMap.begin(); it!=mMappedData.mSinkMap.end(); it++)
3366  {
3367  const am_Sink_Database_s *pObject = &it->second;
3368  if( 0==pObject->reserved )
3369  cb(*pObject);
3370  }
3371  return E_OK;
3372 }
3373 
3374 am_Error_e CAmDatabaseHandlerMap::enumerateGateways(std::function<void(const am_Gateway_s & element)> cb) const
3375 {
3376  for(auto it = mMappedData.mGatewayMap.begin(); it!=mMappedData.mGatewayMap.end(); it++)
3377  {
3378  const am_Gateway_s *pObject = &it->second;
3379  cb(*pObject);
3380  }
3381  return E_OK;
3382 }
3383 
3384 am_Error_e CAmDatabaseHandlerMap::enumerateConverters(std::function<void(const am_Converter_s & element)> cb) const
3385 {
3386  for(auto it = mMappedData.mConverterMap.begin(); it!=mMappedData.mConverterMap.end(); it++)
3387  {
3388  const am_Converter_s *pObject = &it->second;
3389  cb(*pObject);
3390  }
3391  return E_OK;
3392 }
3393 
3395  assert(iObserver!=NULL);
3396  if (std::find(mDatabaseObservers.begin(), mDatabaseObservers.end(), iObserver) == mDatabaseObservers.end())
3397  {
3398  mDatabaseObservers.push_back(static_cast<AmDatabaseObserverCallbacks*>(iObserver));
3399  static_cast<AmDatabaseObserverCallbacks*>(iObserver)->mpDatabaseHandler = this;
3400  return true;
3401  }
3402  return false;
3403 }
3405  assert(iObserver!=NULL);
3406  auto it = std::find(mDatabaseObservers.begin(), mDatabaseObservers.end(), iObserver);
3407  if (it != mDatabaseObservers.end()) {
3408  mDatabaseObservers.erase(it);
3409  static_cast<AmDatabaseObserverCallbacks*>(iObserver)->mpDatabaseHandler = nullptr;
3410  return true;
3411  }
3412  return false;
3413 }
3414 
3416  return mDatabaseObservers.size();
3417 }
3418 
3419 }
am_Error_e getMainConnectionInfoDB(const am_mainConnectionID_t mainConnectionID, am_MainConnection_s &mainConnectionData) const
am_Error_e getListSinkClasses(std::vector< am_SinkClass_s > &listSinkClasses) const
am_sourceID_t sourceID
The sourceID of the converter sink-end.
am_Error_e removeConverterDB(const am_converterID_t converterID)
am_Error_e getListGateways(std::vector< am_Gateway_s > &listGateways) const
std::string busname
the busname.
am_Error_e changeSinkMuteStateDB(const am_MuteState_e muteState, const am_sinkID_t sinkID)
am_Error_e getListConnections(std::vector< am_Connection_s > &listConnections) const
std::string name
The name of the crossfader.
am_Error_e changeCrossFaderHotSink(const am_crossfaderID_t crossfaderID, const am_HotSink_e hotsink)
am_Error_e changeSinkDB(const am_sinkID_t sinkID, const am_sinkClass_t sinkClassID, const std::vector< am_SoundProperty_s > &listSoundProperties, const std::vector< am_CustomAvailabilityReason_t > &listConnectionFormats, const std::vector< am_MainSoundProperty_s > &listMainSoundProperties)
am_MuteState_e muteState
This attribute reflects the muteState of the sink.
uint16_t am_connectionID_t
a connection ID
uint16_t am_CustomSoundPropertyType_t
Within genivi only the some example properties are defined.
am_Error_e changeDelayMainConnection(const am_timeSync_t &delay, const am_mainConnectionID_t &connectionID)
am_Error_e getListSourcesOfDomain(const am_domainID_t domainID, std::vector< am_sourceID_t > &listSourceID) const
std::vector< am_ClassProperty_s > listClassProperties
the list of the class properties.
bool sourceVisible(const am_sourceID_t sourceID) const
registers the Observer at the Database
void logWarning(T value, TArgs...args)
logs given values with warninglevel with the default context
am_converterID_t converterID
This is the ID of the converter, it is unique in the system.
A Common-API wrapper class, which loads the common-api runtime and instantiates all necessary objects...
am_sourceClass_t sourceClassID
the source ID
the desired object is non existent
bool existsObjectWithKeyInMap(const TMapKeyType &key, const std::unordered_map< TMapKeyType, TMapObjectType > &map)
bool existSourceName(const std::string &name) const
checks if a name exits
uint16_t am_sinkClass_t
am_CustomNotificationType_t type
The notification type of the notification.
am_Error_e
the errors of the audiomanager.
am_Error_e changeConnectionFinal(const am_connectionID_t connectionID)
am_InterruptState_e
This struct holds information about the configuration for notifications.
the desired object already exists
am_Error_e peekDomain(const std::string &name, am_domainID_t &domainID)
am_Error_e changeSourceNotificationConfigurationDB(const am_sourceID_t sourceID, const am_NotificationConfiguration_s notificationConfiguration)
am_Error_e getListSinkSoundProperties(const am_sinkID_t sinkID, std::vector< am_SoundProperty_s > &listSoundproperties) const
am_Error_e getListMainSinkSoundProperties(const am_sinkID_t sinkID, std::vector< am_MainSoundProperty_s > &listSoundProperties) const
std::vector< am_ClassProperty_s > listClassProperties
the list of the class properties.
struct describing source classes
This struct describes the attribiutes of a sink.
bool sinkVisible(const am_sinkID_t sinkID) const
gives information about the visibility of a sink
int16_t value
the actual value
am_DomainState_e state
the current domain state
am_Error_e getListMainSinkNotificationConfigurations(const am_sinkID_t sinkID, std::vector< am_NotificationConfiguration_s > &listMainNotificationConfigurations)
am_sinkID_t sinkID_A
The sinkID of the SinkA.
am_Error_e getDomainOfSink(const am_sinkID_t sinkID, am_domainID_t &domainID) const
am_Error_e changeSourceVolume(const am_sourceID_t sourceID, const am_volume_t volume)
am_Error_e getSinkInfoDB(const am_sinkID_t sinkID, am_Sink_s &sinkData) const
am_Error_e removeMainConnectionDB(const am_mainConnectionID_t mainConnectionID)
am_Error_e getListSources(std::vector< am_Source_s > &lisSources) const
const TReturn * objectMatchingPredicate(const std::unordered_map< TIdentifier, TReturn > &map, std::function< bool(const TReturn &refObject)> comparator)
Returns an object matching predicate.
am_Error_e enumerateSinks(std::function< void(const am_Sink_s &element)> cb) const
am_sinkID_t sinkID
This is the ID of the sink, it is unique in the system.
am_Error_e removeSinkClassDB(const am_sinkClass_t sinkClassID)
This struct describes the attribiutes of a domain.
am_domainID_t controlDomainID
This is the ID of the domain that registers the gateway.
std::string name
The name of the source.
uint16_t am_crossfaderID_t
a crossfader ID
am_sinkID_t sinkID
the sinkID
uint16_t am_CustomConnectionFormat_t
This type classifies the format in which data is exchanged within a connection.
am_sinkID_t sinkID
The sinkID of the convertersink-end.
am_HotSink_e hotSink
This enum can have 3 states:
am_Error_e getListMainSources(std::vector< am_SourceType_s > &listMainSources) const
uint16_t am_CustomMainSoundPropertyType_t
Here are all SoundProperties that can be set via the CommandInterface.
am_Error_e changeSinkAvailabilityDB(const am_Availability_s &availability, const am_sinkID_t sinkID)
am_Error_e getListCrossfadersOfDomain(const am_domainID_t domainID, std::vector< am_crossfaderID_t > &listGatewaysID) const
this type holds all information of sinks relevant to the HMI
am_Error_e changeDomainStateDB(const am_DomainState_e domainState, const am_domainID_t domainID)
am_sourceID_t sourceID
the sourceID where the connection starts
am_crossfaderID_t crossfaderID
This is the ID of the crossfader, it is unique in the system.
am_SourceState_e sourceState
The source state is an indication towards the source if it is actively heard or not.
bool isDataEqual(const T &left, const T &right)
int16_t am_timeSync_t
offset time that is introduced in milli seconds.
am_Error_e enumerateSources(std::function< void(const am_Source_s &element)> cb) const
am_Availability_s availability
the availability of the source
am_Error_e changeSystemPropertyDB(const am_SystemProperty_s &property)
am_Error_e getListSourceSoundProperties(const am_sourceID_t sourceID, std::vector< am_SoundProperty_s > &listSoundproperties) const
bool existSink(const am_sinkID_t sinkID) const
checks for a certain Sink
am_Error_e getListSinksOfDomain(const am_domainID_t domainID, std::vector< am_sinkID_t > &listSinkID) const
am_gatewayID_t gatewayID
This is the ID of the gateway, it is unique in the system.
am_Error_e getConverterInfoDB(const am_converterID_t converterID, am_Converter_s &converterData) const
am_sourceClass_t sourceClassID
the sourceClassID, indicates the class the source is in.
describes class properties
SPDX license identifier: MPL-2.0.
am_Error_e getListSourceConnectionFormats(const am_sourceID_t sourceID, std::vector< am_CustomAvailabilityReason_t > &listConnectionFormats) const
std::string name
the name of the sourceClass - must be unique in the system
struct that holds attribiutes of a mainconnection
am_Error_e getSoureState(const am_sourceID_t sourceID, am_SourceState_e &sourceState) const
am_Error_e getListMainConnections(std::vector< am_MainConnection_s > &listMainConnections) const
bool existConverter(const am_converterID_t converterID) const
am_sinkID_t sinkID
The sinkID of the gateway sink-end.
am_Error_e peekSink(const std::string &name, am_sinkID_t &sinkID)
am_Error_e changeSourceClassInfoDB(const am_SourceClass_s &sourceClass)
SPDX license identifier: MPL-2.0.
bool existDomain(const am_domainID_t domainID) const
checks for a certain domain
bool existConnectionID(const am_connectionID_t connectionID) const
checks if a connection with the given ID exists
am_Error_e enterSourceDB(const am_Source_s &sourceData, am_sourceID_t &sourceID)
am_Error_e changeConnectionTimingInformation(const am_connectionID_t connectionID, const am_timeSync_t delay)
am_Error_e changeSinkClassInfoDB(const am_SinkClass_s &sinkClass)
am_Error_e getListSystemProperties(std::vector< am_SystemProperty_s > &listSystemProperties) const
am_CustomConnectionFormat_t connectionFormat
the used connectionformat
am_sinkID_t sinkID
the sinkID where the connection ends
am_Error_e getListGatewaysOfDomain(const am_domainID_t domainID, std::vector< am_gatewayID_t > &listGatewaysID) const
std::string name
The name of the sink.
am_Error_e getListSinks(std::vector< am_Sink_s > &listSinks) const
std::vector< am_MainSoundProperty_s > listMainSoundProperties
This is the list of the available mainSoundProperties.
am_Error_e getSinkMainVolume(const am_sinkID_t sinkID, am_mainVolume_t &mainVolume) const
struct describing system properties
am_Error_e getSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomSoundPropertyType_t propertyType, int16_t &value) const
am_mainConnectionID_t mainConnectionID
the assigned ID
bool existConnection(const am_Connection_s &connection) const
checks if a connection already exists.
uint16_t am_converterID_t
a converter ID
void logVerbose(T value, TArgs...args)
logs given values with verbose with the default context
am_sourceID_t sourceID
The sourceID of the crossfader source.
am_Error_e getSourceInfoDB(const am_sourceID_t sourceID, am_Source_s &sourceData) const
#define NOTIFY_OBSERVERS(CALL)
am_Error_e removeDomainDB(const am_domainID_t domainID)
am_Error_e changeMainConnectionRouteDB(const am_mainConnectionID_t mainconnectionID, const std::vector< am_connectionID_t > &listConnectionID)
bool existCrossFader(const am_crossfaderID_t crossfaderID) const
checks if a CrossFader exists
am_Error_e peekSourceClassID(const std::string &name, am_sourceClass_t &sourceClassID)
am_Error_e getSourceVolume(const am_sourceID_t sourceID, am_volume_t &volume) const
am_sourceID_t sourceID
This is the ID of the source, it is unique in the system.
am_Error_e enterSinkClassDB(const am_SinkClass_s &sinkClass, am_sinkClass_t &sinkClassID)
struct describung mainsound property
am_Error_e getListDomains(std::vector< am_Domain_s > &listDomains) const
SPDX license identifier: MPL-2.0.
bool unregisterObserver(IAmDatabaseObserver *iObserver)
am_ConnectionState_e connectionState
the current connection state
bool existSourceNameOrID(const am_sourceID_t sourceID, const std::string &name) const
checks if a source name or ID exists
am_Availability_s availability
This attribute reflects the availability of the sink.
am_Error_e removeConnection(const am_connectionID_t connectionID)
am_domainID_t domainID
The domainID is the domain the source belongs to.
#define DB_COND_UPDATE(x, y)
am_ConnectionState_e connectionState
the current connection state
std::string name
The name of the gateway.
am_Error_e enterSourceClassDB(am_sourceClass_t &sourceClassID, const am_SourceClass_s &sourceClass)
am_Error_e getSourceClassInfoDB(const am_sourceID_t sourceID, am_SourceClass_s &classInfo) const
am_Error_e getListSinkConnectionFormats(const am_sinkID_t sinkID, std::vector< am_CustomAvailabilityReason_t > &listConnectionFormats) const
bool existSourceClass(const am_sourceClass_t sourceClassID) const
checks for certain sourceClass
am_Error_e changeSinkMainVolumeDB(const am_mainVolume_t mainVolume, const am_sinkID_t sinkID)
am_Error_e peekSource(const std::string &name, am_sourceID_t &sourceID)
am_Error_e changeSinkVolume(const am_sinkID_t sinkID, const am_volume_t volume)
am_Error_e enumerateConverters(std::function< void(const am_Converter_s &element)> cb) const
uint16_t am_sourceID_t
a source ID
am_CustomMainSoundPropertyType_t type
the type of the property
struct describing the sound property
am_sinkID_t sinkID
This is the ID of the sink, it is unique in the system.
am_Error_e getDomainOfSource(const am_sourceID_t sourceID, am_domainID_t &domainID) const
am_Error_e removeCrossfaderDB(const am_crossfaderID_t crossfaderID)
am_sourceClass_t sourceClassID
the sourceClassID, indicates the class the source is in.
am_CustomSystemPropertyType_t type
the type that is set
am_sourceID_t sourceID
the source the audio flows from
am_sourceID_t sourceID
the sourceID
am_sinkClass_t sinkClassID
The sinkClassID references to a sinkClass.
am_Error_e enterCrossfaderDB(const am_Crossfader_s &crossfaderData, am_crossfaderID_t &crossfaderID)
struct describing sinkclasses
bool visible
This Boolean flag indicates whether a source is visible to the commandInterface or not...
am_NotificationStatus_e status
The Notification status.
am_Error_e removeSinkDB(const am_sinkID_t sinkID)
am_Error_e getSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomSoundPropertyType_t propertyType, int16_t &value) const
bool existSinkClass(const am_sinkClass_t sinkClassID) const
checks for certain SinkClass
am_Error_e getSinkVolume(const am_sinkID_t sinkID, am_volume_t &volume) const
am_Error_e enterDomainDB(const am_Domain_s &domainData, am_domainID_t &domainID)
The following interface methods must be implemented by the subclass.
#define DB_COND_ISMODIFIED
This class handles and abstracts the database.
am_CustomAvailabilityReason_t availabilityReason
the reason for the last change.
bool changeNotificationConfiguration(std::vector< am_NotificationConfiguration_s > &listNotificationConfigurations, const am_NotificationConfiguration_s &notificationConfiguration)
am_Error_e getListCrossfaders(std::vector< am_Crossfader_s > &listCrossfaders) const
am_Error_e getGatewayInfoDB(const am_gatewayID_t gatewayID, am_Gateway_s &gatewayData) const
std::string nodename
the name of the node
std::vector< am_connectionID_t > listConnectionID
the list of sub connection IDs the mainconnection consists of
am_Error_e getCrossfaderInfoDB(const am_crossfaderID_t crossfaderID, am_Crossfader_s &crossfaderData) const
am_mainVolume_t volume
This is the representation of the Volume for the commandInterface.
am_ConnectionState_e
represents the connection state
std::vector< am_MainSoundProperty_s > listMainSoundProperties
This is the list of the available mainSoundProperties.
This struct describes the attributes of a converter.
am_Error_e getListMainSourceSoundProperties(const am_sourceID_t sourceID, std::vector< am_MainSoundProperty_s > &listSourceProperties) const
bool existSource(const am_sourceID_t sourceID) const
checks for a certain Source
bool changeMainNotificationConfiguration(std::vector< am_NotificationConfiguration_s > &listMainNotificationConfigurations, const am_NotificationConfiguration_s &mainNotificationConfiguration)
am_Error_e removeSourceClassDB(const am_sourceClass_t sourceClassID)
bool registerObserver(IAmDatabaseObserver *iObserver)
am_Error_e getListSourceClasses(std::vector< am_SourceClass_s > &listSourceClasses) const
am_HotSink_e
describes the active sink of a crossfader.
am_Error_e changeSourceInterruptState(const am_sourceID_t sourceID, const am_InterruptState_e interruptState)
am_Availability_e availability
the current availability state
am_Error_e enumerateGateways(std::function< void(const am_Gateway_s &element)> cb) const
int16_t am_volume_t
The unit is 0.1 db steps,The smallest value -3000 (=AM_MUTE).
This struct describes the attribiutes of a crossfader.
am_sourceID_t sourceID
This is the ID of the source, it is unique in the system.
am_CustomSoundPropertyType_t type
the type of the property - a project specific enum
am_sinkID_t sinkID_B
The sinkID of the SinkB.
am_Error_e enterConnectionDB(const am_Connection_s &connection, am_connectionID_t &connectionID)
am_Error_e changeMainSinkNotificationConfigurationDB(const am_sinkID_t sinkID, const am_NotificationConfiguration_s mainNotificationConfiguration)
am_Error_e getListConnectionsReserved(std::vector< am_Connection_s > &listConnections) const
am_MuteState_e muteState
am_Error_e changeMainSourceNotificationConfigurationDB(const am_sourceID_t sourceID, const am_NotificationConfiguration_s mainNotificationConfiguration)
am_Error_e changeSourceSoundPropertyDB(const am_SoundProperty_s &soundProperty, const am_sourceID_t sourceID)
am_Error_e getMainSinkSoundPropertyValue(const am_sinkID_t sinkID, const am_CustomMainSoundPropertyType_t propertyType, int16_t &value) const
bool isComponentConnected(const am_Gateway_s &gateway) const
am_Error_e changeMainConnectionStateDB(const am_mainConnectionID_t mainconnectionID, const am_ConnectionState_e connectionState)
this type holds all information of connections relevant to the HMI
the desired action is not possible
am_Error_e changeMainSinkSoundPropertyDB(const am_MainSoundProperty_s &soundProperty, const am_sinkID_t sinkID)
bool existGateway(const am_gatewayID_t gatewayID) const
checks for certain gateway
am_sourceID_t sourceID
The sourceID of the gateway sink-end.
uint16_t am_sourceClass_t
am_connectionID_t connectionID
the assigned ID
std::string name
the name of the sinkClass - must be unique in the system
am_domainID_t domainID
the domain ID
am_domainID_t domainID
This is the ID of the domain that registers the converter.
am_Error_e enterMainConnectionDB(const am_MainConnection_s &mainConnectionData, am_mainConnectionID_t &connectionID)
am_Error_e removeGatewayDB(const am_gatewayID_t gatewayID)
am_Error_e peekSinkClassID(const std::string &name, am_sinkClass_t &sinkClassID)
this describes the availability of a sink or a source together with the latest change ...
am_Error_e getDomainState(const am_domainID_t domainID, am_DomainState_e &state) const
am_Error_e changeSourceDB(const am_sourceID_t sourceID, const am_sourceClass_t sourceClassID, const std::vector< am_SoundProperty_s > &listSoundProperties, const std::vector< am_CustomAvailabilityReason_t > &listConnectionFormats, const std::vector< am_MainSoundProperty_s > &listMainSoundProperties)
This struct describes the attributes of a gateway.
am_Error_e getListConvertersOfDomain(const am_domainID_t domainID, std::vector< am_converterID_t > &listConvertersID) const
void logError(T value, TArgs...args)
logs given values with errorlevel with the default context
am_Error_e changeSourceAvailabilityDB(const am_Availability_s &availability, const am_sourceID_t sourceID)
#define NOTIFY_OBSERVERS1(CALL, ARG1)
am_timeSync_t delay
the delay of the mainconnection
am_mainConnectionID_t mainConnectionID
the ID of the mainconnection
#define __METHOD_NAME__
am_Error_e changeSourceState(const am_sourceID_t sourceID, const am_SourceState_e sourceState)
am_Error_e changeMainSourceSoundPropertyDB(const am_MainSoundProperty_s &soundProperty, const am_sourceID_t sourceID)
#define NOTIFY_OBSERVERS2(CALL, ARG1, ARG2)
void dump(std::ostream &output) const
uint16_t am_domainID_t
a domain ID
am_Error_e enterSystemProperties(const std::vector< am_SystemProperty_s > &listSystemProperties)
am_Error_e enterSinkDB(const am_Sink_s &sinkData, am_sinkID_t &sinkID)
int16_t am_mainVolume_t
This is the volume presented on the command interface.
std::string name
The name of the converter.
am_Error_e changeSinkSoundPropertyDB(const am_SoundProperty_s &soundProperty, const am_sinkID_t sinkID)
no error - positive reply
bool existSinkName(const std::string &name) const
checks if a sink with the name exists
TMapObjectType const * objectForKeyIfExistsInMap(const TMapKeyType &key, const std::unordered_map< TMapKeyType, TMapObjectType > &map)
am_Error_e getListMainSourceNotificationConfigurations(const am_sourceID_t sourceID, std::vector< am_NotificationConfiguration_s > &listMainNotificationConfigurations)
int16_t value
the actual value of the property
am_Error_e getListVisibleMainConnections(std::vector< am_MainConnectionType_s > &listConnections) const
am_Error_e getDomainOfCrossfader(const am_converterID_t crossfader, am_domainID_t &domainID) const
there is no change
#define DB_COND_UPDATE_RIE(x, y)
std::vector< am_CustomConnectionFormat_t > listConnectionFormats
This list holds information about the formats that the Source is capable of supporting when deliverin...
#define DB_COND_UPDATE_INIT
only relevant for connectionStatechanged.
this type holds all information of sources relevant to the HMI
bool existSinkNameOrID(const am_sinkID_t sinkID, const std::string &name) const
checks if a sink with the ID or the name exists
uint16_t am_gatewayID_t
a gateway ID
This struct describes the attribiutes of a source.
am_Error_e removeSourceDB(const am_sourceID_t sourceID)
am_Error_e enterGatewayDB(const am_Gateway_s &gatewayData, am_gatewayID_t &gatewayID)
std::string name
The name of the sink.
am_Error_e getTimingInformation(const am_mainConnectionID_t mainConnectionID, am_timeSync_t &delay) const
am_volume_t volume
This is the volume of the sink.
am_Error_e getListConverters(std::vector< am_Converter_s > &listConverters) const
std::string name
The name of the source.
std::string name
the name of the domain
uint16_t am_sinkID_t
a sink ID
uint16_t am_mainConnectionID_t
a mainConnection ID
am_Error_e changeSinkNotificationConfigurationDB(const am_sinkID_t sinkID, const am_NotificationConfiguration_s notificationConfiguration)
am_Error_e changeGatewayDB(const am_gatewayID_t gatewayID, const std::vector< am_CustomAvailabilityReason_t > &listSourceConnectionFormats, const std::vector< am_CustomAvailabilityReason_t > &listSinkConnectionFormats, const std::vector< bool > &convertionMatrix)
int16_t parameter
This gives additional information to the notification status.
am_domainID_t domainID
The domainID is the domain the sink belongs to.
am_SourceState_e
The source state reflects the state of the source.
am_Error_e getSinkClassInfoDB(const am_sinkID_t sinkID, am_SinkClass_s &sinkClass) const
am_Error_e changeConverterDB(const am_converterID_t converterID, const std::vector< am_CustomConnectionFormat_t > &listSourceConnectionFormats, const std::vector< am_CustomConnectionFormat_t > &listSinkConnectionFormats, const std::vector< bool > &convertionMatrix)
am_sinkClass_t sinkClassID
The sinkClassID references to a sinkClass.
am_Error_e getListGatewayConnectionFormats(const am_gatewayID_t gatewayID, std::vector< bool > &listConnectionFormat) const
am_Error_e getListMainSinks(std::vector< am_SinkType_s > &listMainSinks) const
a database error occurred
am_Error_e enterConverterDB(const am_Converter_s &converterData, am_converterID_t &converterID)
bool existMainConnection(const am_mainConnectionID_t mainConnectionID) const
checks for a certain mainConnection
am_timeSync_t delay
the delay of the connection
#define NOTIFY_OBSERVERS4(CALL, ARG1, ARG2, ARG3, ARG4)
am_sinkClass_t sinkClassID
the ID of the sinkClass
std::vector< am_CustomConnectionFormat_t > listConnectionFormats
This list holds information about the formats that the Source is capable of supporting when deliverin...
am_Error_e getMainSourceSoundPropertyValue(const am_sourceID_t sourceID, const am_CustomMainSoundPropertyType_t propertyType, int16_t &value) const
am_sinkID_t sinkID
the sink the audio flows to