2 * Copyright (c) 2013 TOYOTA MOTOR CORPORATION.
6 * Licensed under the Apache License, Version 2.0 (the License){}
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an AS IS BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
20 #ifndef CICOSTATEMACHINECREATOR_H
21 #define CICOSTATEMACHINECREATOR_H
25 #include "CicoBlockParser.h"
26 #include "CicoEventInfo.h"
28 #ifndef CICOSTATECORE_H
32 #ifndef CICOSTATEMACHINE_H
33 class CicoStateMachine;
40 #ifndef CICOFINALSTATE_H
44 #ifndef CICOHISTORYSTATE_H
45 class CicoHistoryState;
48 #define DKstateMachine "stateMachine"
49 #define DKstate "state"
50 #define DKfinalState "finalState"
51 #define DKhistoryState "historyState"
52 #define DKevent "event"
56 #define DKvalue "value"
58 #define DKinitial "initial"
59 #define DKinitial2 "i"
60 #define DKfinish "finish"
62 #define DKdefault "default"
63 #define DKdefault2 "d"
64 #define DKguardCondition "guardCondition"
65 #define DKguardCondition2 "g"
66 #define DKoperator "operator"
67 #define DKoperator2 "o"
68 #define DKtransition "transition"
69 #define DKtransition2 "t"
72 #define DKvalued "valued"
73 #define DKvalued2 "vd"
77 #define DVShallow "Shallow"
84 * StateMachine-Object creator
90 * @brief The CicoStateMachineCreator class
91 * @ state-machine produce from the definition file or string
93 class CicoStateMachineCreator
96 CicoStateMachine* createFile(const std::string& filename);
98 CicoStateMachine* create(const char* sttdef);
99 const std::string& getError();
102 void CreateStateObjects(CicoBlockParser& cbp,
103 CicoStateCore* parent = 0);
104 void CreateStateMachine(CicoBlockParser& cbp);
105 void CreateState(CicoBlockParser& cbp, CicoStateCore* parent);
106 void CreateHistoryState(CicoBlockParser& cbp,
107 CicoStateCore* parent);
108 void CreateFinalState(CicoBlockParser& cbp, CicoStateCore* parent);
110 void setConnect(CicoBlockParser& cbp, CicoStateMachine* csm,
111 CicoStateCore* parent=0);
113 void setConnectStateMachine(CicoBlockParser& cbp,
114 CicoStateMachine* csm);
115 void setConnectState(CicoBlockParser& cbp, CicoStateMachine* csm);
116 void setConnectHistoryState(CicoBlockParser& cbp,
117 CicoStateMachine* csm);
118 void setInitial(CicoBlockParser& cbp, const char* key,
119 CicoStateMachine* csm);
120 void addInitial(CicoStateCore* tgt, CicoStateCore* dat);
122 void setFinish(CicoBlockParser& cbp, const char* key,
123 CicoStateMachine* csm);
125 void setDefault(CicoBlockParser& cbp, CicoHistoryState* chs,
126 CicoStateMachine* csm);
127 void addDefault(CicoHistoryState* chs, CicoStateCore* csc);
130 void CreateEvent(CicoBlockParser& cbp, CicoStateMachine* csm,
131 CicoStateCore* parent);
133 bool regGuardCondition(picojson::value& v, CicoEventInfo& evi);
134 void setGuardCondition(CicoEventInfo& evi, picojson::object& o);
136 bool getJsonString(picojson::value& v, std::string& str);
137 bool getJsonNumber(picojson::value& v, int& num);
138 bool getJsonDouble(picojson::value& v, double& d);
139 bool parseName(picojson::object& o, std::string& nm);
141 bool parseValueI(picojson::object& o, int& v);
142 bool parseValueIS(picojson::object& o, int& n, std::string& s);
144 bool parseValuedD(picojson::object& o, double& v);
146 bool parseHistoryType(picojson::object& o,
147 CicoHistoryState::E_HType& e);
149 bool parseStateObject(picojson::value& v,
150 std::vector<CicoStateCore*>& vec,
151 CicoStateMachine* csm, std::string& err);
153 bool parseOperator(picojson::object& o, std::string& op);
154 bool parseJoin(picojson::object& o, std::string& j);
162 * @brief CicoStateMachineCreator::getError
163 * @ get error message
164 * @return error message
166 inline const std::string& CicoStateMachineCreator::getError()
171 #endif // CICOSTATEMACHINECREATOR_H