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