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