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>
23 #include <tzplatform_config.h>
25 #include "ico_syc_private.h"
26 #include "CicoSystemConfig.h"
28 #include "CicoGKeyFileConfig.h"
30 using namespace boost::property_tree;
31 //==========================================================================
32 // private static variable
33 //==========================================================================
34 CicoSystemConfig* CicoSystemConfig::ms_myInstance = NULL;
36 //--------------------------------------------------------------------------
38 * @brief default constructor
40 //--------------------------------------------------------------------------
41 CicoSystemConfig::CicoSystemConfig()
43 m_typeTable[""] = ICO_NODETYPE_CENTER;
44 m_typeTable["center"] = ICO_NODETYPE_CENTER;
45 m_typeTable["meter"] = ICO_NODETYPE_METER;
46 m_typeTable["remote"] = ICO_NODETYPE_REMOTE;
47 m_typeTable["passenger"] = ICO_NODETYPE_PASSENGER;
48 m_typeTable["rear"] = ICO_NODETYPE_REAR;
49 m_typeTable["rearleft"] = ICO_NODETYPE_REARLEFT;
50 m_typeTable["rearright"] = ICO_NODETYPE_REARRIGHT;
52 m_displayTypeTable[""] = ICO_DISPLAYTYPE_CENTER;
53 m_displayTypeTable["center"] = ICO_DISPLAYTYPE_CENTER;
54 m_displayTypeTable["meter"] = ICO_DISPLAYTYPE_METER;
55 m_displayTypeTable["remote"] = ICO_DISPLAYTYPE_REMOTE;
56 m_displayTypeTable["passenger"] = ICO_DISPLAYTYPE_PASSENGER;
57 m_displayTypeTable["rear"] = ICO_DISPLAYTYPE_REAR;
58 m_displayTypeTable["rearleft"] = ICO_DISPLAYTYPE_REARLEFT;
59 m_displayTypeTable["rearright"] = ICO_DISPLAYTYPE_REARRIGHT;
62 m_categoryTalbe[""] = ICO_POLICY_ALWAYS;
63 m_categoryTalbe["always"] = ICO_POLICY_ALWAYS;
64 m_categoryTalbe["run"] = ICO_POLICY_RUNNING;
65 m_categoryTalbe["park"] = ICO_POLICY_PARKED;
66 m_categoryTalbe["shift_park"] = ICO_POLICY_SHIFT_PARKING;
67 m_categoryTalbe["shift_back"] = ICO_POLICY_SHIFT_REVERSES;
68 m_categoryTalbe["shift_rev"] = ICO_POLICY_SHIFT_REVERSES;
69 m_categoryTalbe["blinker_left"] = ICO_POLICY_BLINKER_LEFT;
70 m_categoryTalbe["blinker_right"] = ICO_POLICY_BLINKER_RIGHT;
73 m_privilegeTable["almighty"] = ICO_PRIVILEGE_ALMIGHTY;
74 m_privilegeTable["system"] = ICO_PRIVILEGE_SYSTEM;
75 m_privilegeTable["system.audio"] = ICO_PRIVILEGE_SYSTEM_AUDIO;
76 m_privilegeTable["system.visible"] = ICO_PRIVILEGE_SYSTEM_VISIBLE;
77 m_privilegeTable["maker"] = ICO_PRIVILEGE_MAKER;
78 m_privilegeTable["certificate"] = ICO_PRIVILEGE_CERTIFICATE;
79 m_privilegeTable["none"] = ICO_PRIVILEGE_NONE;
80 m_privilegeTable[""] = ICO_PRIVILEGE_NONE;
81 m_resourceConf = NULL;
85 //--------------------------------------------------------------------------
89 //--------------------------------------------------------------------------
90 CicoSystemConfig::~CicoSystemConfig()
95 //--------------------------------------------------------------------------
97 * @brief Get instance of CicoSystemConfig
99 * @return pointer of CicoSystemConfig object
101 //--------------------------------------------------------------------------
103 CicoSystemConfig::getInstance(void)
105 if (NULL == ms_myInstance) {
106 ms_myInstance = new CicoSystemConfig();
108 return ms_myInstance;
111 //--------------------------------------------------------------------------
113 * @brief Get instance of CicoSystemConfig
115 * @param [in] confFile config file name
116 * @return true on success, false on error
118 //--------------------------------------------------------------------------
120 CicoSystemConfig::load(const string & confFile)
124 read_xml(confFile, root);
126 createNodeConfList(root);
127 createDisplayConfList(root);
128 createSoundConfList(root);
129 createPortConf(root);
130 createCategoryConf(root);
131 createAppKindConf(root);
132 createInputDevList(root);
133 createDefaultConf(root);
134 createResourceConf(root);
135 createUserConf(root);
136 createVehicleInfoConf(root);
137 createRoleConf(root);
138 createPositionOSConf(root);
141 ICO_ERR("catch exception!");
147 //--------------------------------------------------------------------------
153 //--------------------------------------------------------------------------
154 const vector<CicoSCNodeConf*>&
155 CicoSystemConfig::getNodeConfList(void) const
157 return m_nodeConfList;
160 //--------------------------------------------------------------------------
166 //--------------------------------------------------------------------------
167 const vector<CicoSCDisplayConf*>&
168 CicoSystemConfig::getDisplayConfList(void) const
170 return m_displayConfList;
173 //--------------------------------------------------------------------------
179 //--------------------------------------------------------------------------
180 const vector<CicoSCSoundConf*>&
181 CicoSystemConfig::getSoundConfList(void) const
183 return m_soundConfList;
186 //--------------------------------------------------------------------------
192 //--------------------------------------------------------------------------
193 const vector<CicoSCInputDevConf*> &
194 CicoSystemConfig::getInputDevConfList(void) const
196 return m_inputDevConfList;
199 //--------------------------------------------------------------------------
205 //--------------------------------------------------------------------------
206 const vector<CicoSCCategoryConf*> &
207 CicoSystemConfig::getCategoryConfList(void) const
209 return m_categoryConfList;
212 //--------------------------------------------------------------------------
218 //--------------------------------------------------------------------------
219 const vector<CicoSCAppKindConf*> &
220 CicoSystemConfig::getAppKindConfList(void) const
222 return m_appKindConfList;
225 //--------------------------------------------------------------------------
231 //--------------------------------------------------------------------------
233 CicoSystemConfig::createNodeConfList(const ptree & root)
236 // if (root.not_found() == root.find("systemconfig")) {
237 // ICO_ERR("nodes element not found");
240 ptree nodes = root.get_child("systemconfig.nodes");
242 BOOST_FOREACH (const ptree::value_type& child, nodes) {
243 if (0 != strcmp(child.first.data(),"node")) {
244 ICO_ERR("unknown element(%s)", child.first.data());
246 optional<int> id = optional<int>(-1);
247 optional<string> name;
248 optional<string> type;
249 optional<string> address;
251 id = child.second.get_optional<int>("<xmlattr>.id");
252 if (false == id.is_initialized()) {
253 ICO_ERR("node.id attr not found");
256 name = child.second.get_optional<string>("<xmlattr>.name");
257 if (false == name.is_initialized()) {
258 ICO_ERR("node.name attr not found");
261 type = child.second.get_optional<string>("type");
262 if (false == type.is_initialized()) {
263 ICO_ERR("node.type element not found");
266 address = child.second.get_optional<string>("ipaddress");
267 if (false == address.is_initialized()) {
268 ICO_ERR("node.address element not found");
272 CicoSCNodeConf* nodeConf = new CicoSCNodeConf;
273 nodeConf->id = id.get();
274 nodeConf->name = name.get();
275 nodeConf->type = m_typeTable[type.get()];
276 nodeConf->address = address.get();
277 m_nodeConfList.push_back(nodeConf);
279 nodeConf->dumpConf();
283 //--------------------------------------------------------------------------
289 //--------------------------------------------------------------------------
291 CicoSystemConfig::createDisplayConfList(const ptree & root)
294 // if (root.not_found() != root.find("systemconfi.displays")) {
295 // ICO_ERR("displays element not found");
300 ptree displays = root.get_child("systemconfig.displays");
301 BOOST_FOREACH (const ptree::value_type& child, displays) {
302 optional<int> id = optional<int>(-1);
303 optional<string> name;
304 optional<string> node;
305 optional<int> no = optional<int>(-1);
306 optional<string> type;
307 optional<int> width = optional<int>(-1);
308 optional<int> height = optional<int>(-1);
310 id = child.second.get_optional<int>("<xmlattr>.id");
311 if (false == id.is_initialized()) {
312 ICO_ERR("display.id attr not found");
315 name = child.second.get_optional<string>("<xmlattr>.name");
316 if (false == name.is_initialized()) {
317 ICO_ERR("display.name attr not found");
320 node = child.second.get_optional<string>("node");
321 if (false == node.is_initialized()) {
322 ICO_ERR("display.node attr not found");
325 no = child.second.get_optional<int>("no");
326 if (false == no.is_initialized()) {
327 ICO_ERR("display.no element not found");
330 type = child.second.get_optional<string>("type");
331 if (false == type.is_initialized()) {
332 ICO_ERR("display.type element not found");
335 width = child.second.get_optional<int>("width");
336 if (false == width.is_initialized()) {
337 ICO_ERR("display.width element not found");
340 height = child.second.get_optional<int>("height");
341 if (false == height.is_initialized()) {
342 ICO_ERR("display.height element not found");
346 CicoSCDisplayConf* displayConf = new CicoSCDisplayConf();
347 displayConf->id = id.get();
348 displayConf->name = name.get();
349 displayConf->node = getNodeIdbyName(node.get());
350 displayConf->no = no.get();
351 displayConf->type = m_displayTypeTable[type.get()];
352 displayConf->width = width.get();
353 displayConf->height = height.get();
355 displayConf->dumpConf();
357 createLayerConf(child, displayConf);
358 createDisplayZoneConf(child, displayConf);
360 m_displayConfList.push_back(displayConf);
365 //--------------------------------------------------------------------------
371 //--------------------------------------------------------------------------
373 CicoSystemConfig::createLayoutConfContainedArea(
374 const ptree::value_type& layout,
375 const optional<int>& layer_id, const optional<string>& layer_name,
376 const optional<int>& layout_id, const optional<string>& layout_name,
377 CicoSCDisplayConf* displayConf)
379 ptree areas = layout.second.get_child("areas");
380 BOOST_FOREACH (const ptree::value_type& area, areas) {
381 optional<int> id = optional<int>(-1);
382 optional<string> name;
383 optional<int> type = optional<int>(-1);
384 optional<bool> overlap = optional<bool>(false);
386 id = area.second.get_optional<int>("<xmlattr>.id");
387 if (false == id.is_initialized()) {
388 ICO_ERR("disply.layer.layout.area.id attr not found");
391 name = area.second.get_optional<string>("<xmlattr>.name");
392 if (false == name.is_initialized()) {
393 ICO_ERR("disply.layer.layout.area.name attr not found");
396 type = area.second.get_optional<int>("type");
397 if (false == type.is_initialized()) {
398 ICO_ERR("disply.layer.layout.area.type element not found");
401 overlap = area.second.get_optional<bool>("menuoverlap");
402 if (false == overlap.is_initialized()) {
403 ICO_ERR("disply.layer.layout.area.overlap element not found");
407 CicoSCLayerConf* layerConf = new CicoSCLayerConf();
408 layerConf->id = layer_id.get();
409 layerConf->name = layer_name.get();
410 layerConf->type = type.get();
411 layerConf->menuoverlap = overlap.get();
412 layerConf->layout_id = layout_id.get();
413 layerConf->layout_name = layout_name.get();
414 layerConf->area_id = id.get();
415 layerConf->area_name = name.get();
417 displayConf->layerConfList.push_back(layerConf);
419 layerConf->dumpConf();
423 //--------------------------------------------------------------------------
429 //--------------------------------------------------------------------------
431 CicoSystemConfig::createLayerConfContainedLayout(
432 const ptree::value_type& layer,
433 const optional<int>& layer_id, const optional<string>& layer_name,
434 CicoSCDisplayConf* displayConf)
436 ptree layouts = layer.second.get_child("layouts");
437 BOOST_FOREACH (const ptree::value_type& layout, layouts) {
438 optional<int> id = optional<int>(-1);
439 optional<string> name;
441 id = layout.second.get_optional<int>("<xmlattr>.id");
442 if (false == id.is_initialized()) {
443 ICO_ERR("disply.layer.layout.id attr not found");
446 name = layer.second.get_optional<string>("<xmlattr>.name");
447 if (false == name.is_initialized()) {
448 ICO_ERR("disply.layer.layout.name attr not found");
451 createLayoutConfContainedArea(layout, layer_id, layer_name, id, name,
456 //--------------------------------------------------------------------------
462 //--------------------------------------------------------------------------
464 CicoSystemConfig::createLayerConf(const ptree::value_type & child,
465 CicoSCDisplayConf* displayConf)
467 ptree layers = child.second.get_child("layers");
468 BOOST_FOREACH (const ptree::value_type& layer, layers) {
469 optional<int> id = optional<int>(-1);
470 optional<string> name;
471 optional<int> type = optional<int>(-1);
472 optional<bool> overlap = optional<bool>(false);
474 id = layer.second.get_optional<int>("<xmlattr>.id");
475 if (false == id.is_initialized()) {
476 ICO_ERR("disply.layer.id attr not found");
479 name = layer.second.get_optional<string>("<xmlattr>.name");
480 if (false == name.is_initialized()) {
481 ICO_ERR("disply.layer.name attr not found");
484 type = layer.second.get_optional<int>("type");
485 if (false == type.is_initialized()) {
486 // ICO_ERR("disply.layer.type element not found");
487 createLayerConfContainedLayout(layer, id, name, displayConf);
490 overlap = layer.second.get_optional<bool>("menuoverlap");
491 if (false == overlap.is_initialized()) {
492 ICO_ERR("disply.layer.overlap element not found");
496 CicoSCLayerConf* layerConf = new CicoSCLayerConf();
497 layerConf->id = id.get();
498 layerConf->name = name.get();
499 layerConf->type = type.get();
500 layerConf->menuoverlap = overlap.get();
502 displayConf->layerConfList.push_back(layerConf);
504 layerConf->dumpConf();
508 //--------------------------------------------------------------------------
514 //--------------------------------------------------------------------------
516 CicoSystemConfig::createDisplayZoneConf(const ptree::value_type & child,
517 CicoSCDisplayConf* displayConf)
519 ptree zones = child.second.get_child("zones");
520 BOOST_FOREACH (const ptree::value_type& zone, zones) {
521 optional<int> id = optional<int>(-1);
522 optional<string> name;
527 optional<bool> fixed;
533 id = zone.second.get_optional<int>("<xmlattr>.id");
534 if (false == id.is_initialized()) {
535 ICO_WRN("zone.id.attr not found");
538 name = zone.second.get_optional<string>("<xmlattr>.name");
539 if (false == name.is_initialized()) {
540 ICO_WRN("zone.name.attr not found");
543 x = zone.second.get_optional<string>("geometry.<xmlattr>.x");
544 if (false == x.is_initialized()) {
545 ICO_WRN("zone.geometry.x attr not found");
548 y = zone.second.get_optional<string>("geometry.<xmlattr>.y");
549 if (false == y.is_initialized()) {
550 ICO_WRN("zone.geometry.y attr not found");
553 w = zone.second.get_optional<string>("geometry.<xmlattr>.w");
554 if (false == w.is_initialized()) {
555 ICO_WRN("zone.geometry.w attr not found");
558 h = zone.second.get_optional<string>("geometry.<xmlattr>.h");
559 if (false == h.is_initialized()) {
560 ICO_WRN("zone.geometry.h attr not found");
563 fixed = zone.second.get_optional<bool>("aspect.<xmlattr>.Fixed");
564 if (false == fixed.is_initialized()) {
565 fixed = optional<bool>(false);
567 l = zone.second.get_optional<bool>("aspect.<xmlattr>.AlignLeft");
568 if (false == l.is_initialized()) {
569 l = optional<bool>(false);
571 r = zone.second.get_optional<bool>("aspect.<xmlattr>.AlignRight");
572 if (false == r.is_initialized()) {
573 r = optional<bool>(false);
575 t = zone.second.get_optional<bool>("aspect.<xmlattr>.AlignTop");
576 if (false == t.is_initialized()) {
577 t = optional<bool>(false);
579 b = zone.second.get_optional<bool>("aspect.<xmlattr>.AlignBottom");
580 if (false == b.is_initialized()) {
581 b = optional<bool>(false);
584 CicoSCDisplayZoneConf* zoneConf = new CicoSCDisplayZoneConf();
585 zoneConf->id = id.get();
586 zoneConf->name = name.get();
587 zoneConf->fullname = displayConf->name + "." + name.get();
588 zoneConf->x = calcGeometryExpr(x.get(), displayConf);
589 zoneConf->y = calcGeometryExpr(y.get(), displayConf);
590 zoneConf->w = calcGeometryExpr(w.get(), displayConf);
591 zoneConf->h = calcGeometryExpr(h.get(), displayConf);
592 zoneConf->aspectFixed = fixed.get();
593 zoneConf->aspectAlignLeft = l.get();
594 zoneConf->aspectAlignRight = r.get();
595 zoneConf->aspectAlignTop = t.get();
596 zoneConf->aspectAlignBottom = b.get();
597 displayConf->zoneConfList.push_back(zoneConf);
599 zoneConf->dumpConf();
603 //--------------------------------------------------------------------------
609 //--------------------------------------------------------------------------
611 CicoSystemConfig::createSoundConfList(const ptree & root)
614 ptree sounds = root.get_child("systemconfig.sounds");
615 BOOST_FOREACH (const ptree::value_type& child, sounds) {
616 optional<int> id = optional<int>(-1);
617 optional<string> name;
618 optional<int> no = optional<int>(-1);
620 id = child.second.get_optional<int>("<xmlattr>.id");
621 if (false == id.is_initialized()) {
625 name = child.second.get_optional<string>("<xmlattr>.name");
626 if (false == name.is_initialized()) {
630 no = child.second.get_optional<int>("no");
631 if (false == no.is_initialized()) {
635 CicoSCSoundConf* soundConf = new CicoSCSoundConf();
636 soundConf->id = id.get();
637 soundConf->name = name.get();
638 soundConf->no = no.get();
640 soundConf->dumpConf();
642 createSoundZoneConf(child, soundConf);
644 m_soundConfList.push_back(soundConf);
648 //--------------------------------------------------------------------------
654 //--------------------------------------------------------------------------
656 CicoSystemConfig::createSoundZoneConf(const ptree::value_type & child,
657 CicoSCSoundConf* soundConf)
662 ptree zones = child.second.get_child("zones");
663 BOOST_FOREACH (const ptree::value_type& zone, zones) {
664 optional<int> id = optional<int>(-1);
665 optional<string> name;
667 id = zone.second.get_optional<int>("<xmlattr>.id");
668 if (false == id.is_initialized()) {
671 name = zone.second.get_optional<string>("<xmlattr>.name");
672 if (false == name.is_initialized()) {
676 CicoSCSoundZoneConf* zoneConf = new CicoSCSoundZoneConf();
677 zoneConf->id = id.get();
678 zoneConf->name = name.get();
679 zoneConf->fullname = soundConf->name + "." + name.get();
680 soundConf->zoneConfList.push_back(zoneConf);
682 zoneConf->dumpConf();
686 //--------------------------------------------------------------------------
692 //--------------------------------------------------------------------------
694 CicoSystemConfig::createPortConf(const ptree & root)
697 ptree ports = root.get_child("systemconfig.ports");
698 BOOST_FOREACH (const ptree::value_type& child, ports) {
699 optional<int> id = optional<int>(-1);
700 optional<string> name;
702 id = child.second.get_optional<int>("<xmlattr>.id");
703 if (false == id.is_initialized()) {
706 name = child.second.get_optional<string>("<xmlattr>.name");
707 if (false == name.is_initialized()) {
714 m_sysconPort = atoi(child.second.data().c_str());
717 m_soundPluginPort = atoi(child.second.data().c_str());
725 //--------------------------------------------------------------------------
731 //--------------------------------------------------------------------------
733 CicoSystemConfig::createCategoryConf(const ptree & root)
736 ptree categorys = root.get_child("systemconfig.categorys");
737 BOOST_FOREACH (const ptree::value_type& child, categorys) {
738 optional<int> id = optional<int>(-1);
739 optional<string> name;
740 optional<string> type;
741 optional<string> view;
742 optional<string> sound;
743 optional<string> input;
744 optional<int> priority = optional<int>(-1);
745 optional<int> r_ctrl = optional<int>(-1);
747 id = child.second.get_optional<int>("<xmlattr>.id");
748 if (false == id.is_initialized()) {
751 name = child.second.get_optional<string>("<xmlattr>.name");
752 if (false == name.is_initialized()) {
755 type = child.second.get_optional<string>("type");
756 if (false == type.is_initialized()) {
759 view = child.second.get_optional<string>("view");
760 if (false == view.is_initialized()) {
763 sound = child.second.get_optional<string>("sound");
764 if (false == sound.is_initialized()) {
767 input= child.second.get_optional<string>("input");
768 if (false == sound.is_initialized()) {
771 priority = child.second.get_optional<int>("priority");
772 if (false == priority.is_initialized()) {
775 r_ctrl = child.second.get_optional<int>("r_ctrl");
776 if (false == r_ctrl.is_initialized()) {
780 CicoSCCategoryConf* categoryConf = new CicoSCCategoryConf();
781 categoryConf->id = id.get();
782 categoryConf->name = name.get();
783 categoryConf->type = type.get();
784 categoryConf->view = m_categoryTalbe[view.get()];
785 categoryConf->sound = m_categoryTalbe[sound.get()];
786 categoryConf->input = m_categoryTalbe[input.get()];
787 categoryConf->priority = priority.get();
788 categoryConf->rctrl = r_ctrl.get();
789 m_categoryConfList.push_back(categoryConf);
790 categoryConf->dumpConf();
794 //--------------------------------------------------------------------------
800 //--------------------------------------------------------------------------
802 CicoSystemConfig::createAppKindConf(const ptree & root)
805 ptree appkinds = root.get_child("systemconfig.appkinds");
806 BOOST_FOREACH (const ptree::value_type& child, appkinds) {
807 optional<int> id = optional<int>(-1);
808 optional<string> name;
809 optional<string> privilege;
810 optional<int> priority = optional<int>(-1);
812 id = child.second.get_optional<int>("<xmlattr>.id");
813 if (false == id.is_initialized()) {
817 name = child.second.get_optional<string>("<xmlattr>.name");
818 if (false == name.is_initialized()) {
822 privilege = child.second.get_optional<string>("privilege");
823 if (false == name.is_initialized()) {
827 priority = child.second.get_optional<int>("priority");
828 if (false == priority.is_initialized()) {
832 CicoSCAppKindConf* appKindConf = new CicoSCAppKindConf();
833 appKindConf->id = id.get();
834 appKindConf->name = name.get();
835 appKindConf->privilege = m_privilegeTable[privilege.get()];
836 appKindConf->priority = priority.get();
837 m_appKindConfList.push_back(appKindConf);
838 appKindConf->dumpConf();
842 //--------------------------------------------------------------------------
848 //--------------------------------------------------------------------------
850 CicoSystemConfig::createInputDevList(const ptree & root)
853 ptree inputs = root.get_child("systemconfig.inputs");
854 BOOST_FOREACH (const ptree::value_type& child, inputs) {
855 optional<int> id = optional<int>(-1);
856 optional<string> name;
858 id = child.second.get_optional<int>("<xmlattr>.id");
859 if (false == id.is_initialized()) {
863 name = child.second.get_optional<string>("<xmlattr>.name");
864 if (false == name.is_initialized()) {
868 CicoSCInputDevConf* inputDevConf = new CicoSCInputDevConf();
869 inputDevConf->id = id.get();
870 inputDevConf->name = name.get();
871 inputDevConf->dumpConf();
873 createSwitchList(child, inputDevConf);
874 m_inputDevConfList.push_back(inputDevConf);
878 //--------------------------------------------------------------------------
884 //--------------------------------------------------------------------------
886 CicoSystemConfig::createSwitchList(const ptree::value_type & child,
887 CicoSCInputDevConf* inputDevConf)
889 ptree switchs = child.second.get_child("switchs");
890 BOOST_FOREACH (const ptree::value_type& zone, switchs) {
891 optional<int> id = optional<int>(-1);
892 optional<string> name;
893 optional<string> appid;
895 id = zone.second.get_optional<int>("<xmlattr>.id");
896 if (false == id.is_initialized()) {
900 name = zone.second.get_optional<string>("<xmlattr>.name");
901 if (false == name.is_initialized()) {
905 appid = zone.second.get_optional<string>("<xmlattr>.appid");
906 if (false == appid.is_initialized()) {
910 CicoSCSwitchConf* switchConf = new CicoSCSwitchConf();
911 switchConf->id = id.get();
912 switchConf->name = name.get();
913 switchConf->appid = appid.get();
914 switchConf->dumpConf();
915 inputDevConf->switchConfList.push_back(switchConf);
919 //--------------------------------------------------------------------------
925 //--------------------------------------------------------------------------
927 CicoSystemConfig::createDefaultConf(const ptree & root)
930 ptree defaults = root.get_child("systemconfig.default");
932 optional<string> node;
933 optional<string> appkind;
934 optional<string> category;
935 optional<string> display;
936 optional<string> layer;
937 optional<string> displayzone;
938 optional<string> sound;
939 optional<string> soundzone;
940 optional<string> inputdev;
941 optional<string> inputsw;
943 node = defaults.get_optional<string>("node");
944 if (false == node.is_initialized()) {
945 ICO_WRN("default.node element not found");
948 appkind = defaults.get_optional<string>("appkind");
949 if (false == appkind.is_initialized()) {
950 ICO_WRN("default.appkind element not found");
953 category = defaults.get_optional<string>("category");
954 if (false == category.is_initialized()) {
955 ICO_WRN("default.category element not found");
958 display = defaults.get_optional<string>("display");
959 if (false == display.is_initialized()) {
960 ICO_WRN("default.display element not found");
963 layer = defaults.get_optional<string>("layer");
964 if (false == layer.is_initialized()) {
965 ICO_WRN("default.layer element not found");
968 displayzone = defaults.get_optional<string>("displayzone");
969 if (false == displayzone.is_initialized()) {
970 ICO_WRN("default.displayzone element not found");
973 sound = defaults.get_optional<string>("sound");
974 if (false == sound.is_initialized()) {
975 ICO_WRN("default.sound element not found");
978 soundzone = defaults.get_optional<string>("soundzone");
979 if (false == soundzone.is_initialized()) {
980 ICO_WRN("default.soundzone element not found");
983 inputdev = defaults.get_optional<string>("inputdev");
984 if (false == inputdev.is_initialized()) {
985 ICO_WRN("default.inputdev element not found");
988 inputsw = defaults.get_optional<string>("inputsw");
989 if (false == inputsw.is_initialized()) {
990 ICO_WRN("default.inputdsw element not found");
993 m_defaultConf = new CicoSCDefaultConf();
995 m_defaultConf->node = getNodeIdbyName(node.get());
996 m_defaultConf->appkind = getAppKindIdbyName(appkind.get());
997 m_defaultConf->category = getCategoryIdbyName(category.get());
998 m_defaultConf->display = getDisplayIdbyName(display.get());
999 m_defaultConf->layer = getLayerIdfbyName(display.get(), layer.get());
1000 m_defaultConf->displayzone = getDizplayZoneIdbyName(display.get(),
1002 m_defaultConf->sound = getSoundIdbyName(sound.get());
1003 m_defaultConf->soundzone = getSoundZoneIdbyName(sound.get(),
1005 m_defaultConf->inputdev = getInputDevIdbyName(inputdev.get());
1006 m_defaultConf->inputsw = getSwitchIdbyName(inputdev.get(),
1009 #define ICO_SYC_TOP_EVN "SYSCON_TOPDIR"
1010 /* decide top directory in all configurations */
1011 const char *topdir = getenv(ICO_SYC_TOP_EVN);
1012 if (NULL == topdir) {
1013 topdir = tzplatform_mkpath(TZ_SYS_RO_APP, ICO_SYC_PACKAGE_SYSTEMCONTROLLER);
1015 m_defaultConf->topdir = topdir;
1017 #define ICO_SYC_CONFIG_ENV "SYSCON_CONFDIR"
1018 /* decide top directory in configuration file's */
1019 const char *confdir = getenv(ICO_SYC_CONFIG_ENV);
1020 if (NULL != confdir) {
1021 m_defaultConf->confdir = confdir;
1024 m_defaultConf->confdir = m_defaultConf->topdir;
1025 m_defaultConf->confdir.append("/");
1026 m_defaultConf->confdir.append(ICO_SYC_CONFIGPATH_PACKAGE_CONFIG);
1029 m_defaultConf->dumpConf();
1032 //--------------------------------------------------------------------------
1034 * @brief resource config class object create
1038 //--------------------------------------------------------------------------
1039 void getArray(ptree& t, vector<int>& vec);
1040 static const char* g_resource_cpu = "systemconfig.resource_cpu_control";
1042 CicoSystemConfig::createResourceConf(const ptree & root)
1044 m_resourceConf = new CicoSCResourceConf;
1045 ptree rc = root.get_child(g_resource_cpu);
1052 if ((CicoSCDefaultConf*)0 != m_defaultConf) {
1053 fPath = m_defaultConf->confdir;
1054 fPath += string("/");
1055 fPath += string("system_sysres.json");
1058 memset(&buff, 0, sizeof(buff));
1059 if (0 == stat(fPath.c_str(), &buff)) {
1060 read_json(fPath.c_str(), lcl_pt);
1066 if (boost::optional<std::string> function =
1067 lcl_pt.get_optional<std::string>("function")) {
1068 string v = function.get();
1069 if (0 == v.compare("yes")) {
1072 else if (0 == v.compare("app")) {
1078 ICO_WRN("NG json file(%s)", fPath.c_str());
1084 optional<string> opts = rc.get_optional<string>("do_it");
1085 if (true == opts.is_initialized()) {
1086 string v = opts.get();
1087 if (0 == v.compare("yes")) {
1090 else if (0 == v.compare("app")) {
1095 m_resourceConf->m_bDoIt = b;
1096 m_resourceConf->m_bDoItApp = bApp;
1101 if (boost::optional<std::string> ctrl_dir_path =
1102 lcl_pt.get_optional<std::string>("ctrl_dir_path")) {
1103 dirnm = ctrl_dir_path.get();
1107 ICO_WRN("NG json file(%s)", fPath.c_str());
1111 optional<string> opts2 = rc.get_optional<string>("ctrl_dir_path");
1112 if (true == opts2.is_initialized()) {
1113 dirnm = opts2.get();
1116 if (true == dirnm.empty()) {
1117 dirnm = "/sys/fs/cgroup/cpu,cpuacct/SCprivate";
1119 m_resourceConf->m_cpuCGRPPath = dirnm;
1123 optional<string> opts;
1125 opts = rc.get_optional<string>("sampling_wait");
1126 if (true == opts.is_initialized()) {
1127 m_resourceConf->m_sampling = atoi(opts.get().c_str());
1130 opts = rc.get_optional<string>("log");
1131 if (true == opts.is_initialized()) {
1132 string v = opts.get();
1133 if (0 == v.compare("true")) {
1134 m_resourceConf->m_bLog = true;
1138 opts = rc.get_optional<string>("retry_cnt");
1139 if (true == opts.is_initialized()) {
1140 m_resourceConf->m_retryCnt = atoi(opts.get().c_str());
1143 opts = rc.get_optional<string>("low_limit_value");
1144 if (true == opts.is_initialized()) {
1145 m_resourceConf->m_lowLimitVal = atoi(opts.get().c_str());
1148 opts = rc.get_optional<string>("high_limit_value");
1149 if (true == opts.is_initialized()) {
1150 m_resourceConf->m_highLimitVal = atoi(opts.get().c_str());
1153 BOOST_FOREACH(ptree::value_type& child, rc) {
1154 optional<int> id = optional<int>(-1);
1155 optional<string> name;
1156 id = child.second.get_optional<int>("<xmlattr>.id");
1157 if (false == id.is_initialized()) {
1160 name = child.second.get_optional<string>("<xmlattr>.name");
1161 if (false == name.is_initialized()) {
1164 ptree pth = child.second.get_child("hight_array");
1165 ptree ptl = child.second.get_child("low_array");
1167 CicoSCCpuResourceGrp* obj = new CicoSCCpuResourceGrp;
1168 obj->m_id = id.get();
1170 obj->m_grpNm = name.get();
1171 getArray(pth, obj->m_hight);
1172 getArray(ptl, obj->m_low);
1173 m_resourceConf->m_cpuCtrl.push_back(obj);
1175 m_resourceConf->dumpConf();
1178 //--------------------------------------------------------------------------
1180 * @brief vechicle information config class object create
1184 //--------------------------------------------------------------------------
1186 CicoSystemConfig::createVehicleInfoConf(const ptree & root)
1188 m_vehicleInfoConf = new CicoSCVehicleInfoConf();
1190 ptree child = root.get_child("systemconfig.vehicle_info");
1192 optional<int> retryCnt;
1193 optional<int> waitTime;
1195 retryCnt = child.get_optional<int>("retryCnt");
1196 if (false == retryCnt.is_initialized()) {
1197 ICO_WRN("vehicle_info.retryCnt element not found");
1198 retryCnt = optional<int>(0);
1201 waitTime = child.get_optional<int>("waitTime");
1202 if (false == waitTime.is_initialized()) {
1203 ICO_WRN("vehicle_info.waitTime element not found");
1204 waitTime = optional<int>(0);
1207 m_vehicleInfoConf->retryCnt = retryCnt.get();
1208 m_vehicleInfoConf->waitTime = waitTime.get();
1210 BOOST_FOREACH (const ptree::value_type& vinfo, child) {
1212 optional<string> name;
1213 optional<string> objname;
1214 optional<string> property;
1216 optional<string> type;
1218 id = vinfo.second.get_optional<int>("<xmlattr>.id");
1219 if (false == id.is_initialized()) {
1223 name = vinfo.second.get_optional<string>("<xmlattr>.name");
1224 if (false == name.is_initialized()) {
1228 property = vinfo.second.get_optional<string>("property");
1229 if (false == property.is_initialized()) {
1233 objname = vinfo.second.get_optional<string>("objname");
1234 if (false == objname.is_initialized()) {
1238 zone = vinfo.second.get_optional<int>("zone");
1239 if (false == zone.is_initialized()) {
1243 type = vinfo.second.get_optional<string>("type");
1244 if (false == type.is_initialized()) {
1248 CicoSCVIPropertyConf* viprop = new CicoSCVIPropertyConf();
1249 viprop->id = id.get();
1250 viprop->name = name.get();
1251 viprop->objname = objname.get();
1252 viprop->property = property.get();
1253 viprop->zone = zone.get();
1254 viprop->typestr = type.get();
1255 viprop->type = viprop->typeStrToInt(viprop->typestr);
1256 m_vehicleInfoConf->properties[id.get()] = viprop;
1259 m_vehicleInfoConf->dumpConf();
1262 //--------------------------------------------------------------------------
1264 * @brief user config class object create
1268 //--------------------------------------------------------------------------
1269 static const char* g_login_user_conf = "systemconfig.login_user";
1271 CicoSystemConfig::createUserConf(const ptree & root)
1273 m_userConf = new CicoSCUserConf;
1274 ptree rc = root.get_child(g_login_user_conf);
1275 optional<string> opts = rc.get_optional<string>("parent_dir");
1276 if (true == opts.is_initialized()) {
1277 string v = opts.get();
1279 m_userConf->m_parent_dir = tzplatform_mkpath(TZ_USER_HOME, v.c_str());
1282 if (m_userConf->m_parent_dir.empty()) {
1283 m_userConf->m_parent_dir = tzplatform_mkpath(TZ_USER_HOME, ICO_SYC_CONFIGPATH_HOME);
1285 m_userConf->dumpConf();
1288 //--------------------------------------------------------------------------
1294 //--------------------------------------------------------------------------
1296 CicoSystemConfig::calcGeometryExpr(const string & expr,
1297 CicoSCDisplayConf* conf)
1306 for (i = 0; ; i++) {
1307 if (expr[i] == ' ') continue;
1308 if ((expr[i] == 0) || (expr[i] == '+') || (expr[i] == '-') ||
1309 (expr[i] == '*') || (expr[i] == '-') || (expr[i] == '/')) {
1312 if ((strcasecmp(word, "dispw") == 0) ||
1313 (strcasecmp(word, "width") == 0)) {
1316 else if ((strcasecmp(word, "disph") == 0) ||
1317 (strcasecmp(word, "heigh") == 0)) {
1318 wval = conf->height;
1321 wval = strtol(word, (char **)0, 0);
1327 switch (sign % 10) {
1328 case 0: /* assign */
1347 if (expr[i] == '+') sign = 1;
1348 else if (expr[i] == '-') sign = 2;
1349 else if (expr[i] == '*') sign = 3;
1350 else if (expr[i] == '/') sign = 4;
1354 if ((sign > 0) && (expr[i] == '-')) {
1358 if (expr[i] == '+') sign = 1;
1359 else if (expr[i] == '-') sign = 2;
1360 else if (expr[i] == '*') sign = 3;
1361 else if (expr[i] == '/') sign = 4;
1365 if (expr[i] == 0) break;
1368 if (j < ((int)sizeof(word)-1)) {
1369 word[j++] = expr[i];
1376 //--------------------------------------------------------------------------
1382 //--------------------------------------------------------------------------
1383 const CicoSCNodeConf*
1384 CicoSystemConfig::findNodeConfbyName(const string & name)
1386 vector<CicoSCNodeConf*>::const_iterator itr;
1387 itr = m_nodeConfList.begin();
1388 for (; itr != m_nodeConfList.end(); ++itr) {
1389 const CicoSCNodeConf* conf = (*itr);
1390 if (name == conf->name) {
1398 //--------------------------------------------------------------------------
1404 //--------------------------------------------------------------------------
1405 const CicoSCDisplayConf*
1406 CicoSystemConfig::findDisplayConfbyName(const string & name)
1408 vector<CicoSCDisplayConf*>::const_iterator itr;
1409 itr = m_displayConfList.begin();
1410 for (; itr != m_displayConfList.end(); ++itr) {
1411 const CicoSCDisplayConf* conf = (*itr);
1412 if (name == conf->name) {
1420 //--------------------------------------------------------------------------
1426 //--------------------------------------------------------------------------
1427 const CicoSCDisplayConf*
1428 CicoSystemConfig::findDisplayConfbyName(const string& ECU, const string& name)
1430 int nodeId = getNodeIdbyName(ECU);
1431 vector<CicoSCDisplayConf*>::const_iterator itr;
1432 itr = m_displayConfList.begin();
1433 for (; itr != m_displayConfList.end(); ++itr) {
1434 const CicoSCDisplayConf* conf = (*itr);
1435 if ((name == conf->name)&&(nodeId == conf->node)) {
1443 //--------------------------------------------------------------------------
1449 //--------------------------------------------------------------------------
1450 const CicoSCDisplayConf*
1451 CicoSystemConfig::findDisplayConfbyId(int id)
1453 vector<CicoSCDisplayConf*>::const_iterator itr;
1454 itr = m_displayConfList.begin();
1455 for (; itr != m_displayConfList.end(); ++itr) {
1456 const CicoSCDisplayConf* conf = (*itr);
1457 if (id == conf->id) {
1464 //--------------------------------------------------------------------------
1470 //--------------------------------------------------------------------------
1471 const CicoSCLayerConf*
1472 CicoSystemConfig::findLayerConfbyName(const string & displayName,
1473 const string & layerName)
1475 const CicoSCDisplayConf* displayConf = NULL;
1476 displayConf = findDisplayConfbyName(displayName);
1477 if (NULL == displayConf) {
1481 vector<CicoSCLayerConf*>::const_iterator itr;
1482 itr = displayConf->layerConfList.begin();
1483 for (; itr != displayConf->layerConfList.end(); ++itr) {
1484 const CicoSCLayerConf* conf = (*itr);
1485 // if (layerName == conf->name) {
1486 if ((layerName == conf->name) && (-1 == conf->layout_id)) {
1494 //--------------------------------------------------------------------------
1500 //--------------------------------------------------------------------------
1501 const CicoSCLayerConf*
1502 CicoSystemConfig::findLayerConfbyName(const string& ECU,
1503 const string& display,
1504 const string& layer,
1505 const string& layout,
1508 const CicoSCDisplayConf* displayConf = NULL;
1509 displayConf = findDisplayConfbyName(ECU, display);
1510 if (NULL == displayConf) {
1514 vector<CicoSCLayerConf*>::const_iterator itr;
1515 itr = displayConf->layerConfList.begin();
1516 for (; itr != displayConf->layerConfList.end(); ++itr) {
1517 const CicoSCLayerConf* conf = (*itr);
1518 if ((layer == conf->name)&&(layout == conf->layout_name)&&
1519 (area == conf->area_name)) {
1527 //--------------------------------------------------------------------------
1533 //--------------------------------------------------------------------------
1534 const CicoSCLayerConf*
1535 CicoSystemConfig::findLayerConfbyIdx(int displayid, int idx)
1537 const CicoSCDisplayConf* displayConf = NULL;
1538 displayConf = findDisplayConfbyId(displayid);
1539 if (NULL == displayConf) {
1543 vector<CicoSCLayerConf*>::const_iterator itr;
1544 itr = displayConf->layerConfList.begin();
1545 for (; itr != displayConf->layerConfList.end(); ++itr) {
1546 const CicoSCLayerConf* conf = (*itr);
1555 //--------------------------------------------------------------------------
1561 //--------------------------------------------------------------------------
1562 const CicoSCDisplayZoneConf*
1563 CicoSystemConfig::findDisplayZoneConfbyName(const string & displayName,
1564 const string & zoneName)
1566 // ICO_TRA("CicoSystemConfig::findDisplayZoneConfbyName Enter"
1567 // "(displayName=%s zoneNmae=%s)",
1568 // displayName.c_str(), zoneName.c_str());
1570 const CicoSCDisplayConf* displayConf = NULL;
1571 displayConf = findDisplayConfbyName(displayName);
1572 if (NULL == displayConf) {
1573 // ICO_TRA("CicoSystemConfig::findDisplayZoneConfbyName Leave(NULL)");
1577 vector<CicoSCDisplayZoneConf*>::const_iterator itr;
1578 itr = displayConf->zoneConfList.begin();
1579 for (; itr != displayConf->zoneConfList.end(); ++itr) {
1580 const CicoSCDisplayZoneConf* conf = (*itr);
1581 if (zoneName == conf->name) {
1582 // ICO_TRA("CicoSystemConfig::findDisplayZoneConfbyName Leave"
1583 // "(0x%08x)", conf);
1588 // ICO_TRA("CicoSystemConfig::findDisplayZoneConfbyName Leave(NULL)");
1592 //--------------------------------------------------------------------------
1598 //--------------------------------------------------------------------------
1599 const CicoSCSoundConf*
1600 CicoSystemConfig::findSoundConfbyName(const string & name)
1602 vector<CicoSCSoundConf*>::const_iterator itr;
1603 itr = m_soundConfList.begin();
1604 for (; itr != m_soundConfList.end(); ++itr) {
1605 const CicoSCSoundConf* conf = (*itr);
1606 if (name == conf->name) {
1614 //--------------------------------------------------------------------------
1620 //--------------------------------------------------------------------------
1621 const CicoSCSoundZoneConf*
1622 CicoSystemConfig::findSoundZoneConfbyName(const string & soundName,
1623 const string & zoneName)
1625 // ICO_TRA("CicoSystemConfig::findSoundZoneConfbyName Enter"
1626 // "(soundName=%s zoneNmae=%s)",
1627 // soundName.c_str(), zoneName.c_str());
1629 const CicoSCSoundConf* soundConf = NULL;
1630 soundConf = findSoundConfbyName(soundName);
1631 if (NULL == soundConf) {
1635 vector<CicoSCSoundZoneConf*>::const_iterator itr;
1636 itr = soundConf->zoneConfList.begin();
1637 for (; itr != soundConf->zoneConfList.end(); ++itr) {
1638 const CicoSCSoundZoneConf* conf = (*itr);
1639 if (zoneName == conf->name) {
1647 //--------------------------------------------------------------------------
1653 //--------------------------------------------------------------------------
1654 const CicoSCInputDevConf*
1655 CicoSystemConfig::findInputDevConfbyName(const string & name)
1657 vector<CicoSCInputDevConf*>::const_iterator itr;
1658 itr = m_inputDevConfList.begin();
1659 for (; itr != m_inputDevConfList.end(); ++itr) {
1660 const CicoSCInputDevConf* conf = (*itr);
1661 if (name == conf->name) {
1669 //--------------------------------------------------------------------------
1675 //--------------------------------------------------------------------------
1676 const CicoSCSwitchConf*
1677 CicoSystemConfig::findSwitchConfbyName(const string & inputDevName,
1678 const string & switchName)
1680 const CicoSCInputDevConf* inputDevConf = NULL;
1681 inputDevConf = findInputDevConfbyName(inputDevName);
1682 if (NULL == inputDevConf) {
1683 ICO_WRN("name(%s) input device config not found.",
1684 inputDevName.c_str());
1688 vector<CicoSCSwitchConf*>::const_iterator itr;
1689 itr = inputDevConf->switchConfList.begin();
1690 for (; itr != inputDevConf->switchConfList.end(); ++itr) {
1691 const CicoSCSwitchConf* conf = (*itr);
1692 if (switchName == conf->name) {
1697 ICO_WRN("name(%s) switch config not found.", switchName.c_str());
1701 //--------------------------------------------------------------------------
1707 //--------------------------------------------------------------------------
1708 const CicoSCAppKindConf*
1709 CicoSystemConfig::findAppKindConfbyName(const string & name)
1711 vector<CicoSCAppKindConf*>::const_iterator itr;
1712 itr = m_appKindConfList.begin();
1713 for (; itr != m_appKindConfList.end(); ++itr) {
1714 const CicoSCAppKindConf* conf = (*itr);
1715 if (name == conf->name) {
1723 //--------------------------------------------------------------------------
1729 //--------------------------------------------------------------------------
1730 const CicoSCDisplayZoneConf*
1731 CicoSystemConfig::findDisplayZoneConfbyId(int id)
1733 vector<CicoSCDisplayConf*>::const_iterator itr;
1734 itr = m_displayConfList.begin();
1735 for (; itr != m_displayConfList.end(); ++itr) {
1736 vector<CicoSCDisplayZoneConf*>::const_iterator itr2;
1737 itr2 = (*itr)->zoneConfList.begin();
1738 for (; itr2 != (*itr)->zoneConfList.end(); ++itr2) {
1739 if (id == (*itr2)->id) {
1748 //--------------------------------------------------------------------------
1754 //--------------------------------------------------------------------------
1755 const CicoSCSoundZoneConf*
1756 CicoSystemConfig::findSoundZoneConfbyId(int id)
1758 vector<CicoSCSoundConf*>::const_iterator itr;
1759 itr = m_soundConfList.begin();
1760 for (; itr != m_soundConfList.end(); ++itr) {
1761 vector<CicoSCSoundZoneConf*>::const_iterator itr2;
1762 itr2 = (*itr)->zoneConfList.begin();
1763 for (; itr2 != (*itr)->zoneConfList.end(); ++itr2) {
1764 if (id == (*itr2)->id) {
1773 //--------------------------------------------------------------------------
1779 //--------------------------------------------------------------------------
1780 const CicoSCCategoryConf*
1781 CicoSystemConfig::findCategoryConfbyName(const string & name)
1783 vector<CicoSCCategoryConf*>::const_iterator itr;
1784 itr = m_categoryConfList.begin();
1785 for (; itr != m_categoryConfList.end(); ++itr) {
1786 const CicoSCCategoryConf* conf = (*itr);
1787 if (name == conf->name) {
1788 //return const_cast<CicoSCCategoryConf*>(itr->pointer);
1796 //--------------------------------------------------------------------------
1802 //--------------------------------------------------------------------------
1803 const CicoSCCategoryConf*
1804 CicoSystemConfig::findCategoryConfbyId(int id)
1806 vector<CicoSCCategoryConf*>::const_iterator itr;
1807 itr = m_categoryConfList.begin();
1808 for (; itr != m_categoryConfList.end(); ++itr) {
1809 const CicoSCCategoryConf* conf = (*itr);
1810 if (id == conf->id) {
1818 //--------------------------------------------------------------------------
1824 //--------------------------------------------------------------------------
1825 const CicoSCAppKindConf *
1826 CicoSystemConfig::findAppKindConfbyId(int id)
1828 vector<CicoSCAppKindConf*>::const_iterator itr;
1829 itr = m_appKindConfList.begin();
1830 for (; itr != m_appKindConfList.end(); ++itr) {
1831 if (id == (*itr)->id) {
1839 //--------------------------------------------------------------------------
1845 //--------------------------------------------------------------------------
1846 const CicoSCDefaultConf*
1847 CicoSystemConfig::getDefaultConf(void)
1849 return m_defaultConf;
1852 //--------------------------------------------------------------------------
1858 //--------------------------------------------------------------------------
1860 CicoSystemConfig::getNodeIdbyName(const string & name)
1862 const CicoSCNodeConf* conf = NULL;
1863 conf = findNodeConfbyName(name);
1871 //--------------------------------------------------------------------------
1877 //--------------------------------------------------------------------------
1879 CicoSystemConfig::getDisplayIdbyName(const string & name)
1881 const CicoSCDisplayConf* conf = NULL;
1882 conf = findDisplayConfbyName(name);
1890 //--------------------------------------------------------------------------
1896 //--------------------------------------------------------------------------
1898 CicoSystemConfig::getDisplayIdbyNo(int no)
1900 vector<CicoSCDisplayConf*>::const_iterator itr;
1901 itr = m_displayConfList.begin();
1902 for (; itr != m_displayConfList.end(); ++itr) {
1903 const CicoSCDisplayConf* conf = (*itr);
1904 if (no == conf->no) {
1911 //--------------------------------------------------------------------------
1917 //--------------------------------------------------------------------------
1919 CicoSystemConfig::getDisplayIdbyType(int type)
1921 vector<CicoSCDisplayConf*>::const_iterator itr;
1922 itr = m_displayConfList.begin();
1923 for (; itr != m_displayConfList.end(); ++itr) {
1924 const CicoSCDisplayConf* conf = (*itr);
1925 if (type == conf->type) {
1932 //--------------------------------------------------------------------------
1938 //--------------------------------------------------------------------------
1940 CicoSystemConfig::getNumberofDisplay(void)
1945 //--------------------------------------------------------------------------
1951 //--------------------------------------------------------------------------
1953 CicoSystemConfig::getLayerIdfbyName(const string & displayName,
1954 const string & layerName)
1956 const CicoSCLayerConf* conf = NULL;
1957 conf = findLayerConfbyName(displayName, layerName);
1965 //--------------------------------------------------------------------------
1971 //--------------------------------------------------------------------------
1973 CicoSystemConfig::getLayerIdfbyName(const string& ECU,
1974 const string& display,
1975 const string& layer,
1976 const string& layout,
1979 const CicoSCLayerConf* conf = NULL;
1980 conf = findLayerConfbyName(ECU, display, layer, layout, area);
1988 //--------------------------------------------------------------------------
1994 //--------------------------------------------------------------------------
1996 CicoSystemConfig::getDizplayZoneIdbyName(const string & displayName,
1997 const string & zoneName)
1999 const CicoSCDisplayZoneConf* conf = NULL;
2000 conf = findDisplayZoneConfbyName(displayName, zoneName);
2008 //--------------------------------------------------------------------------
2014 //--------------------------------------------------------------------------
2016 CicoSystemConfig::getDizplayZoneIdbyFullName(const string & zoneFullName)
2018 string::size_type index = zoneFullName.find(".", 0);
2019 if (string::npos == index) {
2022 string displayName = zoneFullName.substr(0, index);
2023 string zoneName = zoneFullName.substr(index+1);
2025 const CicoSCDisplayZoneConf* conf = NULL;
2026 conf = findDisplayZoneConfbyName(displayName, zoneName);
2034 //--------------------------------------------------------------------------
2040 //--------------------------------------------------------------------------
2042 CicoSystemConfig::getSoundIdbyName(const string & name)
2044 const CicoSCSoundConf* conf = NULL;
2045 conf = findSoundConfbyName(name);
2053 //--------------------------------------------------------------------------
2059 //--------------------------------------------------------------------------
2061 CicoSystemConfig::getSoundZoneIdbyName(const string & soundName,
2062 const string & zoneName)
2064 const CicoSCSoundZoneConf* conf = NULL;
2065 conf = findSoundZoneConfbyName(soundName, zoneName);
2073 //--------------------------------------------------------------------------
2079 //--------------------------------------------------------------------------
2081 CicoSystemConfig::getSoundZoneIdbyFullName(const string & zoneFullName)
2083 string::size_type index = zoneFullName.find(".", 0);
2084 if (string::npos == index) {
2087 string soundName = zoneFullName.substr(0, index);
2088 string zoneName = zoneFullName.substr(index+1);
2090 const CicoSCSoundZoneConf* conf = NULL;
2091 conf = findSoundZoneConfbyName(soundName, zoneName);
2099 //--------------------------------------------------------------------------
2105 //--------------------------------------------------------------------------
2107 CicoSystemConfig::getInputDevIdbyName(const string & name)
2109 const CicoSCInputDevConf* conf = NULL;
2110 conf = findInputDevConfbyName(name);
2118 //--------------------------------------------------------------------------
2124 //--------------------------------------------------------------------------
2126 CicoSystemConfig::getSwitchIdbyName(const string & inputDevName,
2127 const string & switchName)
2129 const CicoSCSwitchConf* conf = NULL;
2130 conf = findSwitchConfbyName(inputDevName, switchName);
2138 //--------------------------------------------------------------------------
2144 //--------------------------------------------------------------------------
2146 CicoSystemConfig::getAppKindIdbyName(const string & name)
2148 const CicoSCAppKindConf* conf = NULL;
2149 conf = findAppKindConfbyName(name);
2157 //--------------------------------------------------------------------------
2163 //--------------------------------------------------------------------------
2165 CicoSystemConfig::getCategoryIdbyName(const string & name)
2167 const CicoSCCategoryConf* conf = NULL;
2168 conf = findCategoryConfbyName(name);
2176 //--------------------------------------------------------------------------
2178 * @brief get category config object class
2182 //--------------------------------------------------------------------------
2183 const CicoSCCategoryConf*
2184 CicoSystemConfig::getCategoryObjbyCaategoryID(int id)
2189 vector<CicoSCCategoryConf*>::const_iterator itr;
2190 itr = m_categoryConfList.begin();
2191 for (; itr != m_categoryConfList.end(); ++itr) {
2192 const CicoSCCategoryConf* conf = (*itr);
2193 if (id == conf->id) {
2194 //return const_cast<CicoSCCategoryConf*>(itr->pointer);
2201 //--------------------------------------------------------------------------
2203 * @brief array xml tree to vector<int>
2207 //--------------------------------------------------------------------------
2208 CicoSCVehicleInfoConf*
2209 CicoSystemConfig::getVehicleInfoConf(void)
2211 return m_vehicleInfoConf;
2214 //--------------------------------------------------------------------------
2216 * @brief array xml tree to vector<int>
2220 //--------------------------------------------------------------------------
2221 void getArray(ptree& t, vector<int>& vec)
2224 BOOST_FOREACH (const ptree::value_type& child, t) {
2225 const int value = lexical_cast<int>(child.second.data());
2226 vec.push_back(value);
2230 //--------------------------------------------------------------------------
2232 * @brief get state number from id key
2236 //--------------------------------------------------------------------------
2237 short CicoSystemConfig::getRoleStt(const string& key)
2239 if ((CicoSCRoleConf*)NULL == m_roleConf) {
2240 return ICO_SYC_ROLE_CONF_DEF;
2243 map<string, short>::iterator p;
2244 p = m_roleConf->m_stt.find(key);
2245 if (p == m_roleConf->m_stt.end()) {
2246 r = m_roleConf->m_def;
2254 //--------------------------------------------------------------------------
2256 * @brief array xml tree to vector<int>
2260 //--------------------------------------------------------------------------
2261 void CicoSystemConfig::createRoleConf(const ptree& root)
2263 m_roleConf = new CicoSCRoleConf();
2265 ptree roles = root.get_child("systemconfig.on_screen_roles");
2266 BOOST_FOREACH (const ptree::value_type& role, roles) {
2267 optional<string> id;
2269 id = role.second.get_optional<string>("<xmlattr>.id");
2270 if (false == id.is_initialized()) {
2273 stt = role.second.get_optional<int>("<xmlattr>.state");
2274 if (false == stt.is_initialized()) {
2277 string v_key = id.get();
2278 int v_stt = stt.get();
2279 if (0 == v_key.compare(ICO_SYC_ROLE_CONF_DEF_STR)) { // default define
2280 m_roleConf->m_def = (short)v_stt;
2282 else if (0 == v_key.compare(ICO_SYC_ROLE_CONF_RST_STR)) { // reset event number
2283 m_roleConf->m_rst = (short)v_stt;
2286 m_roleConf->m_stt.insert(pair<string, short>(v_key, (short)v_stt));
2289 m_roleConf->dumpConf();
2292 //--------------------------------------------------------------------------
2294 * @brief position OnScreen Config
2298 //--------------------------------------------------------------------------
2299 void CicoSystemConfig::createPositionOSConf(const ptree& root)
2301 ptree posc = root.get_child("systemconfig.on_screen_position");
2303 int x = ICO_SYC_ONSCREEN_WINDOW_START_X;
2304 int y = ICO_SYC_ONSCREEN_WINDOW_START_Y;
2305 int w = ICO_SYC_ONSCREEN_WINDOW_WIDTH;
2306 int h = ICO_SYC_ONSCREEN_WINDOW_HEIGHT;
2308 optional<string> optsx = posc.get_optional<string>("x");
2309 if (true == optsx.is_initialized()) {
2310 x = atoi(optsx.get().c_str());
2313 optional<string> optsy = posc.get_optional<string>("y");
2314 if (true == optsy.is_initialized()) {
2315 y = atoi(optsy.get().c_str());
2318 optional<string> optsw = posc.get_optional<string>("w");
2319 if (true == optsw.is_initialized()) {
2320 w = atoi(optsw.get().c_str());
2323 optional<string> optsh = posc.get_optional<string>("h");
2324 if (true == optsh.is_initialized()) {
2325 h = atoi(optsh.get().c_str());
2328 m_positionOSConf = new CicoSCPositionOSConf(x, y, w, h);
2329 m_positionOSConf->dumpConf();
2332 // vim:set expandtab ts=4 sw=4: