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();
104 ms_myInstance->load(ICO_SYSTEM_CONFIG_PATH);
106 return ms_myInstance;
109 //--------------------------------------------------------------------------
111 * @brief Get instance of CicoSystemConfig
113 * @param [in] confFile config file name
114 * @return true on success, false on error
116 //--------------------------------------------------------------------------
118 CicoSystemConfig::load(const string & confFile)
122 read_xml(confFile, root);
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);
139 ICO_ERR("catch exception!");
145 //--------------------------------------------------------------------------
151 //--------------------------------------------------------------------------
152 const vector<CicoSCNodeConf*>&
153 CicoSystemConfig::getNodeConfList(void) const
155 return m_nodeConfList;
158 //--------------------------------------------------------------------------
164 //--------------------------------------------------------------------------
165 const vector<CicoSCDisplayConf*>&
166 CicoSystemConfig::getDisplayConfList(void) const
168 return m_displayConfList;
171 //--------------------------------------------------------------------------
177 //--------------------------------------------------------------------------
178 const vector<CicoSCSoundConf*>&
179 CicoSystemConfig::getSoundConfList(void) const
181 return m_soundConfList;
184 //--------------------------------------------------------------------------
190 //--------------------------------------------------------------------------
191 const vector<CicoSCInputDevConf*> &
192 CicoSystemConfig::getInputDevConfList(void) const
194 return m_inputDevConfList;
197 //--------------------------------------------------------------------------
203 //--------------------------------------------------------------------------
204 const vector<CicoSCCategoryConf*> &
205 CicoSystemConfig::getCategoryConfList(void) const
207 return m_categoryConfList;
210 //--------------------------------------------------------------------------
216 //--------------------------------------------------------------------------
217 const vector<CicoSCAppKindConf*> &
218 CicoSystemConfig::getAppKindConfList(void) const
220 return m_appKindConfList;
223 //--------------------------------------------------------------------------
229 //--------------------------------------------------------------------------
231 CicoSystemConfig::createNodeConfList(const ptree & root)
234 // if (root.not_found() == root.find("systemconfig")) {
235 // ICO_ERR("nodes element not found");
238 ptree nodes = root.get_child("systemconfig.nodes");
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());
244 optional<int> id = optional<int>(-1);
245 optional<string> name;
246 optional<string> type;
247 optional<string> address;
249 id = child.second.get_optional<int>("<xmlattr>.id");
250 if (false == id.is_initialized()) {
251 ICO_ERR("node.id attr not found");
254 name = child.second.get_optional<string>("<xmlattr>.name");
255 if (false == name.is_initialized()) {
256 ICO_ERR("node.name attr not found");
259 type = child.second.get_optional<string>("type");
260 if (false == type.is_initialized()) {
261 ICO_ERR("node.type element not found");
264 address = child.second.get_optional<string>("ipaddress");
265 if (false == address.is_initialized()) {
266 ICO_ERR("node.address element not found");
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);
277 nodeConf->dumpConf();
281 //--------------------------------------------------------------------------
287 //--------------------------------------------------------------------------
289 CicoSystemConfig::createDisplayConfList(const ptree & root)
292 // if (root.not_found() != root.find("systemconfi.displays")) {
293 // ICO_ERR("displays element not found");
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);
308 id = child.second.get_optional<int>("<xmlattr>.id");
309 if (false == id.is_initialized()) {
310 ICO_ERR("display.id attr not found");
313 name = child.second.get_optional<string>("<xmlattr>.name");
314 if (false == name.is_initialized()) {
315 ICO_ERR("display.name attr not found");
318 node = child.second.get_optional<string>("node");
319 if (false == node.is_initialized()) {
320 ICO_ERR("display.node attr not found");
323 no = child.second.get_optional<int>("no");
324 if (false == no.is_initialized()) {
325 ICO_ERR("display.no element not found");
328 type = child.second.get_optional<string>("type");
329 if (false == type.is_initialized()) {
330 ICO_ERR("display.type element not found");
333 width = child.second.get_optional<int>("width");
334 if (false == width.is_initialized()) {
335 ICO_ERR("display.width element not found");
338 height = child.second.get_optional<int>("height");
339 if (false == height.is_initialized()) {
340 ICO_ERR("display.height element not found");
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();
353 displayConf->dumpConf();
355 createLayerConf(child, displayConf);
356 createDisplayZoneConf(child, displayConf);
358 m_displayConfList.push_back(displayConf);
363 //--------------------------------------------------------------------------
369 //--------------------------------------------------------------------------
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)
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);
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");
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");
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");
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");
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();
415 displayConf->layerConfList.push_back(layerConf);
417 layerConf->dumpConf();
421 //--------------------------------------------------------------------------
427 //--------------------------------------------------------------------------
429 CicoSystemConfig::createLayerConfContainedLayout(
430 const ptree::value_type& layer,
431 const optional<int>& layer_id, const optional<string>& layer_name,
432 CicoSCDisplayConf* displayConf)
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;
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");
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");
449 createLayoutConfContainedArea(layout, layer_id, layer_name, id, name,
454 //--------------------------------------------------------------------------
460 //--------------------------------------------------------------------------
462 CicoSystemConfig::createLayerConf(const ptree::value_type & child,
463 CicoSCDisplayConf* displayConf)
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);
472 id = layer.second.get_optional<int>("<xmlattr>.id");
473 if (false == id.is_initialized()) {
474 ICO_ERR("disply.layer.id attr not found");
477 name = layer.second.get_optional<string>("<xmlattr>.name");
478 if (false == name.is_initialized()) {
479 ICO_ERR("disply.layer.name attr not found");
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);
488 overlap = layer.second.get_optional<bool>("menuoverlap");
489 if (false == overlap.is_initialized()) {
490 ICO_ERR("disply.layer.overlap element not found");
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();
500 displayConf->layerConfList.push_back(layerConf);
502 layerConf->dumpConf();
506 //--------------------------------------------------------------------------
512 //--------------------------------------------------------------------------
514 CicoSystemConfig::createDisplayZoneConf(const ptree::value_type & child,
515 CicoSCDisplayConf* displayConf)
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;
525 optional<bool> fixed;
531 id = zone.second.get_optional<int>("<xmlattr>.id");
532 if (false == id.is_initialized()) {
533 ICO_WRN("zone.id.attr not found");
536 name = zone.second.get_optional<string>("<xmlattr>.name");
537 if (false == name.is_initialized()) {
538 ICO_WRN("zone.name.attr not found");
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");
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");
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");
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");
561 fixed = zone.second.get_optional<bool>("aspect.<xmlattr>.Fixed");
562 if (false == fixed.is_initialized()) {
563 fixed = optional<bool>(false);
565 l = zone.second.get_optional<bool>("aspect.<xmlattr>.AlignLeft");
566 if (false == l.is_initialized()) {
567 l = optional<bool>(false);
569 r = zone.second.get_optional<bool>("aspect.<xmlattr>.AlignRight");
570 if (false == r.is_initialized()) {
571 r = optional<bool>(false);
573 t = zone.second.get_optional<bool>("aspect.<xmlattr>.AlignTop");
574 if (false == t.is_initialized()) {
575 t = optional<bool>(false);
577 b = zone.second.get_optional<bool>("aspect.<xmlattr>.AlignBottom");
578 if (false == b.is_initialized()) {
579 b = optional<bool>(false);
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);
597 zoneConf->dumpConf();
601 //--------------------------------------------------------------------------
607 //--------------------------------------------------------------------------
609 CicoSystemConfig::createSoundConfList(const ptree & root)
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);
618 id = child.second.get_optional<int>("<xmlattr>.id");
619 if (false == id.is_initialized()) {
623 name = child.second.get_optional<string>("<xmlattr>.name");
624 if (false == name.is_initialized()) {
628 no = child.second.get_optional<int>("no");
629 if (false == no.is_initialized()) {
633 CicoSCSoundConf* soundConf = new CicoSCSoundConf();
634 soundConf->id = id.get();
635 soundConf->name = name.get();
636 soundConf->no = no.get();
638 soundConf->dumpConf();
640 createSoundZoneConf(child, soundConf);
642 m_soundConfList.push_back(soundConf);
646 //--------------------------------------------------------------------------
652 //--------------------------------------------------------------------------
654 CicoSystemConfig::createSoundZoneConf(const ptree::value_type & child,
655 CicoSCSoundConf* soundConf)
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;
665 id = zone.second.get_optional<int>("<xmlattr>.id");
666 if (false == id.is_initialized()) {
669 name = zone.second.get_optional<string>("<xmlattr>.name");
670 if (false == name.is_initialized()) {
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);
680 zoneConf->dumpConf();
684 //--------------------------------------------------------------------------
690 //--------------------------------------------------------------------------
692 CicoSystemConfig::createPortConf(const ptree & root)
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;
700 id = child.second.get_optional<int>("<xmlattr>.id");
701 if (false == id.is_initialized()) {
704 name = child.second.get_optional<string>("<xmlattr>.name");
705 if (false == name.is_initialized()) {
712 m_sysconPort = atoi(child.second.data().c_str());
715 m_soundPluginPort = atoi(child.second.data().c_str());
723 //--------------------------------------------------------------------------
729 //--------------------------------------------------------------------------
731 CicoSystemConfig::createCategoryConf(const ptree & root)
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);
745 id = child.second.get_optional<int>("<xmlattr>.id");
746 if (false == id.is_initialized()) {
749 name = child.second.get_optional<string>("<xmlattr>.name");
750 if (false == name.is_initialized()) {
753 type = child.second.get_optional<string>("type");
754 if (false == type.is_initialized()) {
757 view = child.second.get_optional<string>("view");
758 if (false == view.is_initialized()) {
761 sound = child.second.get_optional<string>("sound");
762 if (false == sound.is_initialized()) {
765 input= child.second.get_optional<string>("input");
766 if (false == sound.is_initialized()) {
769 priority = child.second.get_optional<int>("priority");
770 if (false == priority.is_initialized()) {
773 r_ctrl = child.second.get_optional<int>("r_ctrl");
774 if (false == r_ctrl.is_initialized()) {
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();
792 //--------------------------------------------------------------------------
798 //--------------------------------------------------------------------------
800 CicoSystemConfig::createAppKindConf(const ptree & root)
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);
810 id = child.second.get_optional<int>("<xmlattr>.id");
811 if (false == id.is_initialized()) {
815 name = child.second.get_optional<string>("<xmlattr>.name");
816 if (false == name.is_initialized()) {
820 privilege = child.second.get_optional<string>("privilege");
821 if (false == name.is_initialized()) {
825 priority = child.second.get_optional<int>("priority");
826 if (false == priority.is_initialized()) {
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();
840 //--------------------------------------------------------------------------
846 //--------------------------------------------------------------------------
848 CicoSystemConfig::createInputDevList(const ptree & root)
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;
856 id = child.second.get_optional<int>("<xmlattr>.id");
857 if (false == id.is_initialized()) {
861 name = child.second.get_optional<string>("<xmlattr>.name");
862 if (false == name.is_initialized()) {
866 CicoSCInputDevConf* inputDevConf = new CicoSCInputDevConf();
867 inputDevConf->id = id.get();
868 inputDevConf->name = name.get();
869 inputDevConf->dumpConf();
871 createSwitchList(child, inputDevConf);
872 m_inputDevConfList.push_back(inputDevConf);
876 //--------------------------------------------------------------------------
882 //--------------------------------------------------------------------------
884 CicoSystemConfig::createSwitchList(const ptree::value_type & child,
885 CicoSCInputDevConf* inputDevConf)
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;
893 id = zone.second.get_optional<int>("<xmlattr>.id");
894 if (false == id.is_initialized()) {
898 name = zone.second.get_optional<string>("<xmlattr>.name");
899 if (false == name.is_initialized()) {
903 appid = zone.second.get_optional<string>("<xmlattr>.appid");
904 if (false == appid.is_initialized()) {
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);
917 //--------------------------------------------------------------------------
923 //--------------------------------------------------------------------------
925 CicoSystemConfig::createDefaultConf(const ptree & root)
928 ptree defaults = root.get_child("systemconfig.default");
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;
941 node = defaults.get_optional<string>("node");
942 if (false == node.is_initialized()) {
943 ICO_WRN("default.node element not found");
946 appkind = defaults.get_optional<string>("appkind");
947 if (false == appkind.is_initialized()) {
948 ICO_WRN("default.appkind element not found");
951 category = defaults.get_optional<string>("category");
952 if (false == category.is_initialized()) {
953 ICO_WRN("default.category element not found");
956 display = defaults.get_optional<string>("display");
957 if (false == display.is_initialized()) {
958 ICO_WRN("default.display element not found");
961 layer = defaults.get_optional<string>("layer");
962 if (false == layer.is_initialized()) {
963 ICO_WRN("default.layer element not found");
966 displayzone = defaults.get_optional<string>("displayzone");
967 if (false == displayzone.is_initialized()) {
968 ICO_WRN("default.displayzone element not found");
971 sound = defaults.get_optional<string>("sound");
972 if (false == sound.is_initialized()) {
973 ICO_WRN("default.sound element not found");
976 soundzone = defaults.get_optional<string>("soundzone");
977 if (false == soundzone.is_initialized()) {
978 ICO_WRN("default.soundzone element not found");
981 inputdev = defaults.get_optional<string>("inputdev");
982 if (false == inputdev.is_initialized()) {
983 ICO_WRN("default.inputdev element not found");
986 inputsw = defaults.get_optional<string>("inputsw");
987 if (false == inputsw.is_initialized()) {
988 ICO_WRN("default.inputdsw element not found");
991 m_defaultConf = new CicoSCDefaultConf();
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(),
1000 m_defaultConf->sound = getSoundIdbyName(sound.get());
1001 m_defaultConf->soundzone = getSoundZoneIdbyName(sound.get(),
1003 m_defaultConf->inputdev = getInputDevIdbyName(inputdev.get());
1004 m_defaultConf->inputsw = getSwitchIdbyName(inputdev.get(),
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;
1015 m_defaultConf->topdir = topdir;
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;
1026 m_defaultConf->confdir = m_defaultConf->topdir;
1027 m_defaultConf->confdir.append("/");
1028 m_defaultConf->confdir.append(ICO_SYC_CONFIG_DIR);
1031 m_defaultConf->dumpConf();
1034 //--------------------------------------------------------------------------
1036 * @brief resource config class object create
1040 //--------------------------------------------------------------------------
1041 void getArray(ptree& t, vector<int>& vec);
1042 static const char* g_resource_cpu = "systemconfig.resource_cpu_control";
1044 CicoSystemConfig::createResourceConf(const ptree & root)
1046 m_resourceConf = new CicoSCResourceConf;
1047 ptree rc = root.get_child(g_resource_cpu);
1054 if ((CicoSCDefaultConf*)0 != m_defaultConf) {
1055 fPath = m_defaultConf->confdir;
1056 fPath += string("/");
1057 fPath += string("system_sysres.json");
1060 memset(&buff, 0, sizeof(buff));
1061 if (0 == stat(fPath.c_str(), &buff)) {
1062 read_json(fPath.c_str(), lcl_pt);
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")) {
1074 else if (0 == v.compare("app")) {
1080 ICO_WRN("NG json file(%s)", fPath.c_str());
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")) {
1092 else if (0 == v.compare("app")) {
1097 m_resourceConf->m_bDoIt = b;
1098 m_resourceConf->m_bDoItApp = bApp;
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();
1109 ICO_WRN("NG json file(%s)", fPath.c_str());
1113 optional<string> opts2 = rc.get_optional<string>("ctrl_dir_path");
1114 if (true == opts2.is_initialized()) {
1115 dirnm = opts2.get();
1118 if (true == dirnm.empty()) {
1119 dirnm = "/sys/fs/cgroup/cpu,cpuacct/SCprivate";
1121 m_resourceConf->m_cpuCGRPPath = dirnm;
1125 optional<string> opts;
1127 opts = rc.get_optional<string>("sampling_wait");
1128 if (true == opts.is_initialized()) {
1129 m_resourceConf->m_sampling = atoi(opts.get().c_str());
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;
1140 opts = rc.get_optional<string>("retry_cnt");
1141 if (true == opts.is_initialized()) {
1142 m_resourceConf->m_retryCnt = atoi(opts.get().c_str());
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());
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());
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()) {
1162 name = child.second.get_optional<string>("<xmlattr>.name");
1163 if (false == name.is_initialized()) {
1166 ptree pth = child.second.get_child("hight_array");
1167 ptree ptl = child.second.get_child("low_array");
1169 CicoSCCpuResourceGrp* obj = new CicoSCCpuResourceGrp;
1170 obj->m_id = id.get();
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);
1177 m_resourceConf->dumpConf();
1180 //--------------------------------------------------------------------------
1182 * @brief vechicle information config class object create
1186 //--------------------------------------------------------------------------
1188 CicoSystemConfig::createVehicleInfoConf(const ptree & root)
1190 m_vehicleInfoConf = new CicoSCVehicleInfoConf();
1192 ptree child = root.get_child("systemconfig.vehicle_info");
1194 optional<int> retryCnt;
1195 optional<int> waitTime;
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);
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);
1209 m_vehicleInfoConf->retryCnt = retryCnt.get();
1210 m_vehicleInfoConf->waitTime = waitTime.get();
1212 BOOST_FOREACH (const ptree::value_type& vinfo, child) {
1214 optional<string> name;
1215 optional<string> objname;
1216 optional<string> property;
1218 optional<string> type;
1220 id = vinfo.second.get_optional<int>("<xmlattr>.id");
1221 if (false == id.is_initialized()) {
1225 name = vinfo.second.get_optional<string>("<xmlattr>.name");
1226 if (false == name.is_initialized()) {
1230 property = vinfo.second.get_optional<string>("property");
1231 if (false == property.is_initialized()) {
1235 objname = vinfo.second.get_optional<string>("objname");
1236 if (false == objname.is_initialized()) {
1240 zone = vinfo.second.get_optional<int>("zone");
1241 if (false == zone.is_initialized()) {
1245 type = vinfo.second.get_optional<string>("type");
1246 if (false == type.is_initialized()) {
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;
1261 m_vehicleInfoConf->dumpConf();
1264 //--------------------------------------------------------------------------
1266 * @brief user config class object create
1270 //--------------------------------------------------------------------------
1271 static const char* g_login_user_conf = "systemconfig.login_user";
1273 CicoSystemConfig::createUserConf(const ptree & root)
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();
1281 m_userConf->m_parent_dir = v;
1284 m_userConf->dumpConf();
1287 //--------------------------------------------------------------------------
1293 //--------------------------------------------------------------------------
1295 CicoSystemConfig::calcGeometryExpr(const string & expr,
1296 CicoSCDisplayConf* conf)
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] == '/')) {
1311 if ((strcasecmp(word, "dispw") == 0) ||
1312 (strcasecmp(word, "width") == 0)) {
1315 else if ((strcasecmp(word, "disph") == 0) ||
1316 (strcasecmp(word, "heigh") == 0)) {
1317 wval = conf->height;
1320 wval = strtol(word, (char **)0, 0);
1326 switch (sign % 10) {
1327 case 0: /* assign */
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;
1353 if ((sign > 0) && (expr[i] == '-')) {
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;
1364 if (expr[i] == 0) break;
1367 if (j < ((int)sizeof(word)-1)) {
1368 word[j++] = expr[i];
1375 //--------------------------------------------------------------------------
1381 //--------------------------------------------------------------------------
1382 const CicoSCNodeConf*
1383 CicoSystemConfig::findNodeConfbyName(const string & name)
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) {
1397 //--------------------------------------------------------------------------
1403 //--------------------------------------------------------------------------
1404 const CicoSCDisplayConf*
1405 CicoSystemConfig::findDisplayConfbyName(const string & name)
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) {
1419 //--------------------------------------------------------------------------
1425 //--------------------------------------------------------------------------
1426 const CicoSCDisplayConf*
1427 CicoSystemConfig::findDisplayConfbyName(const string& ECU, const string& name)
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)) {
1442 //--------------------------------------------------------------------------
1448 //--------------------------------------------------------------------------
1449 const CicoSCDisplayConf*
1450 CicoSystemConfig::findDisplayConfbyId(int id)
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) {
1463 //--------------------------------------------------------------------------
1469 //--------------------------------------------------------------------------
1470 const CicoSCLayerConf*
1471 CicoSystemConfig::findLayerConfbyName(const string & displayName,
1472 const string & layerName)
1474 const CicoSCDisplayConf* displayConf = NULL;
1475 displayConf = findDisplayConfbyName(displayName);
1476 if (NULL == displayConf) {
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)) {
1493 //--------------------------------------------------------------------------
1499 //--------------------------------------------------------------------------
1500 const CicoSCLayerConf*
1501 CicoSystemConfig::findLayerConfbyName(const string& ECU,
1502 const string& display,
1503 const string& layer,
1504 const string& layout,
1507 const CicoSCDisplayConf* displayConf = NULL;
1508 displayConf = findDisplayConfbyName(ECU, display);
1509 if (NULL == displayConf) {
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)) {
1526 //--------------------------------------------------------------------------
1532 //--------------------------------------------------------------------------
1533 const CicoSCLayerConf*
1534 CicoSystemConfig::findLayerConfbyIdx(int displayid, int idx)
1536 const CicoSCDisplayConf* displayConf = NULL;
1537 displayConf = findDisplayConfbyId(displayid);
1538 if (NULL == displayConf) {
1542 vector<CicoSCLayerConf*>::const_iterator itr;
1543 itr = displayConf->layerConfList.begin();
1544 for (; itr != displayConf->layerConfList.end(); ++itr) {
1545 const CicoSCLayerConf* conf = (*itr);
1554 //--------------------------------------------------------------------------
1560 //--------------------------------------------------------------------------
1561 const CicoSCDisplayZoneConf*
1562 CicoSystemConfig::findDisplayZoneConfbyName(const string & displayName,
1563 const string & zoneName)
1565 // ICO_TRA("CicoSystemConfig::findDisplayZoneConfbyName Enter"
1566 // "(displayName=%s zoneNmae=%s)",
1567 // displayName.c_str(), zoneName.c_str());
1569 const CicoSCDisplayConf* displayConf = NULL;
1570 displayConf = findDisplayConfbyName(displayName);
1571 if (NULL == displayConf) {
1572 // ICO_TRA("CicoSystemConfig::findDisplayZoneConfbyName Leave(NULL)");
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);
1587 // ICO_TRA("CicoSystemConfig::findDisplayZoneConfbyName Leave(NULL)");
1591 //--------------------------------------------------------------------------
1597 //--------------------------------------------------------------------------
1598 const CicoSCSoundConf*
1599 CicoSystemConfig::findSoundConfbyName(const string & name)
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) {
1613 //--------------------------------------------------------------------------
1619 //--------------------------------------------------------------------------
1620 const CicoSCSoundZoneConf*
1621 CicoSystemConfig::findSoundZoneConfbyName(const string & soundName,
1622 const string & zoneName)
1624 // ICO_TRA("CicoSystemConfig::findSoundZoneConfbyName Enter"
1625 // "(soundName=%s zoneNmae=%s)",
1626 // soundName.c_str(), zoneName.c_str());
1628 const CicoSCSoundConf* soundConf = NULL;
1629 soundConf = findSoundConfbyName(soundName);
1630 if (NULL == soundConf) {
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) {
1646 //--------------------------------------------------------------------------
1652 //--------------------------------------------------------------------------
1653 const CicoSCInputDevConf*
1654 CicoSystemConfig::findInputDevConfbyName(const string & name)
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) {
1668 //--------------------------------------------------------------------------
1674 //--------------------------------------------------------------------------
1675 const CicoSCSwitchConf*
1676 CicoSystemConfig::findSwitchConfbyName(const string & inputDevName,
1677 const string & switchName)
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());
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) {
1696 ICO_WRN("name(%s) switch config not found.", switchName.c_str());
1700 //--------------------------------------------------------------------------
1706 //--------------------------------------------------------------------------
1707 const CicoSCAppKindConf*
1708 CicoSystemConfig::findAppKindConfbyName(const string & name)
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) {
1722 //--------------------------------------------------------------------------
1728 //--------------------------------------------------------------------------
1729 const CicoSCDisplayZoneConf*
1730 CicoSystemConfig::findDisplayZoneConfbyId(int id)
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) {
1747 //--------------------------------------------------------------------------
1753 //--------------------------------------------------------------------------
1754 const CicoSCSoundZoneConf*
1755 CicoSystemConfig::findSoundZoneConfbyId(int id)
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) {
1772 //--------------------------------------------------------------------------
1778 //--------------------------------------------------------------------------
1779 const CicoSCCategoryConf*
1780 CicoSystemConfig::findCategoryConfbyName(const string & name)
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);
1795 //--------------------------------------------------------------------------
1801 //--------------------------------------------------------------------------
1802 const CicoSCCategoryConf*
1803 CicoSystemConfig::findCategoryConfbyId(int id)
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) {
1817 //--------------------------------------------------------------------------
1823 //--------------------------------------------------------------------------
1824 const CicoSCAppKindConf *
1825 CicoSystemConfig::findAppKindConfbyId(int id)
1827 vector<CicoSCAppKindConf*>::const_iterator itr;
1828 itr = m_appKindConfList.begin();
1829 for (; itr != m_appKindConfList.end(); ++itr) {
1830 if (id == (*itr)->id) {
1838 //--------------------------------------------------------------------------
1844 //--------------------------------------------------------------------------
1845 const CicoSCDefaultConf*
1846 CicoSystemConfig::getDefaultConf(void)
1848 return m_defaultConf;
1851 //--------------------------------------------------------------------------
1857 //--------------------------------------------------------------------------
1859 CicoSystemConfig::getNodeIdbyName(const string & name)
1861 const CicoSCNodeConf* conf = NULL;
1862 conf = findNodeConfbyName(name);
1870 //--------------------------------------------------------------------------
1876 //--------------------------------------------------------------------------
1878 CicoSystemConfig::getDisplayIdbyName(const string & name)
1880 const CicoSCDisplayConf* conf = NULL;
1881 conf = findDisplayConfbyName(name);
1889 //--------------------------------------------------------------------------
1895 //--------------------------------------------------------------------------
1897 CicoSystemConfig::getDisplayIdbyNo(int no)
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) {
1910 //--------------------------------------------------------------------------
1916 //--------------------------------------------------------------------------
1918 CicoSystemConfig::getDisplayIdbyType(int type)
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) {
1931 //--------------------------------------------------------------------------
1937 //--------------------------------------------------------------------------
1939 CicoSystemConfig::getNumberofDisplay(void)
1944 //--------------------------------------------------------------------------
1950 //--------------------------------------------------------------------------
1952 CicoSystemConfig::getLayerIdfbyName(const string & displayName,
1953 const string & layerName)
1955 const CicoSCLayerConf* conf = NULL;
1956 conf = findLayerConfbyName(displayName, layerName);
1964 //--------------------------------------------------------------------------
1970 //--------------------------------------------------------------------------
1972 CicoSystemConfig::getLayerIdfbyName(const string& ECU,
1973 const string& display,
1974 const string& layer,
1975 const string& layout,
1978 const CicoSCLayerConf* conf = NULL;
1979 conf = findLayerConfbyName(ECU, display, layer, layout, area);
1987 //--------------------------------------------------------------------------
1993 //--------------------------------------------------------------------------
1995 CicoSystemConfig::getDizplayZoneIdbyName(const string & displayName,
1996 const string & zoneName)
1998 const CicoSCDisplayZoneConf* conf = NULL;
1999 conf = findDisplayZoneConfbyName(displayName, zoneName);
2007 //--------------------------------------------------------------------------
2013 //--------------------------------------------------------------------------
2015 CicoSystemConfig::getDizplayZoneIdbyFullName(const string & zoneFullName)
2017 string::size_type index = zoneFullName.find(".", 0);
2018 if (string::npos == index) {
2021 string displayName = zoneFullName.substr(0, index);
2022 string zoneName = zoneFullName.substr(index+1);
2024 const CicoSCDisplayZoneConf* conf = NULL;
2025 conf = findDisplayZoneConfbyName(displayName, zoneName);
2033 //--------------------------------------------------------------------------
2039 //--------------------------------------------------------------------------
2041 CicoSystemConfig::getSoundIdbyName(const string & name)
2043 const CicoSCSoundConf* conf = NULL;
2044 conf = findSoundConfbyName(name);
2052 //--------------------------------------------------------------------------
2058 //--------------------------------------------------------------------------
2060 CicoSystemConfig::getSoundZoneIdbyName(const string & soundName,
2061 const string & zoneName)
2063 const CicoSCSoundZoneConf* conf = NULL;
2064 conf = findSoundZoneConfbyName(soundName, zoneName);
2072 //--------------------------------------------------------------------------
2078 //--------------------------------------------------------------------------
2080 CicoSystemConfig::getSoundZoneIdbyFullName(const string & zoneFullName)
2082 string::size_type index = zoneFullName.find(".", 0);
2083 if (string::npos == index) {
2086 string soundName = zoneFullName.substr(0, index);
2087 string zoneName = zoneFullName.substr(index+1);
2089 const CicoSCSoundZoneConf* conf = NULL;
2090 conf = findSoundZoneConfbyName(soundName, zoneName);
2098 //--------------------------------------------------------------------------
2104 //--------------------------------------------------------------------------
2106 CicoSystemConfig::getInputDevIdbyName(const string & name)
2108 const CicoSCInputDevConf* conf = NULL;
2109 conf = findInputDevConfbyName(name);
2117 //--------------------------------------------------------------------------
2123 //--------------------------------------------------------------------------
2125 CicoSystemConfig::getSwitchIdbyName(const string & inputDevName,
2126 const string & switchName)
2128 const CicoSCSwitchConf* conf = NULL;
2129 conf = findSwitchConfbyName(inputDevName, switchName);
2137 //--------------------------------------------------------------------------
2143 //--------------------------------------------------------------------------
2145 CicoSystemConfig::getAppKindIdbyName(const string & name)
2147 const CicoSCAppKindConf* conf = NULL;
2148 conf = findAppKindConfbyName(name);
2156 //--------------------------------------------------------------------------
2162 //--------------------------------------------------------------------------
2164 CicoSystemConfig::getCategoryIdbyName(const string & name)
2166 const CicoSCCategoryConf* conf = NULL;
2167 conf = findCategoryConfbyName(name);
2175 //--------------------------------------------------------------------------
2177 * @brief get category config object class
2181 //--------------------------------------------------------------------------
2182 const CicoSCCategoryConf*
2183 CicoSystemConfig::getCategoryObjbyCaategoryID(int id)
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);
2200 //--------------------------------------------------------------------------
2202 * @brief array xml tree to vector<int>
2206 //--------------------------------------------------------------------------
2207 CicoSCVehicleInfoConf*
2208 CicoSystemConfig::getVehicleInfoConf(void)
2210 return m_vehicleInfoConf;
2213 //--------------------------------------------------------------------------
2215 * @brief array xml tree to vector<int>
2219 //--------------------------------------------------------------------------
2220 void getArray(ptree& t, vector<int>& vec)
2223 BOOST_FOREACH (const ptree::value_type& child, t) {
2224 const int value = lexical_cast<int>(child.second.data());
2225 vec.push_back(value);
2229 //--------------------------------------------------------------------------
2231 * @brief get state number from id key
2235 //--------------------------------------------------------------------------
2236 short CicoSystemConfig::getRoleStt(const string& key)
2238 if ((CicoSCRoleConf*)NULL == m_roleConf) {
2239 return ICO_SYC_ROLE_CONF_DEF;
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;
2253 //--------------------------------------------------------------------------
2255 * @brief array xml tree to vector<int>
2259 //--------------------------------------------------------------------------
2260 void CicoSystemConfig::createRoleConf(const ptree& root)
2262 m_roleConf = new CicoSCRoleConf();
2264 ptree roles = root.get_child("systemconfig.on_screen_roles");
2265 BOOST_FOREACH (const ptree::value_type& role, roles) {
2266 optional<string> id;
2268 id = role.second.get_optional<string>("<xmlattr>.id");
2269 if (false == id.is_initialized()) {
2272 stt = role.second.get_optional<int>("<xmlattr>.state");
2273 if (false == stt.is_initialized()) {
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;
2281 else if (0 == v_key.compare(ICO_SYC_ROLE_CONF_RST_STR)) { // reset event number
2282 m_roleConf->m_rst = (short)v_stt;
2285 m_roleConf->m_stt.insert(pair<string, short>(v_key, (short)v_stt));
2288 m_roleConf->dumpConf();
2291 //--------------------------------------------------------------------------
2293 * @brief position OnScreen Config
2297 //--------------------------------------------------------------------------
2298 void CicoSystemConfig::createPositionOSConf(const ptree& root)
2300 ptree posc = root.get_child("systemconfig.on_screen_position");
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;
2307 optional<string> optsx = posc.get_optional<string>("x");
2308 if (true == optsx.is_initialized()) {
2309 x = atoi(optsx.get().c_str());
2312 optional<string> optsy = posc.get_optional<string>("y");
2313 if (true == optsy.is_initialized()) {
2314 y = atoi(optsy.get().c_str());
2317 optional<string> optsw = posc.get_optional<string>("w");
2318 if (true == optsw.is_initialized()) {
2319 w = atoi(optsw.get().c_str());
2322 optional<string> optsh = posc.get_optional<string>("h");
2323 if (true == optsh.is_initialized()) {
2324 h = atoi(optsh.get().c_str());
2327 m_positionOSConf = new CicoSCPositionOSConf(x, y, w, h);
2328 m_positionOSConf->dumpConf();
2331 // vim:set expandtab ts=4 sw=4: