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