2 * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
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
10 /*========================================================================*/
12 * @file CicoSystemConfig.cpp
14 * @brief This file implementation of CicoSystemConfig class
16 /*========================================================================*/
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>
24 #include "CicoSystemConfig.h"
27 using namespace boost::property_tree;
28 //==========================================================================
29 // private static variable
30 //==========================================================================
31 CicoSystemConfig* CicoSystemConfig::ms_myInstance = NULL;
33 //--------------------------------------------------------------------------
35 * @brief default constructor
37 //--------------------------------------------------------------------------
38 CicoSystemConfig::CicoSystemConfig()
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;
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;
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;
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;
82 //--------------------------------------------------------------------------
86 //--------------------------------------------------------------------------
87 CicoSystemConfig::~CicoSystemConfig()
92 //--------------------------------------------------------------------------
94 * @brief Get instance of CicoSystemConfig
96 * @return pointer of CicoSystemConfig object
98 //--------------------------------------------------------------------------
100 CicoSystemConfig::getInstance(void)
102 if (NULL == ms_myInstance) {
103 ms_myInstance = new CicoSystemConfig();
105 return ms_myInstance;
108 //--------------------------------------------------------------------------
110 * @brief Get instance of CicoSystemConfig
112 * @param [in] confFile config file name
113 * @return true on success, false on error
115 //--------------------------------------------------------------------------
117 CicoSystemConfig::load(const string & confFile)
121 read_xml(confFile, root);
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 createRoleConf(root);
135 createPositionOSConf(root);
138 ICO_ERR("catch exception!");
144 //--------------------------------------------------------------------------
150 //--------------------------------------------------------------------------
151 const vector<CicoSCNodeConf*>&
152 CicoSystemConfig::getNodeConfList(void) const
154 return m_nodeConfList;
157 //--------------------------------------------------------------------------
163 //--------------------------------------------------------------------------
164 const vector<CicoSCDisplayConf*>&
165 CicoSystemConfig::getDisplayConfList(void) const
167 return m_displayConfList;
170 //--------------------------------------------------------------------------
176 //--------------------------------------------------------------------------
177 const vector<CicoSCSoundConf*>&
178 CicoSystemConfig::getSoundConfList(void) const
180 return m_soundConfList;
183 //--------------------------------------------------------------------------
189 //--------------------------------------------------------------------------
190 const vector<CicoSCInputDevConf*> &
191 CicoSystemConfig::getInputDevConfList(void) const
193 return m_inputDevConfList;
196 //--------------------------------------------------------------------------
202 //--------------------------------------------------------------------------
203 const vector<CicoSCCategoryConf*> &
204 CicoSystemConfig::getCategoryConfList(void) const
206 return m_categoryConfList;
209 //--------------------------------------------------------------------------
215 //--------------------------------------------------------------------------
216 const vector<CicoSCAppKindConf*> &
217 CicoSystemConfig::getAppKindConfList(void) const
219 return m_appKindConfList;
222 //--------------------------------------------------------------------------
228 //--------------------------------------------------------------------------
230 CicoSystemConfig::createNodeConfList(const ptree & root)
233 // if (root.not_found() == root.find("systemconfig")) {
234 // ICO_ERR("nodes element not found");
237 ptree nodes = root.get_child("systemconfig.nodes");
239 BOOST_FOREACH (const ptree::value_type& child, nodes) {
240 if (0 != strcmp(child.first.data(),"node")) {
241 ICO_ERR("unknown element(%s)", child.first.data());
243 optional<int> id = optional<int>(-1);
244 optional<string> name;
245 optional<string> type;
246 optional<string> address;
248 id = child.second.get_optional<int>("<xmlattr>.id");
249 if (false == id.is_initialized()) {
250 ICO_ERR("node.id attr not found");
253 name = child.second.get_optional<string>("<xmlattr>.name");
254 if (false == name.is_initialized()) {
255 ICO_ERR("node.name attr not found");
258 type = child.second.get_optional<string>("type");
259 if (false == type.is_initialized()) {
260 ICO_ERR("node.type element not found");
263 address = child.second.get_optional<string>("ipaddress");
264 if (false == address.is_initialized()) {
265 ICO_ERR("node.address element not found");
269 CicoSCNodeConf* nodeConf = new CicoSCNodeConf;
270 nodeConf->id = id.get();
271 nodeConf->name = name.get();
272 nodeConf->type = m_typeTable[type.get()];
273 nodeConf->address = address.get();
274 m_nodeConfList.push_back(nodeConf);
276 nodeConf->dumpConf();
280 //--------------------------------------------------------------------------
286 //--------------------------------------------------------------------------
288 CicoSystemConfig::createDisplayConfList(const ptree & root)
291 // if (root.not_found() != root.find("systemconfi.displays")) {
292 // ICO_ERR("displays element not found");
297 ptree displays = root.get_child("systemconfig.displays");
298 BOOST_FOREACH (const ptree::value_type& child, displays) {
299 optional<int> id = optional<int>(-1);
300 optional<string> name;
301 optional<string> node;
302 optional<int> no = optional<int>(-1);
303 optional<string> type;
304 optional<int> width = optional<int>(-1);
305 optional<int> height = optional<int>(-1);
307 id = child.second.get_optional<int>("<xmlattr>.id");
308 if (false == id.is_initialized()) {
309 ICO_ERR("display.id attr not found");
312 name = child.second.get_optional<string>("<xmlattr>.name");
313 if (false == name.is_initialized()) {
314 ICO_ERR("display.name attr not found");
317 node = child.second.get_optional<string>("node");
318 if (false == node.is_initialized()) {
319 ICO_ERR("display.node attr not found");
322 no = child.second.get_optional<int>("no");
323 if (false == no.is_initialized()) {
324 ICO_ERR("display.no element not found");
327 type = child.second.get_optional<string>("type");
328 if (false == type.is_initialized()) {
329 ICO_ERR("display.type element not found");
332 width = child.second.get_optional<int>("width");
333 if (false == width.is_initialized()) {
334 ICO_ERR("display.width element not found");
337 height = child.second.get_optional<int>("height");
338 if (false == height.is_initialized()) {
339 ICO_ERR("display.height element not found");
343 CicoSCDisplayConf* displayConf = new CicoSCDisplayConf();
344 displayConf->id = id.get();
345 displayConf->name = name.get();
346 displayConf->node = getNodeIdbyName(node.get());
347 displayConf->no = no.get();
348 displayConf->type = m_displayTypeTable[type.get()];
349 displayConf->width = width.get();
350 displayConf->height = height.get();
352 displayConf->dumpConf();
354 createLayerConf(child, displayConf);
355 createDisplayZoneConf(child, displayConf);
357 m_displayConfList.push_back(displayConf);
362 //--------------------------------------------------------------------------
368 //--------------------------------------------------------------------------
370 CicoSystemConfig::createLayoutConfContainedArea(
371 const ptree::value_type& layout,
372 const optional<int>& layer_id, const optional<string>& layer_name,
373 const optional<int>& layout_id, const optional<string>& layout_name,
374 CicoSCDisplayConf* displayConf)
376 ptree areas = layout.second.get_child("areas");
377 BOOST_FOREACH (const ptree::value_type& area, areas) {
378 optional<int> id = optional<int>(-1);
379 optional<string> name;
380 optional<int> type = optional<int>(-1);
381 optional<bool> overlap = optional<bool>(false);
383 id = area.second.get_optional<int>("<xmlattr>.id");
384 if (false == id.is_initialized()) {
385 ICO_ERR("disply.layer.layout.area.id attr not found");
388 name = area.second.get_optional<string>("<xmlattr>.name");
389 if (false == name.is_initialized()) {
390 ICO_ERR("disply.layer.layout.area.name attr not found");
393 type = area.second.get_optional<int>("type");
394 if (false == type.is_initialized()) {
395 ICO_ERR("disply.layer.layout.area.type element not found");
398 overlap = area.second.get_optional<bool>("menuoverlap");
399 if (false == overlap.is_initialized()) {
400 ICO_ERR("disply.layer.layout.area.overlap element not found");
404 CicoSCLayerConf* layerConf = new CicoSCLayerConf();
405 layerConf->id = layer_id.get();
406 layerConf->name = layer_name.get();
407 layerConf->type = type.get();
408 layerConf->menuoverlap = overlap.get();
409 layerConf->layout_id = layout_id.get();
410 layerConf->layout_name = layout_name.get();
411 layerConf->area_id = id.get();
412 layerConf->area_name = name.get();
414 displayConf->layerConfList.push_back(layerConf);
416 layerConf->dumpConf();
420 //--------------------------------------------------------------------------
426 //--------------------------------------------------------------------------
428 CicoSystemConfig::createLayerConfContainedLayout(
429 const ptree::value_type& layer,
430 const optional<int>& layer_id, const optional<string>& layer_name,
431 CicoSCDisplayConf* displayConf)
433 ptree layouts = layer.second.get_child("layouts");
434 BOOST_FOREACH (const ptree::value_type& layout, layouts) {
435 optional<int> id = optional<int>(-1);
436 optional<string> name;
438 id = layout.second.get_optional<int>("<xmlattr>.id");
439 if (false == id.is_initialized()) {
440 ICO_ERR("disply.layer.layout.id attr not found");
443 name = layer.second.get_optional<string>("<xmlattr>.name");
444 if (false == name.is_initialized()) {
445 ICO_ERR("disply.layer.layout.name attr not found");
448 createLayoutConfContainedArea(layout, layer_id, layer_name, id, name,
453 //--------------------------------------------------------------------------
459 //--------------------------------------------------------------------------
461 CicoSystemConfig::createLayerConf(const ptree::value_type & child,
462 CicoSCDisplayConf* displayConf)
464 ptree layers = child.second.get_child("layers");
465 BOOST_FOREACH (const ptree::value_type& layer, layers) {
466 optional<int> id = optional<int>(-1);
467 optional<string> name;
468 optional<int> type = optional<int>(-1);
469 optional<bool> overlap = optional<bool>(false);
471 id = layer.second.get_optional<int>("<xmlattr>.id");
472 if (false == id.is_initialized()) {
473 ICO_ERR("disply.layer.id attr not found");
476 name = layer.second.get_optional<string>("<xmlattr>.name");
477 if (false == name.is_initialized()) {
478 ICO_ERR("disply.layer.name attr not found");
481 type = layer.second.get_optional<int>("type");
482 if (false == type.is_initialized()) {
483 // ICO_ERR("disply.layer.type element not found");
484 createLayerConfContainedLayout(layer, id, name, displayConf);
487 overlap = layer.second.get_optional<bool>("menuoverlap");
488 if (false == overlap.is_initialized()) {
489 ICO_ERR("disply.layer.overlap element not found");
493 CicoSCLayerConf* layerConf = new CicoSCLayerConf();
494 layerConf->id = id.get();
495 layerConf->name = name.get();
496 layerConf->type = type.get();
497 layerConf->menuoverlap = overlap.get();
499 displayConf->layerConfList.push_back(layerConf);
501 layerConf->dumpConf();
505 //--------------------------------------------------------------------------
511 //--------------------------------------------------------------------------
513 CicoSystemConfig::createDisplayZoneConf(const ptree::value_type & child,
514 CicoSCDisplayConf* displayConf)
516 ptree zones = child.second.get_child("zones");
517 BOOST_FOREACH (const ptree::value_type& zone, zones) {
518 optional<int> id = optional<int>(-1);
519 optional<string> name;
524 optional<bool> fixed;
530 id = zone.second.get_optional<int>("<xmlattr>.id");
531 if (false == id.is_initialized()) {
532 ICO_WRN("zone.id.attr not found");
535 name = zone.second.get_optional<string>("<xmlattr>.name");
536 if (false == name.is_initialized()) {
537 ICO_WRN("zone.name.attr not found");
540 x = zone.second.get_optional<string>("geometry.<xmlattr>.x");
541 if (false == x.is_initialized()) {
542 ICO_WRN("zone.geometry.x attr not found");
545 y = zone.second.get_optional<string>("geometry.<xmlattr>.y");
546 if (false == y.is_initialized()) {
547 ICO_WRN("zone.geometry.y attr not found");
550 w = zone.second.get_optional<string>("geometry.<xmlattr>.w");
551 if (false == w.is_initialized()) {
552 ICO_WRN("zone.geometry.w attr not found");
555 h = zone.second.get_optional<string>("geometry.<xmlattr>.h");
556 if (false == h.is_initialized()) {
557 ICO_WRN("zone.geometry.h attr not found");
560 fixed = zone.second.get_optional<bool>("aspect.<xmlattr>.Fixed");
561 if (false == fixed.is_initialized()) {
562 fixed = optional<bool>(false);
564 l = zone.second.get_optional<bool>("aspect.<xmlattr>.AlignLeft");
565 if (false == l.is_initialized()) {
566 l = optional<bool>(false);
568 r = zone.second.get_optional<bool>("aspect.<xmlattr>.AlignRight");
569 if (false == r.is_initialized()) {
570 r = optional<bool>(false);
572 t = zone.second.get_optional<bool>("aspect.<xmlattr>.AlignTop");
573 if (false == t.is_initialized()) {
574 t = optional<bool>(false);
576 b = zone.second.get_optional<bool>("aspect.<xmlattr>.AlignBottom");
577 if (false == b.is_initialized()) {
578 b = optional<bool>(false);
581 CicoSCDisplayZoneConf* zoneConf = new CicoSCDisplayZoneConf();
582 zoneConf->id = id.get();
583 zoneConf->name = name.get();
584 zoneConf->fullname = displayConf->name + "." + name.get();
585 zoneConf->x = calcGeometryExpr(x.get(), displayConf);
586 zoneConf->y = calcGeometryExpr(y.get(), displayConf);
587 zoneConf->w = calcGeometryExpr(w.get(), displayConf);
588 zoneConf->h = calcGeometryExpr(h.get(), displayConf);
589 zoneConf->aspectFixed = fixed.get();
590 zoneConf->aspectAlignLeft = l.get();
591 zoneConf->aspectAlignRight = r.get();
592 zoneConf->aspectAlignTop = t.get();
593 zoneConf->aspectAlignBottom = b.get();
594 displayConf->zoneConfList.push_back(zoneConf);
596 zoneConf->dumpConf();
600 //--------------------------------------------------------------------------
606 //--------------------------------------------------------------------------
608 CicoSystemConfig::createSoundConfList(const ptree & root)
611 ptree sounds = root.get_child("systemconfig.sounds");
612 BOOST_FOREACH (const ptree::value_type& child, sounds) {
613 optional<int> id = optional<int>(-1);
614 optional<string> name;
615 optional<int> no = optional<int>(-1);
617 id = child.second.get_optional<int>("<xmlattr>.id");
618 if (false == id.is_initialized()) {
622 name = child.second.get_optional<string>("<xmlattr>.name");
623 if (false == name.is_initialized()) {
627 no = child.second.get_optional<int>("no");
628 if (false == no.is_initialized()) {
632 CicoSCSoundConf* soundConf = new CicoSCSoundConf();
633 soundConf->id = id.get();
634 soundConf->name = name.get();
635 soundConf->no = no.get();
637 soundConf->dumpConf();
639 createSoundZoneConf(child, soundConf);
641 m_soundConfList.push_back(soundConf);
645 //--------------------------------------------------------------------------
651 //--------------------------------------------------------------------------
653 CicoSystemConfig::createSoundZoneConf(const ptree::value_type & child,
654 CicoSCSoundConf* soundConf)
659 ptree zones = child.second.get_child("zones");
660 BOOST_FOREACH (const ptree::value_type& zone, zones) {
661 optional<int> id = optional<int>(-1);
662 optional<string> name;
664 id = zone.second.get_optional<int>("<xmlattr>.id");
665 if (false == id.is_initialized()) {
668 name = zone.second.get_optional<string>("<xmlattr>.name");
669 if (false == name.is_initialized()) {
673 CicoSCSoundZoneConf* zoneConf = new CicoSCSoundZoneConf();
674 zoneConf->id = id.get();
675 zoneConf->name = name.get();
676 zoneConf->fullname = soundConf->name + "." + name.get();
677 soundConf->zoneConfList.push_back(zoneConf);
679 zoneConf->dumpConf();
683 //--------------------------------------------------------------------------
689 //--------------------------------------------------------------------------
691 CicoSystemConfig::createPortConf(const ptree & root)
694 ptree ports = root.get_child("systemconfig.ports");
695 BOOST_FOREACH (const ptree::value_type& child, ports) {
696 optional<int> id = optional<int>(-1);
697 optional<string> name;
699 id = child.second.get_optional<int>("<xmlattr>.id");
700 if (false == id.is_initialized()) {
703 name = child.second.get_optional<string>("<xmlattr>.name");
704 if (false == name.is_initialized()) {
711 m_sysconPort = atoi(child.second.data().c_str());
714 m_soundPluginPort = atoi(child.second.data().c_str());
722 //--------------------------------------------------------------------------
728 //--------------------------------------------------------------------------
730 CicoSystemConfig::createCategoryConf(const ptree & root)
733 ptree categorys = root.get_child("systemconfig.categorys");
734 BOOST_FOREACH (const ptree::value_type& child, categorys) {
735 optional<int> id = optional<int>(-1);
736 optional<string> name;
737 optional<string> type;
738 optional<string> view;
739 optional<string> sound;
740 optional<string> input;
741 optional<int> priority = optional<int>(-1);
742 optional<int> r_ctrl = optional<int>(-1);
744 id = child.second.get_optional<int>("<xmlattr>.id");
745 if (false == id.is_initialized()) {
748 name = child.second.get_optional<string>("<xmlattr>.name");
749 if (false == name.is_initialized()) {
752 type = child.second.get_optional<string>("type");
753 if (false == type.is_initialized()) {
756 view = child.second.get_optional<string>("view");
757 if (false == view.is_initialized()) {
760 sound = child.second.get_optional<string>("sound");
761 if (false == sound.is_initialized()) {
764 input= child.second.get_optional<string>("input");
765 if (false == sound.is_initialized()) {
768 priority = child.second.get_optional<int>("priority");
769 if (false == priority.is_initialized()) {
772 r_ctrl = child.second.get_optional<int>("r_ctrl");
773 if (false == r_ctrl.is_initialized()) {
777 CicoSCCategoryConf* categoryConf = new CicoSCCategoryConf();
778 categoryConf->id = id.get();
779 categoryConf->name = name.get();
780 categoryConf->type = type.get();
781 categoryConf->view = m_categoryTalbe[view.get()];
782 categoryConf->sound = m_categoryTalbe[sound.get()];
783 categoryConf->input = m_categoryTalbe[input.get()];
784 categoryConf->priority = priority.get();
785 categoryConf->rctrl = r_ctrl.get();
786 m_categoryConfList.push_back(categoryConf);
787 categoryConf->dumpConf();
791 //--------------------------------------------------------------------------
797 //--------------------------------------------------------------------------
799 CicoSystemConfig::createAppKindConf(const ptree & root)
802 ptree appkinds = root.get_child("systemconfig.appkinds");
803 BOOST_FOREACH (const ptree::value_type& child, appkinds) {
804 optional<int> id = optional<int>(-1);
805 optional<string> name;
806 optional<string> privilege;
807 optional<int> priority = optional<int>(-1);
809 id = child.second.get_optional<int>("<xmlattr>.id");
810 if (false == id.is_initialized()) {
814 name = child.second.get_optional<string>("<xmlattr>.name");
815 if (false == name.is_initialized()) {
819 privilege = child.second.get_optional<string>("privilege");
820 if (false == name.is_initialized()) {
824 priority = child.second.get_optional<int>("priority");
825 if (false == priority.is_initialized()) {
829 CicoSCAppKindConf* appKindConf = new CicoSCAppKindConf();
830 appKindConf->id = id.get();
831 appKindConf->name = name.get();
832 appKindConf->privilege = m_privilegeTable[privilege.get()];
833 appKindConf->priority = priority.get();
834 m_appKindConfList.push_back(appKindConf);
835 appKindConf->dumpConf();
839 //--------------------------------------------------------------------------
845 //--------------------------------------------------------------------------
847 CicoSystemConfig::createInputDevList(const ptree & root)
850 ptree inputs = root.get_child("systemconfig.inputs");
851 BOOST_FOREACH (const ptree::value_type& child, inputs) {
852 optional<int> id = optional<int>(-1);
853 optional<string> name;
855 id = child.second.get_optional<int>("<xmlattr>.id");
856 if (false == id.is_initialized()) {
860 name = child.second.get_optional<string>("<xmlattr>.name");
861 if (false == name.is_initialized()) {
865 CicoSCInputDevConf* inputDevConf = new CicoSCInputDevConf();
866 inputDevConf->id = id.get();
867 inputDevConf->name = name.get();
868 inputDevConf->dumpConf();
870 createSwitchList(child, inputDevConf);
871 m_inputDevConfList.push_back(inputDevConf);
875 //--------------------------------------------------------------------------
881 //--------------------------------------------------------------------------
883 CicoSystemConfig::createSwitchList(const ptree::value_type & child,
884 CicoSCInputDevConf* inputDevConf)
886 ptree switchs = child.second.get_child("switchs");
887 BOOST_FOREACH (const ptree::value_type& zone, switchs) {
888 optional<int> id = optional<int>(-1);
889 optional<string> name;
890 optional<string> appid;
892 id = zone.second.get_optional<int>("<xmlattr>.id");
893 if (false == id.is_initialized()) {
897 name = zone.second.get_optional<string>("<xmlattr>.name");
898 if (false == name.is_initialized()) {
902 appid = zone.second.get_optional<string>("<xmlattr>.appid");
903 if (false == appid.is_initialized()) {
907 CicoSCSwitchConf* switchConf = new CicoSCSwitchConf();
908 switchConf->id = id.get();
909 switchConf->name = name.get();
910 switchConf->appid = appid.get();
911 switchConf->dumpConf();
912 inputDevConf->switchConfList.push_back(switchConf);
916 //--------------------------------------------------------------------------
922 //--------------------------------------------------------------------------
924 CicoSystemConfig::createDefaultConf(const ptree & root)
927 ptree defaults = root.get_child("systemconfig.default");
929 optional<string> node;
930 optional<string> appkind;
931 optional<string> category;
932 optional<string> display;
933 optional<string> layer;
934 optional<string> displayzone;
935 optional<string> sound;
936 optional<string> soundzone;
937 optional<string> inputdev;
938 optional<string> inputsw;
940 node = defaults.get_optional<string>("node");
941 if (false == node.is_initialized()) {
942 ICO_WRN("default.node element not found");
945 appkind = defaults.get_optional<string>("appkind");
946 if (false == appkind.is_initialized()) {
947 ICO_WRN("default.appkind element not found");
950 category = defaults.get_optional<string>("category");
951 if (false == category.is_initialized()) {
952 ICO_WRN("default.category element not found");
955 display = defaults.get_optional<string>("display");
956 if (false == display.is_initialized()) {
957 ICO_WRN("default.display element not found");
960 layer = defaults.get_optional<string>("layer");
961 if (false == layer.is_initialized()) {
962 ICO_WRN("default.layer element not found");
965 displayzone = defaults.get_optional<string>("displayzone");
966 if (false == displayzone.is_initialized()) {
967 ICO_WRN("default.displayzone element not found");
970 sound = defaults.get_optional<string>("sound");
971 if (false == sound.is_initialized()) {
972 ICO_WRN("default.sound element not found");
975 soundzone = defaults.get_optional<string>("soundzone");
976 if (false == soundzone.is_initialized()) {
977 ICO_WRN("default.soundzone element not found");
980 inputdev = defaults.get_optional<string>("inputdev");
981 if (false == inputdev.is_initialized()) {
982 ICO_WRN("default.inputdev element not found");
985 inputsw = defaults.get_optional<string>("inputsw");
986 if (false == inputsw.is_initialized()) {
987 ICO_WRN("default.inputdsw element not found");
990 m_defaultConf = new CicoSCDefaultConf();
992 m_defaultConf->node = getNodeIdbyName(node.get());
993 m_defaultConf->appkind = getAppKindIdbyName(appkind.get());
994 m_defaultConf->category = getCategoryIdbyName(category.get());
995 m_defaultConf->display = getDisplayIdbyName(display.get());
996 m_defaultConf->layer = getLayerIdfbyName(display.get(), layer.get());
997 m_defaultConf->displayzone = getDizplayZoneIdbyName(display.get(),
999 m_defaultConf->sound = getSoundIdbyName(sound.get());
1000 m_defaultConf->soundzone = getSoundZoneIdbyName(sound.get(),
1002 m_defaultConf->inputdev = getInputDevIdbyName(inputdev.get());
1003 m_defaultConf->inputsw = getSwitchIdbyName(inputdev.get(),
1007 #define ICO_SYC_TOP_EVN (char*)"SYSCON_TOPDIR"
1008 #define ICO_SYC_TOP_DIR (char*)"/usr/apps/org.tizen.ico.system-controller"
1009 /* decide top directory in all configurations */
1010 char *topdir = getenv(ICO_SYC_TOP_EVN);
1011 if (NULL == topdir) {
1012 topdir = ICO_SYC_TOP_DIR;
1014 m_defaultConf->topdir = topdir;
1017 #define ICO_SYC_CONFIG_ENV (char*)"SYSCON_CONFDIR"
1018 #define ICO_SYC_CONFIG_DIR (char*)"res/config"
1019 /* decide top directory in configuration file's */
1020 char *confdir = getenv(ICO_SYC_CONFIG_ENV);
1021 if (NULL != confdir) {
1022 m_defaultConf->confdir = confdir;
1025 m_defaultConf->confdir = m_defaultConf->topdir;
1026 m_defaultConf->confdir.append("/");
1027 m_defaultConf->confdir.append(ICO_SYC_CONFIG_DIR);
1030 m_defaultConf->dumpConf();
1033 //--------------------------------------------------------------------------
1035 * @brief resource config class object create
1039 //--------------------------------------------------------------------------
1040 void getArray(ptree& t, vector<int>& vec);
1041 static const char* g_resource_cpu = "systemconfig.resource_cpu_control";
1043 CicoSystemConfig::createResourceConf(const ptree & root)
1045 m_resourceConf = new CicoSCResourceConf;
1046 ptree rc = root.get_child(g_resource_cpu);
1053 if ((CicoSCDefaultConf*)0 != m_defaultConf) {
1054 fPath = m_defaultConf->confdir;
1055 fPath += string("/");
1056 fPath += string("system_sysres.json");
1059 memset(&buff, 0, sizeof(buff));
1060 if (0 == stat(fPath.c_str(), &buff)) {
1061 read_json(fPath.c_str(), lcl_pt);
1067 if (boost::optional<std::string> function =
1068 lcl_pt.get_optional<std::string>("function")) {
1069 string v = function.get();
1070 if (0 == v.compare("yes")) {
1073 else if (0 == v.compare("app")) {
1079 ICO_WRN("NG json file(%s)", fPath.c_str());
1085 optional<string> opts = rc.get_optional<string>("do_it");
1086 if (true == opts.is_initialized()) {
1087 string v = opts.get();
1088 if (0 == v.compare("yes")) {
1091 else if (0 == v.compare("app")) {
1096 m_resourceConf->m_bDoIt = b;
1097 m_resourceConf->m_bDoItApp = bApp;
1102 if (boost::optional<std::string> ctrl_dir_path =
1103 lcl_pt.get_optional<std::string>("ctrl_dir_path")) {
1104 dirnm = ctrl_dir_path.get();
1108 ICO_WRN("NG json file(%s)", fPath.c_str());
1112 optional<string> opts2 = rc.get_optional<string>("ctrl_dir_path");
1113 if (true == opts2.is_initialized()) {
1114 dirnm = opts2.get();
1117 if (true == dirnm.empty()) {
1118 dirnm = "/sys/fs/cgroup/cpu,cpuacct/SCprivate";
1120 m_resourceConf->m_cpuCGRPPath = dirnm;
1124 optional<string> opts;
1126 opts = rc.get_optional<string>("sampling_wait");
1127 if (true == opts.is_initialized()) {
1128 m_resourceConf->m_sampling = atoi(opts.get().c_str());
1131 opts = rc.get_optional<string>("log");
1132 if (true == opts.is_initialized()) {
1133 string v = opts.get();
1134 if (0 == v.compare("true")) {
1135 m_resourceConf->m_bLog = true;
1139 opts = rc.get_optional<string>("retry_cnt");
1140 if (true == opts.is_initialized()) {
1141 m_resourceConf->m_retryCnt = atoi(opts.get().c_str());
1144 opts = rc.get_optional<string>("low_limit_value");
1145 if (true == opts.is_initialized()) {
1146 m_resourceConf->m_lowLimitVal = atoi(opts.get().c_str());
1149 opts = rc.get_optional<string>("high_limit_value");
1150 if (true == opts.is_initialized()) {
1151 m_resourceConf->m_highLimitVal = atoi(opts.get().c_str());
1154 BOOST_FOREACH(ptree::value_type& child, rc) {
1155 optional<int> id = optional<int>(-1);
1156 optional<string> name;
1157 id = child.second.get_optional<int>("<xmlattr>.id");
1158 if (false == id.is_initialized()) {
1161 name = child.second.get_optional<string>("<xmlattr>.name");
1162 if (false == name.is_initialized()) {
1165 ptree pth = child.second.get_child("hight_array");
1166 ptree ptl = child.second.get_child("low_array");
1168 CicoSCCpuResourceGrp* obj = new CicoSCCpuResourceGrp;
1169 obj->m_id = id.get();
1171 obj->m_grpNm = name.get();
1172 getArray(pth, obj->m_hight);
1173 getArray(ptl, obj->m_low);
1174 m_resourceConf->m_cpuCtrl.push_back(obj);
1176 m_resourceConf->dumpConf();
1179 //--------------------------------------------------------------------------
1181 * @brief vechicle information config class object create
1185 //--------------------------------------------------------------------------
1187 CicoSystemConfig::createVehicleInfoConf(const ptree & root)
1189 m_vehicleInfoConf = new CicoSCVehicleInfoConf();
1191 ptree child = root.get_child("systemconfig.vehicle_info");
1193 optional<int> retryCnt;
1194 optional<int> waitTime;
1196 retryCnt = child.get_optional<int>("retryCnt");
1197 if (false == retryCnt.is_initialized()) {
1198 ICO_WRN("vehicle_info.retryCnt element not found");
1199 retryCnt = optional<int>(0);
1202 waitTime = child.get_optional<int>("waitTime");
1203 if (false == waitTime.is_initialized()) {
1204 ICO_WRN("vehicle_info.waitTime element not found");
1205 waitTime = optional<int>(0);
1208 m_vehicleInfoConf->retryCnt = retryCnt.get();
1209 m_vehicleInfoConf->waitTime = waitTime.get();
1211 BOOST_FOREACH (const ptree::value_type& vinfo, child) {
1213 optional<string> name;
1214 optional<string> objname;
1215 optional<string> property;
1217 optional<string> type;
1219 id = vinfo.second.get_optional<int>("<xmlattr>.id");
1220 if (false == id.is_initialized()) {
1224 name = vinfo.second.get_optional<string>("<xmlattr>.name");
1225 if (false == name.is_initialized()) {
1229 property = vinfo.second.get_optional<string>("property");
1230 if (false == property.is_initialized()) {
1234 objname = vinfo.second.get_optional<string>("objname");
1235 if (false == objname.is_initialized()) {
1239 zone = vinfo.second.get_optional<int>("zone");
1240 if (false == zone.is_initialized()) {
1244 type = vinfo.second.get_optional<string>("type");
1245 if (false == type.is_initialized()) {
1249 CicoSCVIPropertyConf* viprop = new CicoSCVIPropertyConf();
1250 viprop->id = id.get();
1251 viprop->name = name.get();
1252 viprop->objname = objname.get();
1253 viprop->property = property.get();
1254 viprop->zone = zone.get();
1255 viprop->typestr = type.get();
1256 viprop->type = viprop->typeStrToInt(viprop->typestr);
1257 m_vehicleInfoConf->properties[id.get()] = viprop;
1260 m_vehicleInfoConf->dumpConf();
1263 //--------------------------------------------------------------------------
1265 * @brief user config class object create
1269 //--------------------------------------------------------------------------
1270 static const char* g_login_user_conf = "systemconfig.login_user";
1272 CicoSystemConfig::createUserConf(const ptree & root)
1274 m_userConf = new CicoSCUserConf;
1275 ptree rc = root.get_child(g_login_user_conf);
1276 optional<string> opts = rc.get_optional<string>("parent_dir");
1277 if (true == opts.is_initialized()) {
1278 string v = opts.get();
1280 m_userConf->m_parent_dir = v;
1283 m_userConf->dumpConf();
1286 //--------------------------------------------------------------------------
1292 //--------------------------------------------------------------------------
1294 CicoSystemConfig::calcGeometryExpr(const string & expr,
1295 CicoSCDisplayConf* conf)
1304 for (i = 0; ; i++) {
1305 if (expr[i] == ' ') continue;
1306 if ((expr[i] == 0) || (expr[i] == '+') || (expr[i] == '-') ||
1307 (expr[i] == '*') || (expr[i] == '-') || (expr[i] == '/')) {
1310 if ((strcasecmp(word, "dispw") == 0) ||
1311 (strcasecmp(word, "width") == 0)) {
1314 else if ((strcasecmp(word, "disph") == 0) ||
1315 (strcasecmp(word, "heigh") == 0)) {
1316 wval = conf->height;
1319 wval = strtol(word, (char **)0, 0);
1325 switch (sign % 10) {
1326 case 0: /* assign */
1345 if (expr[i] == '+') sign = 1;
1346 else if (expr[i] == '-') sign = 2;
1347 else if (expr[i] == '*') sign = 3;
1348 else if (expr[i] == '/') sign = 4;
1352 if ((sign > 0) && (expr[i] == '-')) {
1356 if (expr[i] == '+') sign = 1;
1357 else if (expr[i] == '-') sign = 2;
1358 else if (expr[i] == '*') sign = 3;
1359 else if (expr[i] == '/') sign = 4;
1363 if (expr[i] == 0) break;
1366 if (j < ((int)sizeof(word)-1)) {
1367 word[j++] = expr[i];
1374 //--------------------------------------------------------------------------
1380 //--------------------------------------------------------------------------
1381 const CicoSCNodeConf*
1382 CicoSystemConfig::findNodeConfbyName(const string & name)
1384 vector<CicoSCNodeConf*>::const_iterator itr;
1385 itr = m_nodeConfList.begin();
1386 for (; itr != m_nodeConfList.end(); ++itr) {
1387 const CicoSCNodeConf* conf = (*itr);
1388 if (name == conf->name) {
1396 //--------------------------------------------------------------------------
1402 //--------------------------------------------------------------------------
1403 const CicoSCDisplayConf*
1404 CicoSystemConfig::findDisplayConfbyName(const string & name)
1406 vector<CicoSCDisplayConf*>::const_iterator itr;
1407 itr = m_displayConfList.begin();
1408 for (; itr != m_displayConfList.end(); ++itr) {
1409 const CicoSCDisplayConf* conf = (*itr);
1410 if (name == conf->name) {
1418 //--------------------------------------------------------------------------
1424 //--------------------------------------------------------------------------
1425 const CicoSCDisplayConf*
1426 CicoSystemConfig::findDisplayConfbyName(const string& ECU, const string& name)
1428 int nodeId = getNodeIdbyName(ECU);
1429 vector<CicoSCDisplayConf*>::const_iterator itr;
1430 itr = m_displayConfList.begin();
1431 for (; itr != m_displayConfList.end(); ++itr) {
1432 const CicoSCDisplayConf* conf = (*itr);
1433 if ((name == conf->name)&&(nodeId == conf->node)) {
1441 //--------------------------------------------------------------------------
1447 //--------------------------------------------------------------------------
1448 const CicoSCDisplayConf*
1449 CicoSystemConfig::findDisplayConfbyId(int id)
1451 vector<CicoSCDisplayConf*>::const_iterator itr;
1452 itr = m_displayConfList.begin();
1453 for (; itr != m_displayConfList.end(); ++itr) {
1454 const CicoSCDisplayConf* conf = (*itr);
1455 if (id == conf->id) {
1462 //--------------------------------------------------------------------------
1468 //--------------------------------------------------------------------------
1469 const CicoSCLayerConf*
1470 CicoSystemConfig::findLayerConfbyName(const string & displayName,
1471 const string & layerName)
1473 const CicoSCDisplayConf* displayConf = NULL;
1474 displayConf = findDisplayConfbyName(displayName);
1475 if (NULL == displayConf) {
1479 vector<CicoSCLayerConf*>::const_iterator itr;
1480 itr = displayConf->layerConfList.begin();
1481 for (; itr != displayConf->layerConfList.end(); ++itr) {
1482 const CicoSCLayerConf* conf = (*itr);
1483 // if (layerName == conf->name) {
1484 if ((layerName == conf->name) && (-1 == conf->layout_id)) {
1492 //--------------------------------------------------------------------------
1498 //--------------------------------------------------------------------------
1499 const CicoSCLayerConf*
1500 CicoSystemConfig::findLayerConfbyName(const string& ECU,
1501 const string& display,
1502 const string& layer,
1503 const string& layout,
1506 const CicoSCDisplayConf* displayConf = NULL;
1507 displayConf = findDisplayConfbyName(ECU, display);
1508 if (NULL == displayConf) {
1512 vector<CicoSCLayerConf*>::const_iterator itr;
1513 itr = displayConf->layerConfList.begin();
1514 for (; itr != displayConf->layerConfList.end(); ++itr) {
1515 const CicoSCLayerConf* conf = (*itr);
1516 if ((layer == conf->name)&&(layout == conf->layout_name)&&
1517 (area == conf->area_name)) {
1525 //--------------------------------------------------------------------------
1531 //--------------------------------------------------------------------------
1532 const CicoSCLayerConf*
1533 CicoSystemConfig::findLayerConfbyIdx(int displayid, int idx)
1535 const CicoSCDisplayConf* displayConf = NULL;
1536 displayConf = findDisplayConfbyId(displayid);
1537 if (NULL == displayConf) {
1541 vector<CicoSCLayerConf*>::const_iterator itr;
1542 itr = displayConf->layerConfList.begin();
1543 for (; itr != displayConf->layerConfList.end(); ++itr) {
1544 const CicoSCLayerConf* conf = (*itr);
1553 //--------------------------------------------------------------------------
1559 //--------------------------------------------------------------------------
1560 const CicoSCDisplayZoneConf*
1561 CicoSystemConfig::findDisplayZoneConfbyName(const string & displayName,
1562 const string & zoneName)
1564 // ICO_TRA("CicoSystemConfig::findDisplayZoneConfbyName Enter"
1565 // "(displayName=%s zoneNmae=%s)",
1566 // displayName.c_str(), zoneName.c_str());
1568 const CicoSCDisplayConf* displayConf = NULL;
1569 displayConf = findDisplayConfbyName(displayName);
1570 if (NULL == displayConf) {
1571 // ICO_TRA("CicoSystemConfig::findDisplayZoneConfbyName Leave(NULL)");
1575 vector<CicoSCDisplayZoneConf*>::const_iterator itr;
1576 itr = displayConf->zoneConfList.begin();
1577 for (; itr != displayConf->zoneConfList.end(); ++itr) {
1578 const CicoSCDisplayZoneConf* conf = (*itr);
1579 if (zoneName == conf->name) {
1580 // ICO_TRA("CicoSystemConfig::findDisplayZoneConfbyName Leave"
1581 // "(0x%08x)", conf);
1586 // ICO_TRA("CicoSystemConfig::findDisplayZoneConfbyName Leave(NULL)");
1590 //--------------------------------------------------------------------------
1596 //--------------------------------------------------------------------------
1597 const CicoSCSoundConf*
1598 CicoSystemConfig::findSoundConfbyName(const string & name)
1600 vector<CicoSCSoundConf*>::const_iterator itr;
1601 itr = m_soundConfList.begin();
1602 for (; itr != m_soundConfList.end(); ++itr) {
1603 const CicoSCSoundConf* conf = (*itr);
1604 if (name == conf->name) {
1612 //--------------------------------------------------------------------------
1618 //--------------------------------------------------------------------------
1619 const CicoSCSoundZoneConf*
1620 CicoSystemConfig::findSoundZoneConfbyName(const string & soundName,
1621 const string & zoneName)
1623 // ICO_TRA("CicoSystemConfig::findSoundZoneConfbyName Enter"
1624 // "(soundName=%s zoneNmae=%s)",
1625 // soundName.c_str(), zoneName.c_str());
1627 const CicoSCSoundConf* soundConf = NULL;
1628 soundConf = findSoundConfbyName(soundName);
1629 if (NULL == soundConf) {
1633 vector<CicoSCSoundZoneConf*>::const_iterator itr;
1634 itr = soundConf->zoneConfList.begin();
1635 for (; itr != soundConf->zoneConfList.end(); ++itr) {
1636 const CicoSCSoundZoneConf* conf = (*itr);
1637 if (zoneName == conf->name) {
1645 //--------------------------------------------------------------------------
1651 //--------------------------------------------------------------------------
1652 const CicoSCInputDevConf*
1653 CicoSystemConfig::findInputDevConfbyName(const string & name)
1655 vector<CicoSCInputDevConf*>::const_iterator itr;
1656 itr = m_inputDevConfList.begin();
1657 for (; itr != m_inputDevConfList.end(); ++itr) {
1658 const CicoSCInputDevConf* conf = (*itr);
1659 if (name == conf->name) {
1667 //--------------------------------------------------------------------------
1673 //--------------------------------------------------------------------------
1674 const CicoSCSwitchConf*
1675 CicoSystemConfig::findSwitchConfbyName(const string & inputDevName,
1676 const string & switchName)
1678 const CicoSCInputDevConf* inputDevConf = NULL;
1679 inputDevConf = findInputDevConfbyName(inputDevName);
1680 if (NULL == inputDevConf) {
1681 ICO_WRN("name(%s) input device config not found.",
1682 inputDevName.c_str());
1686 vector<CicoSCSwitchConf*>::const_iterator itr;
1687 itr = inputDevConf->switchConfList.begin();
1688 for (; itr != inputDevConf->switchConfList.end(); ++itr) {
1689 const CicoSCSwitchConf* conf = (*itr);
1690 if (switchName == conf->name) {
1695 ICO_WRN("name(%s) switch config not found.", switchName.c_str());
1699 //--------------------------------------------------------------------------
1705 //--------------------------------------------------------------------------
1706 const CicoSCAppKindConf*
1707 CicoSystemConfig::findAppKindConfbyName(const string & name)
1709 vector<CicoSCAppKindConf*>::const_iterator itr;
1710 itr = m_appKindConfList.begin();
1711 for (; itr != m_appKindConfList.end(); ++itr) {
1712 const CicoSCAppKindConf* conf = (*itr);
1713 if (name == conf->name) {
1721 //--------------------------------------------------------------------------
1727 //--------------------------------------------------------------------------
1728 const CicoSCDisplayZoneConf*
1729 CicoSystemConfig::findDisplayZoneConfbyId(int id)
1731 vector<CicoSCDisplayConf*>::const_iterator itr;
1732 itr = m_displayConfList.begin();
1733 for (; itr != m_displayConfList.end(); ++itr) {
1734 vector<CicoSCDisplayZoneConf*>::const_iterator itr2;
1735 itr2 = (*itr)->zoneConfList.begin();
1736 for (; itr2 != (*itr)->zoneConfList.end(); ++itr2) {
1737 if (id == (*itr2)->id) {
1746 //--------------------------------------------------------------------------
1752 //--------------------------------------------------------------------------
1753 const CicoSCSoundZoneConf*
1754 CicoSystemConfig::findSoundZoneConfbyId(int id)
1756 vector<CicoSCSoundConf*>::const_iterator itr;
1757 itr = m_soundConfList.begin();
1758 for (; itr != m_soundConfList.end(); ++itr) {
1759 vector<CicoSCSoundZoneConf*>::const_iterator itr2;
1760 itr2 = (*itr)->zoneConfList.begin();
1761 for (; itr2 != (*itr)->zoneConfList.end(); ++itr2) {
1762 if (id == (*itr2)->id) {
1771 //--------------------------------------------------------------------------
1777 //--------------------------------------------------------------------------
1778 const CicoSCCategoryConf*
1779 CicoSystemConfig::findCategoryConfbyName(const string & name)
1781 vector<CicoSCCategoryConf*>::const_iterator itr;
1782 itr = m_categoryConfList.begin();
1783 for (; itr != m_categoryConfList.end(); ++itr) {
1784 const CicoSCCategoryConf* conf = (*itr);
1785 if (name == conf->name) {
1786 //return const_cast<CicoSCCategoryConf*>(itr->pointer);
1794 //--------------------------------------------------------------------------
1800 //--------------------------------------------------------------------------
1801 const CicoSCCategoryConf*
1802 CicoSystemConfig::findCategoryConfbyId(int id)
1804 vector<CicoSCCategoryConf*>::const_iterator itr;
1805 itr = m_categoryConfList.begin();
1806 for (; itr != m_categoryConfList.end(); ++itr) {
1807 const CicoSCCategoryConf* conf = (*itr);
1808 if (id == conf->id) {
1816 //--------------------------------------------------------------------------
1822 //--------------------------------------------------------------------------
1823 const CicoSCAppKindConf *
1824 CicoSystemConfig::findAppKindConfbyId(int id)
1826 vector<CicoSCAppKindConf*>::const_iterator itr;
1827 itr = m_appKindConfList.begin();
1828 for (; itr != m_appKindConfList.end(); ++itr) {
1829 if (id == (*itr)->id) {
1837 //--------------------------------------------------------------------------
1843 //--------------------------------------------------------------------------
1844 const CicoSCDefaultConf*
1845 CicoSystemConfig::getDefaultConf(void)
1847 return m_defaultConf;
1850 //--------------------------------------------------------------------------
1856 //--------------------------------------------------------------------------
1858 CicoSystemConfig::getNodeIdbyName(const string & name)
1860 const CicoSCNodeConf* conf = NULL;
1861 conf = findNodeConfbyName(name);
1869 //--------------------------------------------------------------------------
1875 //--------------------------------------------------------------------------
1877 CicoSystemConfig::getDisplayIdbyName(const string & name)
1879 const CicoSCDisplayConf* conf = NULL;
1880 conf = findDisplayConfbyName(name);
1888 //--------------------------------------------------------------------------
1894 //--------------------------------------------------------------------------
1896 CicoSystemConfig::getDisplayIdbyNo(int no)
1898 vector<CicoSCDisplayConf*>::const_iterator itr;
1899 itr = m_displayConfList.begin();
1900 for (; itr != m_displayConfList.end(); ++itr) {
1901 const CicoSCDisplayConf* conf = (*itr);
1902 if (no == conf->no) {
1909 //--------------------------------------------------------------------------
1915 //--------------------------------------------------------------------------
1917 CicoSystemConfig::getDisplayIdbyType(int type)
1919 vector<CicoSCDisplayConf*>::const_iterator itr;
1920 itr = m_displayConfList.begin();
1921 for (; itr != m_displayConfList.end(); ++itr) {
1922 const CicoSCDisplayConf* conf = (*itr);
1923 if (type == conf->type) {
1930 //--------------------------------------------------------------------------
1936 //--------------------------------------------------------------------------
1938 CicoSystemConfig::getNumberofDisplay(void)
1943 //--------------------------------------------------------------------------
1949 //--------------------------------------------------------------------------
1951 CicoSystemConfig::getLayerIdfbyName(const string & displayName,
1952 const string & layerName)
1954 const CicoSCLayerConf* conf = NULL;
1955 conf = findLayerConfbyName(displayName, layerName);
1963 //--------------------------------------------------------------------------
1969 //--------------------------------------------------------------------------
1971 CicoSystemConfig::getLayerIdfbyName(const string& ECU,
1972 const string& display,
1973 const string& layer,
1974 const string& layout,
1977 const CicoSCLayerConf* conf = NULL;
1978 conf = findLayerConfbyName(ECU, display, layer, layout, area);
1986 //--------------------------------------------------------------------------
1992 //--------------------------------------------------------------------------
1994 CicoSystemConfig::getDizplayZoneIdbyName(const string & displayName,
1995 const string & zoneName)
1997 const CicoSCDisplayZoneConf* conf = NULL;
1998 conf = findDisplayZoneConfbyName(displayName, zoneName);
2006 //--------------------------------------------------------------------------
2012 //--------------------------------------------------------------------------
2014 CicoSystemConfig::getDizplayZoneIdbyFullName(const string & zoneFullName)
2016 string::size_type index = zoneFullName.find(".", 0);
2017 if (string::npos == index) {
2020 string displayName = zoneFullName.substr(0, index);
2021 string zoneName = zoneFullName.substr(index+1);
2023 const CicoSCDisplayZoneConf* conf = NULL;
2024 conf = findDisplayZoneConfbyName(displayName, zoneName);
2032 //--------------------------------------------------------------------------
2038 //--------------------------------------------------------------------------
2040 CicoSystemConfig::getSoundIdbyName(const string & name)
2042 const CicoSCSoundConf* conf = NULL;
2043 conf = findSoundConfbyName(name);
2051 //--------------------------------------------------------------------------
2057 //--------------------------------------------------------------------------
2059 CicoSystemConfig::getSoundZoneIdbyName(const string & soundName,
2060 const string & zoneName)
2062 const CicoSCSoundZoneConf* conf = NULL;
2063 conf = findSoundZoneConfbyName(soundName, zoneName);
2071 //--------------------------------------------------------------------------
2077 //--------------------------------------------------------------------------
2079 CicoSystemConfig::getSoundZoneIdbyFullName(const string & zoneFullName)
2081 string::size_type index = zoneFullName.find(".", 0);
2082 if (string::npos == index) {
2085 string soundName = zoneFullName.substr(0, index);
2086 string zoneName = zoneFullName.substr(index+1);
2088 const CicoSCSoundZoneConf* conf = NULL;
2089 conf = findSoundZoneConfbyName(soundName, zoneName);
2097 //--------------------------------------------------------------------------
2103 //--------------------------------------------------------------------------
2105 CicoSystemConfig::getInputDevIdbyName(const string & name)
2107 const CicoSCInputDevConf* conf = NULL;
2108 conf = findInputDevConfbyName(name);
2116 //--------------------------------------------------------------------------
2122 //--------------------------------------------------------------------------
2124 CicoSystemConfig::getSwitchIdbyName(const string & inputDevName,
2125 const string & switchName)
2127 const CicoSCSwitchConf* conf = NULL;
2128 conf = findSwitchConfbyName(inputDevName, switchName);
2136 //--------------------------------------------------------------------------
2142 //--------------------------------------------------------------------------
2144 CicoSystemConfig::getAppKindIdbyName(const string & name)
2146 const CicoSCAppKindConf* conf = NULL;
2147 conf = findAppKindConfbyName(name);
2155 //--------------------------------------------------------------------------
2161 //--------------------------------------------------------------------------
2163 CicoSystemConfig::getCategoryIdbyName(const string & name)
2165 const CicoSCCategoryConf* conf = NULL;
2166 conf = findCategoryConfbyName(name);
2174 //--------------------------------------------------------------------------
2176 * @brief get category config object class
2180 //--------------------------------------------------------------------------
2181 const CicoSCCategoryConf*
2182 CicoSystemConfig::getCategoryObjbyCaategoryID(int id)
2187 vector<CicoSCCategoryConf*>::const_iterator itr;
2188 itr = m_categoryConfList.begin();
2189 for (; itr != m_categoryConfList.end(); ++itr) {
2190 const CicoSCCategoryConf* conf = (*itr);
2191 if (id == conf->id) {
2192 //return const_cast<CicoSCCategoryConf*>(itr->pointer);
2199 //--------------------------------------------------------------------------
2201 * @brief array xml tree to vector<int>
2205 //--------------------------------------------------------------------------
2206 CicoSCVehicleInfoConf*
2207 CicoSystemConfig::getVehicleInfoConf(void)
2209 return m_vehicleInfoConf;
2212 //--------------------------------------------------------------------------
2214 * @brief array xml tree to vector<int>
2218 //--------------------------------------------------------------------------
2219 void getArray(ptree& t, vector<int>& vec)
2222 BOOST_FOREACH (const ptree::value_type& child, t) {
2223 const int value = lexical_cast<int>(child.second.data());
2224 vec.push_back(value);
2228 //--------------------------------------------------------------------------
2230 * @brief get state number from id key
2234 //--------------------------------------------------------------------------
2235 short CicoSystemConfig::getRoleStt(const string& key)
2237 if ((CicoSCRoleConf*)NULL == m_roleConf) {
2238 return ICO_SYC_ROLE_CONF_DEF;
2241 map<string, short>::iterator p;
2242 p = m_roleConf->m_stt.find(key);
2243 if (p == m_roleConf->m_stt.end()) {
2244 r = m_roleConf->m_def;
2252 //--------------------------------------------------------------------------
2254 * @brief array xml tree to vector<int>
2258 //--------------------------------------------------------------------------
2259 void CicoSystemConfig::createRoleConf(const ptree& root)
2261 m_roleConf = new CicoSCRoleConf();
2263 ptree roles = root.get_child("systemconfig.on_screen_roles");
2264 BOOST_FOREACH (const ptree::value_type& role, roles) {
2265 optional<string> id;
2267 id = role.second.get_optional<string>("<xmlattr>.id");
2268 if (false == id.is_initialized()) {
2271 stt = role.second.get_optional<int>("<xmlattr>.state");
2272 if (false == stt.is_initialized()) {
2275 string v_key = id.get();
2276 int v_stt = stt.get();
2277 if (0 == v_key.compare(ICO_SYC_ROLE_CONF_DEF_STR)) { // default define
2278 m_roleConf->m_def = (short)v_stt;
2280 else if (0 == v_key.compare(ICO_SYC_ROLE_CONF_RST_STR)) { // reset event number
2281 m_roleConf->m_rst = (short)v_stt;
2284 m_roleConf->m_stt.insert(pair<string, short>(v_key, (short)v_stt));
2287 m_roleConf->dumpConf();
2290 //--------------------------------------------------------------------------
2292 * @brief position OnScreen Config
2296 //--------------------------------------------------------------------------
2297 void CicoSystemConfig::createPositionOSConf(const ptree& root)
2299 ptree posc = root.get_child("systemconfig.on_screen_position");
2301 int x = ICO_SYC_ONSCREEN_WINDOW_START_X;
2302 int y = ICO_SYC_ONSCREEN_WINDOW_START_Y;
2303 int w = ICO_SYC_ONSCREEN_WINDOW_WIDTH;
2304 int h = ICO_SYC_ONSCREEN_WINDOW_HEIGHT;
2306 optional<string> optsx = posc.get_optional<string>("x");
2307 if (true == optsx.is_initialized()) {
2308 x = atoi(optsx.get().c_str());
2311 optional<string> optsy = posc.get_optional<string>("y");
2312 if (true == optsy.is_initialized()) {
2313 y = atoi(optsy.get().c_str());
2316 optional<string> optsw = posc.get_optional<string>("w");
2317 if (true == optsw.is_initialized()) {
2318 w = atoi(optsw.get().c_str());
2321 optional<string> optsh = posc.get_optional<string>("h");
2322 if (true == optsh.is_initialized()) {
2323 h = atoi(optsh.get().c_str());
2326 m_positionOSConf = new CicoSCPositionOSConf(x, y, w, h);
2327 m_positionOSConf->dumpConf();
2330 // vim:set expandtab ts=4 sw=4: