state.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 1997-2017 JDERobot Developers Team
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU Library General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program; if not, see <http://www.gnu.org/licenses/>.
16 
17  Authors : Okan Asik (asik.okan@gmail.com)
18 
19 */
20 #ifndef STATE_H
21 #define STATE_H
22 
23 #include <vector>
24 #include <map>
25 #include "transition.h"
26 #include "runtimegui.h"
27 
28 class State {
29 protected:
30  int id;
31  bool active;
32  bool running;
35  bool initial;
36  bool displayGui;
38 
39  std::vector<State*> states;
40  std::vector<Transition*> transitions;
41  std::map<int, State*> statesById;
42 
44  pthread_t thread;
45 
46 public:
47  State(int id, bool initial, int cycleDuration, State* parent, RunTimeGui* gui);
48 
49  void init();
50  void addState(State* state);
51  void addTransition(Transition* transition);
52  void startThread();
53  void run();
54  void stop();
55  void join();
56  long getCurrentTime();
57 
58  virtual void runCode() {}
59 
60  static void* threadRunner(void*);
61 
62 };
63 
64 #endif
void init()
Definition: state.cpp:39
long getCurrentTime()
Definition: state.cpp:129
static void * threadRunner(void *)
Definition: state.cpp:74
bool displayGui
Definition: state.h:36
bool initial
Definition: state.h:35
int id
Definition: state.h:30
virtual void runCode()
Definition: state.h:58
State(int id, bool initial, int cycleDuration, State *parent, RunTimeGui *gui)
Definition: state.cpp:25
bool active
Definition: state.h:31
RunTimeGui * gui
Definition: state.h:43
State * parent
Definition: state.h:33
Definition: state.h:28
void addTransition(Transition *transition)
Definition: state.cpp:70
std::vector< State * > states
Definition: state.h:39
void join()
Definition: state.cpp:135
void run()
Definition: state.cpp:82
void stop()
Definition: state.cpp:125
void addState(State *state)
Definition: state.cpp:61
State * currentState
Definition: state.h:34
std::map< int, State * > statesById
Definition: state.h:41
std::vector< Transition * > transitions
Definition: state.h:40
pthread_t thread
Definition: state.h:44
int cycleDuration
Definition: state.h:37
void startThread()
Definition: state.cpp:78
bool running
Definition: state.h:32


visualstates
Author(s):
autogenerated on Thu Apr 1 2021 02:42:20