Additional functions of policy and resource management.
[profile/ivi/ico-uxf-homescreen.git] / lib / system-controller / CicoSCSystemConfig.cpp
1 /*
2  * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
3  *
4  * This program is licensed under the terms and conditions of the
5  * Apache License, version 2.0.  The full text of the Apache License is at
6  * http://www.apache.org/licenses/LICENSE-2.0
7  *
8  */
9
10 /*========================================================================*/    
11 /**
12  *  @file   CicoSCSystemConfig.cpp
13  *
14  *  @brief  This file implementation of CicoSCSystemConfig class
15  */
16 /*========================================================================*/    
17
18 #include "CicoSCSystemConfig.h"
19 #include "CicoSCConf.h"
20
21 //==========================================================================    
22 //  private static variable
23 //==========================================================================    
24 CicoSCSystemConfig* CicoSCSystemConfig::ms_myInstance = NULL;
25
26 //--------------------------------------------------------------------------
27 /**
28  *  @brief  default constructor
29  */
30 //--------------------------------------------------------------------------
31 CicoSCSystemConfig::CicoSCSystemConfig()
32 {
33     m_typeTable[""]          = ICO_NODETYPE_CENTER;
34     m_typeTable["center"]    = ICO_NODETYPE_CENTER;
35     m_typeTable["meter"]     = ICO_NODETYPE_METER;
36     m_typeTable["remote"]    = ICO_NODETYPE_REMOTE;
37     m_typeTable["passenger"] = ICO_NODETYPE_PASSENGER;
38     m_typeTable["rear"]      = ICO_NODETYPE_REAR;
39     m_typeTable["rearleft"]  = ICO_NODETYPE_REARLEFT;
40     m_typeTable["rearright"] = ICO_NODETYPE_REARRIGHT;
41
42     m_displayTypeTable[""]          = ICO_DISPLAYTYPE_CENTER;
43     m_displayTypeTable["center"]    = ICO_DISPLAYTYPE_CENTER;
44     m_displayTypeTable["meter"]     = ICO_DISPLAYTYPE_METER;
45     m_displayTypeTable["remote"]    = ICO_DISPLAYTYPE_REMOTE;
46     m_displayTypeTable["passenger"] = ICO_DISPLAYTYPE_PASSENGER;
47     m_displayTypeTable["rear"]      = ICO_DISPLAYTYPE_REAR;
48     m_displayTypeTable["rearleft"]  = ICO_DISPLAYTYPE_REARLEFT;
49     m_displayTypeTable["rearright"] = ICO_DISPLAYTYPE_REARRIGHT;
50
51     // 
52     m_categoryTalbe[""]              = ICO_POLICY_ALWAYS;
53     m_categoryTalbe["always"]        = ICO_POLICY_ALWAYS;
54     m_categoryTalbe["run"]           = ICO_POLICY_RUNNING;
55     m_categoryTalbe["park"]          = ICO_POLICY_PARKED;
56     m_categoryTalbe["shift_park"]    = ICO_POLICY_SHIFT_PARKING;
57     m_categoryTalbe["shift_back"]    = ICO_POLICY_SHIFT_REVERSES;
58     m_categoryTalbe["shift_rev"]     = ICO_POLICY_SHIFT_REVERSES;
59     m_categoryTalbe["blinker_left"]  = ICO_POLICY_BLINKER_LEFT;
60     m_categoryTalbe["blinker_right"] = ICO_POLICY_BLINKER_RIGHT;
61
62     //
63     m_privilegeTable["almighty"]       = ICO_PRIVILEGE_ALMIGHTY;
64     m_privilegeTable["system"]         = ICO_PRIVILEGE_SYSTEM;
65     m_privilegeTable["system.audio"]   = ICO_PRIVILEGE_SYSTEM_AUDIO;
66     m_privilegeTable["system.visible"] = ICO_PRIVILEGE_SYSTEM_VISIBLE;
67     m_privilegeTable["maker"]          = ICO_PRIVILEGE_MAKER;
68     m_privilegeTable["certificate"]    = ICO_PRIVILEGE_CERTIFICATE;
69     m_privilegeTable["none"]           = ICO_PRIVILEGE_NONE;
70     m_privilegeTable[""]               = ICO_PRIVILEGE_NONE;
71     m_resourceConf = NULL;
72     m_userConf = NULL;
73 }
74
75 //--------------------------------------------------------------------------
76 /**
77  *  @brief  destructor
78  */
79 //--------------------------------------------------------------------------
80 CicoSCSystemConfig::~CicoSCSystemConfig()
81 {
82     // TODO
83 }
84
85 //--------------------------------------------------------------------------
86 /**
87  *  @brief  Get instance of CicoSCSystemConfig
88  *
89  *  @return  pointer of CicoSCSystemConfig object
90  */
91 //--------------------------------------------------------------------------
92 CicoSCSystemConfig*
93 CicoSCSystemConfig::getInstance(void)
94 {
95     if (NULL == ms_myInstance) {
96         ms_myInstance = new CicoSCSystemConfig();
97     }
98     return ms_myInstance;
99 }
100
101 //--------------------------------------------------------------------------
102 /**
103  *  @brief  Get instance of CicoSCSystemConfig
104  *
105  *  @param  [in]    confFile    config file name
106  *  @return 0 on success, other on error
107  */
108 //--------------------------------------------------------------------------
109 int
110 CicoSCSystemConfig::load(const string & confFile)
111 {
112     ptree root;
113     read_xml(confFile, root);
114
115     createNodeConfList(root);
116     createDisplayConfList(root);
117     createSoundConfList(root);
118     createPortConf(root);
119     createCategoryConf(root);
120     createAppKindConf(root);
121     createInputDevList(root);
122     createDefaultConf(root);
123     createLogConf(root);
124     createResourceConf(root);
125     createUserConf(root);
126
127     return 0;   //TODO
128 }
129
130 //--------------------------------------------------------------------------
131 /**
132  *  @brief  
133  *
134  *  @param  [in]
135  */
136 //--------------------------------------------------------------------------
137 const vector<CicoSCNodeConf*>&
138 CicoSCSystemConfig::getNodeConfList(void) const
139 {
140     return m_nodeConfList;
141 }
142
143 //--------------------------------------------------------------------------
144 /**
145  *  @brief  
146  *
147  *  @param  [in]
148  */
149 //--------------------------------------------------------------------------
150 const vector<CicoSCDisplayConf*>&
151 CicoSCSystemConfig::getDisplayConfList(void) const
152 {
153     return m_displayConfList;
154 }
155
156 //--------------------------------------------------------------------------
157 /**
158  *  @brief  
159  *
160  *  @param  [in]
161  */
162 //--------------------------------------------------------------------------
163 const vector<CicoSCSoundConf*>&
164 CicoSCSystemConfig::getSoundConfList(void) const
165 {
166     return m_soundConfList;
167 }
168
169 //--------------------------------------------------------------------------
170 /**
171  *  @brief  
172  *
173  *  @param  [in]
174  */
175 //--------------------------------------------------------------------------
176 const vector<CicoSCInputDevConf*> &
177 CicoSCSystemConfig::getInputDevConfList(void) const
178 {
179     return m_inputDevConfList;
180 }
181
182 //--------------------------------------------------------------------------
183 /**
184  *  @brief  
185  *
186  *  @param  [in]
187  */
188 //--------------------------------------------------------------------------
189 const vector<CicoSCCategoryConf*> &
190 CicoSCSystemConfig::getCategoryConfList(void) const
191 {
192     return m_categoryConfList;
193 }
194
195 //--------------------------------------------------------------------------
196 /**
197  *  @brief  
198  *
199  *  @param  [in]
200  */
201 //--------------------------------------------------------------------------
202 const vector<CicoSCAppKindConf*> &
203 CicoSCSystemConfig::getAppKindConfList(void) const
204 {
205     return m_appKindConfList;
206 }
207
208 //--------------------------------------------------------------------------
209 /**
210  *  @brief  
211  *
212  *  @param  [in]
213  */
214 //--------------------------------------------------------------------------
215 void
216 CicoSCSystemConfig::createNodeConfList(const ptree & root)
217 {
218     //<nodes>
219 //    if (root.not_found() == root.find("systemconfig")) {
220 //        ICO_ERR("nodes element not found");
221 //        return;
222 //    }
223     ptree nodes = root.get_child("systemconfig.nodes");
224
225     BOOST_FOREACH (const ptree::value_type& child, nodes) {
226         if (0 != strcmp(child.first.data(),"node")) {
227             ICO_ERR("unknown element(%s)", child.first.data());
228         }
229         optional<int> id = optional<int>(-1);
230         optional<string> name;
231         optional<string> type;
232         optional<string> address;
233
234         id = child.second.get_optional<int>("<xmlattr>.id");
235         if (false == id.is_initialized()) {
236             ICO_ERR("node.id attr not found");
237             continue;
238         }
239         name = child.second.get_optional<string>("<xmlattr>.name");
240         if (false == name.is_initialized()) {
241             ICO_ERR("node.name attr not found");
242             continue;
243         }
244         type = child.second.get_optional<string>("type");
245         if (false == type.is_initialized()) {
246             ICO_ERR("node.type element not found");
247             continue;
248         }
249         address = child.second.get_optional<string>("ipaddress");
250         if (false == address.is_initialized()) {
251             ICO_ERR("node.address element not found");
252             continue;
253         }
254
255         CicoSCNodeConf* nodeConf = new CicoSCNodeConf;
256         nodeConf->id      = id.get();
257         nodeConf->name    = name.get();
258         nodeConf->type    = m_typeTable[type.get()];
259         nodeConf->address = address.get();
260         m_nodeConfList.push_back(nodeConf);
261
262         nodeConf->dumpConf();
263     }
264 }
265
266 //--------------------------------------------------------------------------
267 /**
268  *  @brief  
269  *
270  *  @param  [in]
271  */
272 //--------------------------------------------------------------------------
273 void
274 CicoSCSystemConfig::createDisplayConfList(const ptree & root)
275 {
276     //<displays>
277 //    if (root.not_found() != root.find("systemconfi.displays")) {
278 //        ICO_ERR("displays element not found");
279 //        return;
280 //    }
281
282     ptree displays = root.get_child("systemconfig.displays");
283     BOOST_FOREACH (const ptree::value_type& child, displays) {
284         optional<int> id = optional<int>(-1);
285         optional<string> name;
286         optional<string> node;
287         optional<int> no = optional<int>(-1);
288         optional<string> wayland;
289         optional<string> type;
290         optional<int> width = optional<int>(-1);
291         optional<int> height = optional<int>(-1);
292         optional<int> inch = optional<int>(-1);
293
294         id = child.second.get_optional<int>("<xmlattr>.id");
295         if (false == id.is_initialized()) {
296             ICO_ERR("display.id attr not found");
297             continue;
298         }
299         name = child.second.get_optional<string>("<xmlattr>.name");
300         if (false == name.is_initialized()) {
301             ICO_ERR("display.name attr not found");
302             continue;
303         }
304         node = child.second.get_optional<string>("node");
305         if (false == node.is_initialized()) {
306             ICO_ERR("display.node attr not found");
307             continue;
308         }
309         no = child.second.get_optional<int>("no");
310         if (false == no.is_initialized()) {
311             ICO_ERR("display.no element not found");
312             continue;
313         }
314         wayland = child.second.get_optional<string>("wayland");
315         if (false == wayland.is_initialized()) {
316             ICO_ERR("display.wayland element not found");
317             continue;
318         }
319         type = child.second.get_optional<string>("type");
320         if (false == type.is_initialized()) {
321             ICO_ERR("display.type element not found");
322             continue;
323         }
324         width = child.second.get_optional<int>("width");
325         if (false == width.is_initialized()) {
326             ICO_ERR("display.width element not found");
327             continue;
328         }
329         height = child.second.get_optional<int>("height");
330         if (false == height.is_initialized()) {
331             ICO_ERR("display.height element not found");
332             continue;
333         }
334         inch = child.second.get_optional<int>("inch");
335         if (false == inch.is_initialized()) {
336             ICO_ERR("display.inch element not found");
337             continue;
338         }
339
340         CicoSCDisplayConf* displayConf = new CicoSCDisplayConf();
341         displayConf->id     = id.get();
342         displayConf->name   = name.get();
343         displayConf->node   = getNodeIdbyName(node.get());
344         displayConf->no     = no.get();
345         displayConf->type   = m_displayTypeTable[type.get()];
346         displayConf->width  = width.get();
347         displayConf->height = height.get();
348         displayConf->inch   = inch.get();
349
350         displayConf->dumpConf();
351
352         createLayerConf(child, displayConf);
353         createDisplayZoneConf(child, displayConf);
354
355         // TODO overlap to zoneid
356         vector<CicoSCDisplayZoneConf*>::iterator itr;
357         itr = displayConf->zoneConfList.begin();
358         for (; itr != displayConf->zoneConfList.end(); ++itr) {
359         }
360
361         m_displayConfList.push_back(displayConf);
362     }
363 }
364
365 //--------------------------------------------------------------------------
366 /**
367  *  @brief  
368  *
369  *  @param  [in]
370  */
371 //--------------------------------------------------------------------------
372 void
373 CicoSCSystemConfig::createLayerConf(const ptree::value_type & child,
374                                     CicoSCDisplayConf* displayConf)
375 {
376     ptree layers = child.second.get_child("layers");
377     BOOST_FOREACH (const ptree::value_type& layer, layers) {
378         optional<int> id = optional<int>(-1);
379         optional<string> name;
380         optional<int> type = optional<int>(-1);
381         optional<bool> overlap = optional<bool>(false);
382
383         id = layer.second.get_optional<int>("<xmlattr>.id");
384         if (false == id.is_initialized()) {
385             ICO_ERR("disply.layer.id attr not found");
386             continue;
387         }
388         name = layer.second.get_optional<string>("<xmlattr>.name");
389         if (false == name.is_initialized()) {
390             ICO_ERR("disply.layer.name attr not found");
391             continue;
392         }
393         type = layer.second.get_optional<int>("type");
394         if (false == type.is_initialized()) {
395             ICO_ERR("disply.layer.type element not found");
396             continue;
397         }
398         overlap = layer.second.get_optional<bool>("menuoverlap");
399         if (false == overlap.is_initialized()) {
400             ICO_ERR("disply.layer.overlap element not found");
401             continue;
402         }
403
404         CicoSCLayerConf* layerConf = new CicoSCLayerConf();
405         layerConf->id          = id.get();
406         layerConf->name        = name.get();
407         layerConf->type        = type.get();
408         layerConf->menuoverlap = overlap.get();
409
410         displayConf->layerConfList.push_back(layerConf);
411
412         layerConf->dumpConf();
413     }
414 }
415
416 //--------------------------------------------------------------------------
417 /**
418  *  @brief  
419  *
420  *  @param  [in]
421  */
422 //--------------------------------------------------------------------------
423 void
424 CicoSCSystemConfig::createDisplayZoneConf(const ptree::value_type & child,
425                                           CicoSCDisplayConf* displayConf)
426 {
427     ptree zones = child.second.get_child("zones");
428     BOOST_FOREACH (const ptree::value_type& zone, zones) {
429         optional<int>    id = optional<int>(-1);
430         optional<string> name;
431         optional<string> x;
432         optional<string> y;
433         optional<string> w;
434         optional<string> h;
435         optional<string> overlap;
436
437         id = zone.second.get_optional<int>("<xmlattr>.id");
438         if (false == id.is_initialized()) {
439             ICO_WRN("zone.id.attr not found");
440             continue;
441         }
442         name = zone.second.get_optional<string>("<xmlattr>.name");
443         if (false == name.is_initialized()) {
444             ICO_WRN("zone.name.attr not found");
445             continue;
446         }
447         x = zone.second.get_optional<string>("geometry.<xmlattr>.x");
448         if (false == x.is_initialized()) {
449             ICO_WRN("zone.geometry.x attr not found");
450             continue;
451         }
452         y = zone.second.get_optional<string>("geometry.<xmlattr>.y");
453         if (false == y.is_initialized()) {
454             ICO_WRN("zone.geometry.y attr not found");
455             continue;
456         }
457         w = zone.second.get_optional<string>("geometry.<xmlattr>.w");
458         if (false == w.is_initialized()) {
459             ICO_WRN("zone.geometry.w attr not found");
460             continue;
461         }
462         h = zone.second.get_optional<string>("geometry.<xmlattr>.h");
463         if (false == h.is_initialized()) {
464             ICO_WRN("zone.geometry.h attr not found");
465             continue;
466         }
467         overlap = zone.second.get_optional<string>("overlap");
468         if (false == overlap.is_initialized()) {
469             ICO_WRN("zone.overlap element not found");
470             overlap = optional<string>("");
471         }
472
473         CicoSCDisplayZoneConf* zoneConf = new CicoSCDisplayZoneConf();
474         zoneConf->id         = id.get();
475         zoneConf->name       = name.get();
476         zoneConf->fullname   = displayConf->name + "." + name.get();
477         zoneConf->x          = calcGeometryExpr(x.get(), displayConf);
478         zoneConf->y          = calcGeometryExpr(y.get(), displayConf);
479         zoneConf->w          = calcGeometryExpr(w.get(), displayConf);
480         zoneConf->h          = calcGeometryExpr(h.get(), displayConf);
481         zoneConf->overlapStr = overlap.get();
482         displayConf->zoneConfList.push_back(zoneConf);
483
484         zoneConf->dumpConf();
485     }
486 }
487
488 //--------------------------------------------------------------------------
489 /**
490  *  @brief  
491  *
492  *  @param  [in]
493  */
494 //--------------------------------------------------------------------------
495 void
496 CicoSCSystemConfig::createSoundConfList(const ptree & root)
497 {
498     //<sound>
499     ptree sounds = root.get_child("systemconfig.sounds");
500     BOOST_FOREACH (const ptree::value_type& child, sounds) {
501         optional<int> id = optional<int>(-1);
502         optional<string> name;
503         optional<int> no = optional<int>(-1);
504
505         id = child.second.get_optional<int>("<xmlattr>.id");
506         if (false == id.is_initialized()) {
507             continue;
508         }
509
510         name = child.second.get_optional<string>("<xmlattr>.name");
511         if (false == name.is_initialized()) {
512             continue;
513         }
514
515         no = child.second.get_optional<int>("no");
516         if (false == no.is_initialized()) {
517             continue;
518         }
519
520         CicoSCSoundConf* soundConf = new CicoSCSoundConf();
521         soundConf->id   = id.get();
522         soundConf->name = name.get();
523         soundConf->no   = no.get();
524
525         soundConf->dumpConf();
526
527         createSoundZoneConf(child, soundConf);
528
529         m_soundConfList.push_back(soundConf);
530     }
531 }
532
533 //--------------------------------------------------------------------------
534 /**
535  *  @brief  
536  *
537  *  @param  [in]
538  */
539 //--------------------------------------------------------------------------
540 void
541 CicoSCSystemConfig::createSoundZoneConf(const ptree::value_type & child,
542                                         CicoSCSoundConf* soundConf)
543 {
544     //<sound>
545     //  <zone>
546     //      ...
547     ptree zones = child.second.get_child("zones");
548     BOOST_FOREACH (const ptree::value_type& zone, zones) {
549         optional<int>    id = optional<int>(-1);
550         optional<string> name;
551
552         id = zone.second.get_optional<int>("<xmlattr>.id");
553         if (false == id.is_initialized()) {
554             continue;
555         }
556         name = zone.second.get_optional<string>("<xmlattr>.name");
557         if (false == name.is_initialized()) {
558             continue;
559         }
560
561         CicoSCSoundZoneConf* zoneConf = new CicoSCSoundZoneConf();
562         zoneConf->id       = id.get();
563         zoneConf->name     = name.get();
564         zoneConf->fullname = soundConf->name + "." + name.get();
565         soundConf->zoneConfList.push_back(zoneConf);
566
567         zoneConf->dumpConf();
568     }
569 }
570
571 //--------------------------------------------------------------------------
572 /**
573  *  @brief  
574  *
575  *  @param  [in]
576  */
577 //--------------------------------------------------------------------------
578 void
579 CicoSCSystemConfig::createPortConf(const ptree & root)
580 {
581     // <ports>
582     ptree ports = root.get_child("systemconfig.ports");
583     BOOST_FOREACH (const ptree::value_type& child, ports) {
584         optional<int> id = optional<int>(-1);
585         optional<string> name;
586
587         id = child.second.get_optional<int>("<xmlattr>.id");
588         if (false == id.is_initialized()) {
589             continue;
590         }
591         name = child.second.get_optional<string>("<xmlattr>.name");
592         if (false == name.is_initialized()) {
593             continue;
594         }
595
596         switch (id.get()) {
597         case 0:
598             // TODO
599             m_sysconPort = atoi(child.second.data().c_str());
600             break;
601         case 1:
602             m_soundPluginPort = atoi(child.second.data().c_str());
603             break;
604         default:
605             break;
606         }
607     }
608 }
609
610 //--------------------------------------------------------------------------
611 /**
612  *  @brief  
613  *
614  *  @param  [in]
615  */
616 //--------------------------------------------------------------------------
617 void
618 CicoSCSystemConfig::createCategoryConf(const ptree & root)
619 {
620     //<category>
621     ptree categorys = root.get_child("systemconfig.categorys");
622     BOOST_FOREACH (const ptree::value_type& child, categorys) {
623         optional<int> id = optional<int>(-1);
624         optional<string> name;
625         optional<string> type;
626         optional<string> view;
627         optional<string> sound;
628         optional<string> input;
629         optional<int> priority = optional<int>(-1);
630         optional<int> r_ctrl = optional<int>(-1);
631         
632         id = child.second.get_optional<int>("<xmlattr>.id");
633         if (false == id.is_initialized()) {
634             continue;
635         }
636         name = child.second.get_optional<string>("<xmlattr>.name");
637         if (false == name.is_initialized()) {
638             continue;
639         }
640         type = child.second.get_optional<string>("type");
641         if (false == type.is_initialized()) {
642             continue;
643         }
644         view = child.second.get_optional<string>("view");
645         if (false == view.is_initialized()) {
646             continue;
647         }
648         sound = child.second.get_optional<string>("sound");
649         if (false == sound.is_initialized()) {
650             continue;
651         }
652         input= child.second.get_optional<string>("input");
653         if (false == sound.is_initialized()) {
654             continue;
655         }
656         priority = child.second.get_optional<int>("priority");
657         if (false == priority.is_initialized()) {
658             continue;
659         }
660         r_ctrl = child.second.get_optional<int>("r_ctrl");
661         if (false == r_ctrl.is_initialized()) {
662             continue;
663         }
664
665         CicoSCCategoryConf* categoryConf = new CicoSCCategoryConf();
666         categoryConf->id       = id.get();
667         categoryConf->name     = name.get();
668         categoryConf->type     = type.get();
669         categoryConf->view     = m_categoryTalbe[view.get()];
670         categoryConf->sound    = m_categoryTalbe[sound.get()];
671         categoryConf->input    = m_categoryTalbe[input.get()];
672         categoryConf->priority = priority.get();
673         categoryConf->rctrl    = r_ctrl.get();
674         m_categoryConfList.push_back(categoryConf);
675         categoryConf->dumpConf();
676     }
677 }
678
679 //--------------------------------------------------------------------------
680 /**
681  *  @brief  
682  *
683  *  @param  [in]
684  */
685 //--------------------------------------------------------------------------
686 void
687 CicoSCSystemConfig::createAppKindConf(const ptree & root)
688 {
689     // <appkinds>
690     ptree appkinds = root.get_child("systemconfig.appkinds");
691     BOOST_FOREACH (const ptree::value_type& child, appkinds) {
692         optional<int> id = optional<int>(-1);
693         optional<string> name;
694         optional<string> privilege;
695         optional<int> priority = optional<int>(-1);
696
697         id = child.second.get_optional<int>("<xmlattr>.id");
698         if (false == id.is_initialized()) {
699             continue;
700         }
701
702         name = child.second.get_optional<string>("<xmlattr>.name");
703         if (false == name.is_initialized()) {
704             continue;
705         }
706
707         privilege = child.second.get_optional<string>("privilege");
708         if (false == name.is_initialized()) {
709             continue;
710         }
711
712         priority = child.second.get_optional<int>("priority");
713         if (false == priority.is_initialized()) {
714             continue;
715         }
716
717         CicoSCAppKindConf* appKindConf = new CicoSCAppKindConf();
718         appKindConf->id        = id.get();
719         appKindConf->name      = name.get();
720         appKindConf->privilege = m_privilegeTable[privilege.get()];
721         appKindConf->priority  = priority.get();
722         m_appKindConfList.push_back(appKindConf);
723         appKindConf->dumpConf();
724     }
725 }
726
727 //--------------------------------------------------------------------------
728 /**
729  *  @brief  
730  *
731  *  @param  [in]
732  */
733 //--------------------------------------------------------------------------
734 void
735 CicoSCSystemConfig::createInputDevList(const ptree & root)
736 {
737     //<inputs>
738     ptree inputs = root.get_child("systemconfig.inputs");
739     BOOST_FOREACH (const ptree::value_type& child, inputs) {
740         optional<int> id = optional<int>(-1);
741         optional<string> name;
742
743         id = child.second.get_optional<int>("<xmlattr>.id");
744         if (false == id.is_initialized()) {
745             continue;
746         }
747
748         name = child.second.get_optional<string>("<xmlattr>.name");
749         if (false == name.is_initialized()) {
750             continue;
751         }
752                                                 
753         CicoSCInputDevConf* inputDevConf = new CicoSCInputDevConf();
754         inputDevConf->id   = id.get();
755         inputDevConf->name = name.get();
756         inputDevConf->dumpConf();
757
758         createSwitchList(child, inputDevConf);
759         m_inputDevConfList.push_back(inputDevConf);
760     }
761 }
762
763 //--------------------------------------------------------------------------
764 /**
765  *  @brief  
766  *
767  *  @param  [in]
768  */
769 //--------------------------------------------------------------------------
770 void
771 CicoSCSystemConfig::createSwitchList(const ptree::value_type & child,
772                                      CicoSCInputDevConf* inputDevConf)
773 {
774     ptree switchs = child.second.get_child("switchs");
775     BOOST_FOREACH (const ptree::value_type& zone, switchs) {
776         optional<int> id = optional<int>(-1);
777         optional<string> name;
778         optional<string> appid;
779
780         id = zone.second.get_optional<int>("<xmlattr>.id");
781         if (false == id.is_initialized()) {
782             continue;
783         }
784
785         name = zone.second.get_optional<string>("<xmlattr>.name");
786         if (false == name.is_initialized()) {
787             continue;
788         }
789
790         appid = zone.second.get_optional<string>("<xmlattr>.appid");
791         if (false == appid.is_initialized()) {
792             continue;
793         }
794
795         CicoSCSwitchConf* switchConf = new CicoSCSwitchConf();
796         switchConf->id    = id.get();
797         switchConf->name  = name.get();
798         switchConf->appid = appid.get();
799         switchConf->dumpConf();
800         inputDevConf->switchConfList.push_back(switchConf);
801     }
802 }
803
804 //--------------------------------------------------------------------------
805 /**
806  *  @brief  
807  *
808  *  @param  [in]
809  */
810 //--------------------------------------------------------------------------
811 void
812 CicoSCSystemConfig::createDefaultConf(const ptree & root)
813 {
814     // <default>
815     ptree defaults = root.get_child("systemconfig.default");
816
817     optional<string> node;
818     optional<string> appkind;
819     optional<string> category;
820     optional<string> display;
821     optional<string> layer;
822     optional<string> displayzone;
823     optional<string> sound;
824     optional<string> soundzone;
825     optional<string> inputdev;
826     optional<string> inputsw;
827
828     node = defaults.get_optional<string>("node");
829     if (false == node.is_initialized()) {
830         ICO_WRN("default.node element not found");
831     }
832
833     appkind = defaults.get_optional<string>("appkind");
834     if (false == appkind.is_initialized()) {
835         ICO_WRN("default.appkind element not found");
836     }
837
838     category = defaults.get_optional<string>("category");
839     if (false == category.is_initialized()) {
840         ICO_WRN("default.category element not found");
841     }
842
843     display = defaults.get_optional<string>("display");
844     if (false == display.is_initialized()) {
845         ICO_WRN("default.display element not found");
846     }
847
848     layer = defaults.get_optional<string>("layer");
849     if (false == layer.is_initialized()) {
850         ICO_WRN("default.layer element not found");
851     }
852
853     displayzone = defaults.get_optional<string>("displayzone");
854     if (false == displayzone.is_initialized()) {
855         ICO_WRN("default.displayzone element not found");
856     }
857
858     sound = defaults.get_optional<string>("sound");
859     if (false == sound.is_initialized()) {
860         ICO_WRN("default.sound element not found");
861     }
862
863     soundzone = defaults.get_optional<string>("soundzone");
864     if (false == soundzone.is_initialized()) {
865         ICO_WRN("default.soundzone element not found");
866     }
867
868     inputdev = defaults.get_optional<string>("inputdev");
869     if (false == inputdev.is_initialized()) {
870         ICO_WRN("default.inputdev element not found");
871     }
872
873     inputsw = defaults.get_optional<string>("inputsw");
874     if (false == inputsw.is_initialized()) {
875         ICO_WRN("default.inputdsw element not found");
876     }
877
878     m_defaultConf = new CicoSCDefaultConf();
879
880     m_defaultConf->node        = getNodeIdbyName(node.get());
881     m_defaultConf->appkind     = getAppKindIdbyName(appkind.get());
882     m_defaultConf->category    = getCategoryIdbyName(category.get());
883     m_defaultConf->display     = getDisplayIdbyName(display.get());
884     m_defaultConf->layer       = getLayerIdfbyName(display.get(), layer.get());
885     m_defaultConf->displayzone = getDizplayZoneIdbyName(display.get(),
886                                                       displayzone.get());
887     m_defaultConf->sound       = getSoundIdbyName(sound.get());
888     m_defaultConf->soundzone   = getSoundZoneIdbyName(sound.get(),
889                                                     soundzone.get());
890     m_defaultConf->inputdev    = getInputDevIdbyName(inputdev.get());
891     m_defaultConf->inputsw     = getSwitchIdbyName(inputdev.get(),
892                                                  inputsw.get());
893
894 //TODO
895 #define ICO_SYC_TOP_EVN     (char*)"SYSCON_TOPDIR"
896 #define ICO_SYC_TOP_DIR     (char*)"/usr/apps/org.tizen.ico.system-controller"
897     /* decide top directory in all configurations       */
898     char *topdir = getenv(ICO_SYC_TOP_EVN);
899     if (NULL ==  topdir) {
900         topdir = ICO_SYC_TOP_DIR;
901     }
902     m_defaultConf->topdir = topdir;
903     
904 //TODO
905 #define ICO_SYC_CONFIG_ENV  (char*)"SYSCON_CONFDIR"
906 #define ICO_SYC_CONFIG_DIR  (char*)"res/config"
907     /* decide top directory in configuration file's     */
908     char *confdir = getenv(ICO_SYC_CONFIG_ENV);
909     if (NULL != confdir) {
910         m_defaultConf->confdir = confdir;
911     }
912     else {
913         m_defaultConf->confdir = m_defaultConf->topdir;
914         m_defaultConf->confdir.append("/");
915         m_defaultConf->confdir.append(ICO_SYC_CONFIG_DIR);
916     }
917
918     m_defaultConf->dumpConf();
919 }
920
921 //--------------------------------------------------------------------------
922 /**
923  *  @brief  
924  *
925  *  @param  [in]
926  */
927 //--------------------------------------------------------------------------
928 void
929 CicoSCSystemConfig::createLogConf(const ptree & root)
930 {
931     // <log>
932     // </log>
933     ptree logNode = root.get_child("systemconfig.log");
934     int loglevel  = logNode.get<int>("loglevel");
935     bool logflush = logNode.get<bool>("logflush");
936
937     m_loglevel = loglevel;
938     m_logflush = logflush;
939 }
940
941 //--------------------------------------------------------------------------
942 /**
943  *  @brief  resource config class object create
944  *
945  *  @param  [in]
946  */
947 //--------------------------------------------------------------------------
948 void getArray(ptree& t, vector<int>& vec);
949 static const char* g_resource_cpu = "systemconfig.resource_cpu_control";
950 void
951 CicoSCSystemConfig::createResourceConf(const ptree & root)
952 {
953     m_resourceConf = new CicoSCResourceConf;
954     ptree rc = root.get_child(g_resource_cpu);
955     bool b = false;
956     optional<string> opts = rc.get_optional<string>("do_it");
957     if (true == opts.is_initialized()) {
958         string v = opts.get();
959         if (0 == v.compare("yes")) {
960             b = true;
961         }
962     }
963     m_resourceConf->m_bDoIt = b;
964     if (false == b) {
965         return;
966     }
967
968     string dirnm;
969     optional<string> opts2 = rc.get_optional<string>("ctrl_dir_path");
970     if (true == opts2.is_initialized()) {
971         dirnm = opts2.get();
972     }
973     else {
974         dirnm = "/sys/fs/cgroup/cpu,cpuacct/SCprivate";
975     }
976     m_resourceConf->m_cpuCGRPPath = dirnm;
977
978     opts = rc.get_optional<string>("sampling_wait");
979     if (true == opts.is_initialized()) {
980         m_resourceConf->m_sampling = atoi(opts.get().c_str());
981     }
982
983     opts = rc.get_optional<string>("log");
984     if (true == opts.is_initialized()) {
985         string v = opts.get();
986         if (0 == v.compare("true")) {
987             m_resourceConf->m_bLog = true;
988         }
989     }
990
991     opts = rc.get_optional<string>("retry_cnt");
992     if (true == opts.is_initialized()) {
993         m_resourceConf->m_retryCnt = atoi(opts.get().c_str());
994     }
995
996     opts = rc.get_optional<string>("low_limit_value");
997     if (true == opts.is_initialized()) {
998         m_resourceConf->m_lowLimitVal = atoi(opts.get().c_str());
999     }
1000
1001     opts = rc.get_optional<string>("high_limit_value");
1002     if (true == opts.is_initialized()) {
1003         m_resourceConf->m_highLimitVal = atoi(opts.get().c_str());
1004     }
1005
1006     BOOST_FOREACH(ptree::value_type& child, rc) {
1007         optional<int> id = optional<int>(-1);
1008         optional<string> name;
1009         id = child.second.get_optional<int>("<xmlattr>.id");
1010         if (false == id.is_initialized()) {
1011             continue;
1012         }
1013         name = child.second.get_optional<string>("<xmlattr>.name");
1014         if (false == name.is_initialized()) {
1015             continue;
1016         }
1017         ptree pth = child.second.get_child("hight_array");
1018         ptree ptl = child.second.get_child("low_array");
1019
1020         CicoSCCpuResourceGrp* obj = new CicoSCCpuResourceGrp;
1021         obj->m_id    = id.get();
1022         obj->m_bDoIt = b;
1023         obj->m_grpNm = name.get();
1024         getArray(pth, obj->m_hight);
1025         getArray(ptl, obj->m_low);
1026         m_resourceConf->m_cpuCtrl.push_back(obj);
1027     }
1028     m_resourceConf->dumpConf();
1029 }
1030
1031 //--------------------------------------------------------------------------
1032 /**
1033  *  @brief  user config class object create
1034  *
1035  *  @param  [in]
1036  */
1037 //--------------------------------------------------------------------------
1038 static const char* g_login_user_conf = "systemconfig.login_user";
1039 void
1040 CicoSCSystemConfig::createUserConf(const ptree & root)
1041 {
1042     m_userConf = new CicoSCUserConf;
1043     ptree rc = root.get_child(g_login_user_conf);
1044     optional<string> opts = rc.get_optional<string>("parent_dir");
1045     if (true == opts.is_initialized()) {
1046         string v = opts.get();
1047         if (v.empty()) {
1048             m_userConf->m_parent_dir = v;
1049         }
1050     }
1051     m_userConf->dumpConf();
1052 }
1053
1054 //--------------------------------------------------------------------------
1055 /**
1056  *  @brief  
1057  *
1058  *  @param  [in]
1059  */
1060 //--------------------------------------------------------------------------
1061 int
1062 CicoSCSystemConfig::calcGeometryExpr(const string & expr,
1063                                      CicoSCDisplayConf* conf)
1064 {
1065     int     val = 0;
1066     int     wval;
1067     int     i, j, sign;
1068     char    word[32];
1069
1070     j = 0;
1071     sign = 0;
1072     for (i = 0; ; i++)  {
1073         if (expr[i] == ' ')  continue;
1074         if ((expr[i] == 0) || (expr[i] == '+') || (expr[i] == '-') ||
1075             (expr[i] == '*') || (expr[i] == '-') || (expr[i] == '/'))  {
1076             if (j > 0)  {
1077                 word[j] = 0;
1078                 if ((strcasecmp(word, "dispw") == 0) ||
1079                     (strcasecmp(word, "width") == 0))   {
1080                     wval = conf->width;
1081                 }
1082                 else if ((strcasecmp(word, "disph") == 0) ||
1083                          (strcasecmp(word, "heigh") == 0))  {
1084                     wval = conf->height;
1085                 }
1086                 else    {
1087                     wval = strtol(word, (char **)0, 0);
1088                 }
1089                 j = 0;
1090                 if (sign >= 10) {
1091                     wval = 0 - wval;
1092                 }
1093                 switch (sign % 10)  {
1094                 case 0:                     /* assign       */
1095                     val = wval;
1096                     break;
1097                 case 1:                     /* '+'          */
1098                     val += wval;
1099                     break;
1100                 case 2:                     /* '-'          */
1101                     val -= wval;
1102                     break;
1103                 case 3:                     /* '*'          */
1104                     val *= wval;
1105                     break;
1106                 case 4:                     /* '/'          */
1107                     val /= wval;
1108                     break;
1109                 default:
1110                     break;
1111                 }
1112                 sign = 0;
1113                 if (expr[i] == '+')      sign = 1;
1114                 else if (expr[i] == '-') sign = 2;
1115                 else if (expr[i] == '*') sign = 3;
1116                 else if (expr[i] == '/') sign = 4;
1117                 else                    sign = 0;
1118             }
1119             else    {
1120                 if ((sign > 0) && (expr[i] == '-'))  {
1121                     sign += 10;
1122                 }
1123                 else    {
1124                     if (expr[i] == '+')      sign = 1;
1125                     else if (expr[i] == '-') sign = 2;
1126                     else if (expr[i] == '*') sign = 3;
1127                     else if (expr[i] == '/') sign = 4;
1128                     else                     sign = 0;
1129                 }
1130             }
1131             if (expr[i] == 0)    break;
1132         }
1133         else    {
1134             if (j < ((int)sizeof(word)-1))  {
1135                 word[j++] = expr[i];
1136             }
1137         }
1138     }
1139     return val;
1140 }
1141
1142 //--------------------------------------------------------------------------
1143 /**
1144  *  @brief  
1145  *
1146  *  @param  [in]
1147  */
1148 //--------------------------------------------------------------------------
1149 const CicoSCNodeConf*
1150 CicoSCSystemConfig::findNodeConfbyName(const string & name)
1151 {
1152     vector<CicoSCNodeConf*>::iterator itr;
1153     itr = m_nodeConfList.begin();
1154     for (; itr != m_nodeConfList.end(); ++itr) {
1155         const CicoSCNodeConf* conf = const_cast<CicoSCNodeConf*>(*itr);
1156         if (name == conf->name) {
1157             return conf;
1158         }
1159     }
1160
1161     return NULL;
1162 }
1163
1164 //--------------------------------------------------------------------------
1165 /**
1166  *  @brief  
1167  *
1168  *  @param  [in]
1169  */
1170 //--------------------------------------------------------------------------
1171 const CicoSCDisplayConf*
1172 CicoSCSystemConfig::findDisplayConfbyName(const string & name)
1173 {
1174     vector<CicoSCDisplayConf*>::iterator itr;
1175     itr = m_displayConfList.begin();
1176     for (; itr != m_displayConfList.end(); ++itr) {
1177         const CicoSCDisplayConf* conf = NULL;
1178         conf = const_cast<CicoSCDisplayConf*>(*itr);
1179         if (name == conf->name) {
1180             return conf;
1181         }
1182     }
1183
1184     return NULL;
1185 }
1186
1187 //--------------------------------------------------------------------------
1188 /**
1189  *  @brief  
1190  *
1191  *  @param  [in]
1192  */
1193 //--------------------------------------------------------------------------
1194 const CicoSCLayerConf*
1195 CicoSCSystemConfig::findLayerConfbyName(const string & displayName,
1196                                         const string & layerName)
1197 {
1198     const CicoSCDisplayConf* displayConf = NULL;
1199     displayConf = findDisplayConfbyName(displayName);
1200     if (NULL == displayConf) {
1201         return NULL;
1202     }
1203
1204     vector<CicoSCLayerConf*>::const_iterator itr;
1205     itr = displayConf->layerConfList.begin();
1206     for (; itr != displayConf->layerConfList.end(); ++itr) {
1207         const CicoSCLayerConf* conf = NULL;
1208         conf = const_cast<CicoSCLayerConf*>(*itr);
1209         if (layerName == conf->name) {
1210             return conf;
1211         }
1212     }
1213
1214     return NULL;
1215 }
1216
1217 //--------------------------------------------------------------------------
1218 /**
1219  *  @brief  
1220  *
1221  *  @param  [in]
1222  */
1223 //--------------------------------------------------------------------------
1224 const CicoSCDisplayZoneConf*
1225 CicoSCSystemConfig::findDisplayZoneConfbyName(const string & displayName,
1226                                               const string & zoneName)
1227 {
1228     ICO_DBG("CicoSCSystemConfig::findDisplayZoneConfbyName Enter"
1229             "(displayName=%s zoneNmae=%s)",
1230             displayName.c_str(), zoneName.c_str());
1231
1232     const CicoSCDisplayConf* displayConf = NULL;
1233     displayConf = findDisplayConfbyName(displayName);
1234     if (NULL == displayConf) {
1235         ICO_DBG("CicoSCSystemConfig::findDisplayZoneConfbyName Leave(NULL)");
1236         return NULL;
1237     }
1238
1239     vector<CicoSCDisplayZoneConf*>::const_iterator itr;
1240     itr = displayConf->zoneConfList.begin();
1241     for (; itr != displayConf->zoneConfList.end(); ++itr) {
1242         const CicoSCDisplayZoneConf* conf = NULL;
1243         conf = const_cast<CicoSCDisplayZoneConf*>(*itr);
1244         if (zoneName == conf->name) {
1245             ICO_DBG("CicoSCSystemConfig::findDisplayZoneConfbyName Leave"
1246                     "(0x%08x)", conf);
1247             return conf;
1248         }
1249     }
1250
1251     ICO_DBG("CicoSCSystemConfig::findDisplayZoneConfbyName Leave(NULL)");
1252     return NULL;
1253 }
1254
1255 //--------------------------------------------------------------------------
1256 /**
1257  *  @brief  
1258  *
1259  *  @param  [in]
1260  */
1261 //--------------------------------------------------------------------------
1262 const CicoSCSoundConf*
1263 CicoSCSystemConfig::findSoundConfbyName(const string & name)
1264 {
1265     vector<CicoSCSoundConf*>::iterator itr;
1266     itr = m_soundConfList.begin();
1267     for (; itr != m_soundConfList.end(); ++itr) {
1268         const CicoSCSoundConf* conf = NULL;
1269         conf = const_cast<CicoSCSoundConf*>(*itr);
1270         if (name == conf->name) {
1271             return conf;
1272         }
1273     }
1274
1275     return NULL;
1276 }
1277
1278 //--------------------------------------------------------------------------
1279 /**
1280  *  @brief  
1281  *
1282  *  @param  [in]
1283  */
1284 //--------------------------------------------------------------------------
1285 const CicoSCSoundZoneConf*
1286 CicoSCSystemConfig::findSoundZoneConfbyName(const string & soundName,
1287                                             const string & zoneName)
1288 {
1289     ICO_DBG("CicoSCSystemConfig::findSoundZoneConfbyName Enter"
1290             "(soundName=%s zoneNmae=%s)",
1291             soundName.c_str(), zoneName.c_str());
1292
1293     const CicoSCSoundConf* soundConf = NULL;
1294     soundConf = findSoundConfbyName(soundName);
1295     if (NULL == soundConf) {
1296         return NULL;
1297     }
1298
1299     vector<CicoSCSoundZoneConf*>::const_iterator itr;
1300     itr = soundConf->zoneConfList.begin();
1301     for (; itr != soundConf->zoneConfList.end(); ++itr) {
1302         const CicoSCSoundZoneConf* conf = NULL;
1303         conf = const_cast<CicoSCSoundZoneConf*>(*itr);
1304         if (zoneName == conf->name) {
1305             return conf;
1306         }
1307     }
1308
1309     return NULL;
1310 }
1311
1312 //--------------------------------------------------------------------------
1313 /**
1314  *  @brief  
1315  *
1316  *  @param  [in]
1317  */
1318 //--------------------------------------------------------------------------
1319 const CicoSCInputDevConf*
1320 CicoSCSystemConfig::findInputDevConfbyName(const string & name)
1321 {
1322     vector<CicoSCInputDevConf*>::iterator itr;
1323     itr = m_inputDevConfList.begin();
1324     for (; itr != m_inputDevConfList.end(); ++itr) {
1325         const CicoSCInputDevConf* conf = NULL;
1326         conf = const_cast<CicoSCInputDevConf*>(*itr);
1327         if (name == conf->name) {
1328             return conf;
1329         }
1330     }
1331
1332     return NULL;
1333 }
1334
1335 //--------------------------------------------------------------------------
1336 /**
1337  *  @brief  
1338  *
1339  *  @param  [in]
1340  */
1341 //--------------------------------------------------------------------------
1342 const CicoSCSwitchConf*
1343 CicoSCSystemConfig::findSwitchConfbyName(const string & inputDevName,
1344                                          const string & switchName)
1345 {
1346     const CicoSCInputDevConf* inputDevConf = NULL;
1347     inputDevConf = findInputDevConfbyName(inputDevName);
1348     if (NULL == inputDevConf) {
1349         ICO_WRN("name(%s) input device config not found.",
1350                  inputDevName.c_str());
1351         return NULL;
1352     }
1353
1354     vector<CicoSCSwitchConf*>::const_iterator itr;
1355     itr = inputDevConf->switchConfList.begin();
1356     for (; itr != inputDevConf->switchConfList.end(); ++itr) {
1357         const CicoSCSwitchConf* conf = NULL;
1358         conf = const_cast<CicoSCSwitchConf*>(*itr);
1359         if (switchName == conf->name) {
1360             return conf;
1361         }
1362     }
1363
1364     ICO_WRN("name(%s) switch config not found.", switchName.c_str());
1365     return NULL;
1366 }
1367
1368 //--------------------------------------------------------------------------
1369 /**
1370  *  @brief  
1371  *
1372  *  @param  [in]
1373  */
1374 //--------------------------------------------------------------------------
1375 const CicoSCAppKindConf*
1376 CicoSCSystemConfig::findAppKindConfbyName(const string & name)
1377 {
1378     vector<CicoSCAppKindConf*>::iterator itr;
1379     itr = m_appKindConfList.begin();
1380     for (; itr != m_appKindConfList.end(); ++itr) {
1381         const CicoSCAppKindConf* conf = NULL;
1382         conf = const_cast<CicoSCAppKindConf*>(*itr);
1383         if (name == conf->name) {
1384             return conf;
1385         }
1386     }
1387
1388     return NULL;
1389 }
1390
1391 //--------------------------------------------------------------------------
1392 /**
1393  *  @brief  
1394  *
1395  *  @param  [in]
1396  */
1397 //--------------------------------------------------------------------------
1398 const CicoSCSoundZoneConf*
1399 CicoSCSystemConfig::findSoundZoneConfbyId(int id)
1400 {
1401     vector<CicoSCSoundConf*>::iterator itr;
1402     itr = m_soundConfList.begin();
1403     for (; itr != m_soundConfList.end(); ++itr) {
1404         vector<CicoSCSoundZoneConf*>::iterator itr2;
1405         itr2 = (*itr)->zoneConfList.begin();
1406         for (; itr2 != (*itr)->zoneConfList.end(); ++itr2) {
1407             if (id == (*itr2)->id) {
1408                 return *itr2;
1409             }
1410         }
1411     }
1412
1413     return NULL;
1414 }
1415
1416 //--------------------------------------------------------------------------
1417 /**
1418  *  @brief  
1419  *
1420  *  @param  [in]
1421  */
1422 //--------------------------------------------------------------------------
1423 const CicoSCCategoryConf*
1424 CicoSCSystemConfig::findCategoryConfbyName(const string & name)
1425 {
1426     vector<CicoSCCategoryConf*>::iterator itr;
1427     itr = m_categoryConfList.begin();
1428     for (; itr != m_categoryConfList.end(); ++itr) {
1429         const CicoSCCategoryConf* conf = NULL;
1430         conf = const_cast<CicoSCCategoryConf*>(*itr);
1431         if (name == conf->name) {
1432             //return const_cast<CicoSCCategoryConf*>(itr->pointer);
1433             return conf;
1434         }
1435     }
1436
1437     return NULL;
1438 }
1439
1440 //--------------------------------------------------------------------------
1441 /**
1442  *  @brief  
1443  *
1444  *  @param  [in]
1445  */
1446 //--------------------------------------------------------------------------
1447 const CicoSCCategoryConf*
1448 CicoSCSystemConfig::findCategoryConfbyId(int id)
1449 {
1450     vector<CicoSCCategoryConf*>::iterator itr;
1451     itr = m_categoryConfList.begin();
1452     for (; itr != m_categoryConfList.end(); ++itr) {
1453         const CicoSCCategoryConf* conf = NULL;
1454         conf = const_cast<CicoSCCategoryConf*>(*itr);
1455         if (id == conf->id) {
1456             return conf;
1457         }
1458     }
1459
1460     return NULL;
1461 }
1462
1463 //--------------------------------------------------------------------------
1464 /**
1465  *  @brief  
1466  *
1467  *  @param  [in]
1468  */
1469 //--------------------------------------------------------------------------
1470 const CicoSCAppKindConf *
1471 CicoSCSystemConfig::findAppKindConfbyId(int id)
1472 {
1473     vector<CicoSCAppKindConf*>::iterator itr;
1474     itr = m_appKindConfList.begin();
1475     for (; itr != m_appKindConfList.end(); ++itr) {
1476         if (id == (*itr)->id) {
1477             return *itr;
1478         }
1479     }
1480
1481     return NULL;
1482 }
1483
1484 //--------------------------------------------------------------------------
1485 /**
1486  *  @brief  
1487  *
1488  *  @param  [in]
1489  */
1490 //--------------------------------------------------------------------------
1491 const CicoSCDefaultConf*
1492 CicoSCSystemConfig::getDefaultConf(void)
1493 {
1494     return m_defaultConf;
1495 }
1496
1497 //--------------------------------------------------------------------------
1498 /**
1499  *  @brief  
1500  *
1501  *  @param  [in]
1502  */
1503 //--------------------------------------------------------------------------
1504 int
1505 CicoSCSystemConfig::getNodeIdbyName(const string & name)
1506 {
1507     const CicoSCNodeConf* conf = NULL;
1508     conf = findNodeConfbyName(name);
1509     if (NULL == conf) {
1510         return -1;
1511     }
1512
1513     return conf->id;
1514 }
1515
1516 //--------------------------------------------------------------------------
1517 /**
1518  *  @brief  
1519  *
1520  *  @param  [in]
1521  */
1522 //--------------------------------------------------------------------------
1523 int
1524 CicoSCSystemConfig::getDisplayIdbyName(const string & name)
1525 {
1526     const CicoSCDisplayConf* conf = NULL;
1527     conf = findDisplayConfbyName(name);
1528     if (NULL == conf) {
1529         return -1;
1530     }
1531
1532     return conf->id;
1533 }
1534
1535 //--------------------------------------------------------------------------
1536 /**
1537  *  @brief  
1538  *
1539  *  @param  [in]
1540  */
1541 //--------------------------------------------------------------------------
1542 int
1543 CicoSCSystemConfig::getLayerIdfbyName(const string & displayName,
1544                                       const string & layerName)
1545 {
1546     const CicoSCLayerConf* conf = NULL;
1547     conf = findLayerConfbyName(displayName, layerName);
1548     if (NULL == conf) {
1549         return -1;
1550     }
1551
1552     return conf->id;
1553 }
1554
1555 //--------------------------------------------------------------------------
1556 /**
1557  *  @brief  
1558  *
1559  *  @param  [in]
1560  */
1561 //--------------------------------------------------------------------------
1562 int
1563 CicoSCSystemConfig::getDizplayZoneIdbyName(const string & displayName,
1564                                            const string & zoneName)
1565 {
1566     const CicoSCDisplayZoneConf* conf = NULL;
1567     conf = findDisplayZoneConfbyName(displayName, zoneName);
1568     if (NULL == conf) {
1569         return -1;
1570     }
1571
1572     return conf->id;
1573 }
1574
1575 //--------------------------------------------------------------------------
1576 /**
1577  *  @brief  
1578  *
1579  *  @param  [in]
1580  */
1581 //--------------------------------------------------------------------------
1582 int
1583 CicoSCSystemConfig::getDizplayZoneIdbyFullName(const string & zoneFullName)
1584 {
1585     string::size_type index = zoneFullName.find(".", 0);
1586     if (string::npos == index) {
1587         return -1;
1588     }
1589     string displayName = zoneFullName.substr(0, index);
1590     string zoneName    = zoneFullName.substr(index+1);
1591
1592     const CicoSCDisplayZoneConf* conf = NULL;
1593     conf = findDisplayZoneConfbyName(displayName, zoneName);
1594     if (NULL == conf) {
1595         return -1;
1596     }
1597
1598     return conf->id;
1599 }
1600
1601 //--------------------------------------------------------------------------
1602 /**
1603  *  @brief  
1604  *
1605  *  @param  [in]
1606  */
1607 //--------------------------------------------------------------------------
1608 int
1609 CicoSCSystemConfig::getSoundIdbyName(const string & name)
1610 {
1611     const CicoSCSoundConf* conf = NULL;
1612     conf = findSoundConfbyName(name);
1613     if (NULL == conf) {
1614         return -1;
1615     }
1616
1617     return conf->id;
1618 }
1619
1620 //--------------------------------------------------------------------------
1621 /**
1622  *  @brief  
1623  *
1624  *  @param  [in]
1625  */
1626 //--------------------------------------------------------------------------
1627 int
1628 CicoSCSystemConfig::getSoundZoneIdbyName(const string & soundName,
1629                                          const string & zoneName)
1630 {
1631     const CicoSCSoundZoneConf* conf = NULL;
1632     conf = findSoundZoneConfbyName(soundName, zoneName);
1633     if (NULL == conf) {
1634         return -1;
1635     }
1636
1637     return conf->id;
1638 }
1639
1640 //--------------------------------------------------------------------------
1641 /**
1642  *  @brief  
1643  *
1644  *  @param  [in]
1645  */
1646 //--------------------------------------------------------------------------
1647 int
1648 CicoSCSystemConfig::getSoundZoneIdbyFullName(const string & zoneFullName)
1649 {
1650     string::size_type index = zoneFullName.find(".", 0);
1651     if (string::npos == index) {
1652         return -1;
1653     }
1654     string soundName = zoneFullName.substr(0, index);
1655     string zoneName  = zoneFullName.substr(index+1);
1656
1657     const CicoSCSoundZoneConf* conf = NULL;
1658     conf = findSoundZoneConfbyName(soundName, zoneName);
1659     if (NULL == conf) {
1660         return -1;
1661     }
1662
1663     return conf->id;
1664 }
1665
1666 //--------------------------------------------------------------------------
1667 /**
1668  *  @brief  
1669  *
1670  *  @param  [in]
1671  */
1672 //--------------------------------------------------------------------------
1673 int
1674 CicoSCSystemConfig::getInputDevIdbyName(const string & name)
1675 {
1676     const CicoSCInputDevConf* conf = NULL;
1677     conf = findInputDevConfbyName(name);
1678     if (NULL == conf) {
1679         return -1;
1680     }
1681
1682     return conf->id;
1683 }
1684
1685 //--------------------------------------------------------------------------
1686 /**
1687  *  @brief  
1688  *
1689  *  @param  [in]
1690  */
1691 //--------------------------------------------------------------------------
1692 int
1693 CicoSCSystemConfig::getSwitchIdbyName(const string & inputDevName,
1694                                       const string & switchName)
1695 {
1696     const CicoSCSwitchConf* conf = NULL;
1697     conf = findSwitchConfbyName(inputDevName, switchName);
1698     if (NULL == conf) {
1699         return -1;
1700     }
1701
1702     return conf->id;
1703 }
1704
1705 //--------------------------------------------------------------------------
1706 /**
1707  *  @brief  
1708  *
1709  *  @param  [in]
1710  */
1711 //--------------------------------------------------------------------------
1712 int
1713 CicoSCSystemConfig::getAppKindIdbyName(const string & name)
1714 {
1715     const CicoSCAppKindConf* conf = NULL;
1716     conf = findAppKindConfbyName(name);
1717     if (NULL == conf) {
1718         return -1;
1719     }
1720
1721     return conf->id;
1722 }
1723
1724 //--------------------------------------------------------------------------
1725 /**
1726  *  @brief  
1727  *
1728  *  @param  [in]
1729  */
1730 //--------------------------------------------------------------------------
1731 int
1732 CicoSCSystemConfig::getCategoryIdbyName(const string & name)
1733 {
1734     const CicoSCCategoryConf* conf = NULL;
1735     conf = findCategoryConfbyName(name);
1736     if (NULL == conf) {
1737         return -1;
1738     }
1739
1740     return conf->id;
1741 }
1742
1743 //--------------------------------------------------------------------------
1744 /**
1745  *  @brief  get category config object class
1746  *
1747  *  @param  [in]
1748  */
1749 //--------------------------------------------------------------------------
1750 const CicoSCCategoryConf*
1751 CicoSCSystemConfig::getCategoryObjbyCaategoryID(int id)
1752 {
1753     if (-1 == id) {
1754         return NULL;
1755     }
1756     vector<CicoSCCategoryConf*>::iterator itr;
1757     itr = m_categoryConfList.begin();
1758     for (; itr != m_categoryConfList.end(); ++itr) {
1759         const CicoSCCategoryConf* conf = NULL;
1760         conf = const_cast<CicoSCCategoryConf*>(*itr);
1761         if (id == conf->id) {
1762             //return const_cast<CicoSCCategoryConf*>(itr->pointer);
1763             return conf;
1764         }
1765     }
1766     return NULL;
1767 }
1768
1769 //--------------------------------------------------------------------------
1770 /**
1771  *  @brief  array xml tree to vector<int>
1772  *
1773  *  @param  [in]
1774  */
1775 //--------------------------------------------------------------------------
1776 void getArray(ptree& t, vector<int>& vec)
1777 {
1778     vec.clear();
1779     BOOST_FOREACH (const ptree::value_type& child, t) {
1780         const int value = lexical_cast<int>(child.second.data());
1781         vec.push_back(value);
1782     }
1783 }
1784 // vim:set expandtab ts=4 sw=4: