Adding context automaton
This commit is contained in:
31
rs.cc
31
rs.cc
@@ -168,3 +168,34 @@ void RctSys::printSystem(void)
|
|||||||
showReactions();
|
showReactions();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool CtxAut::hasState(std::string name)
|
||||||
|
{
|
||||||
|
if (states_names.find(name) == states_names.end())
|
||||||
|
return false;
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CtxAut::addState(std::string name)
|
||||||
|
{
|
||||||
|
if (!hasState(name))
|
||||||
|
{
|
||||||
|
State new_state_id = states_ids.size();
|
||||||
|
|
||||||
|
VERB_L2("Adding state: " << name << " index=" << new_state_id);
|
||||||
|
|
||||||
|
states_ids.push_back(name);
|
||||||
|
states_names[name] = new_state_id;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void CtxAut::pushContextEntity(std::string entityName)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void CtxAut::addTransition(std::string srcStateName, std::string dstStateName)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|||||||
22
rs.hh
22
rs.hh
@@ -26,7 +26,6 @@ class RctSys
|
|||||||
{
|
{
|
||||||
friend class SymRS;
|
friend class SymRS;
|
||||||
friend class SymRSstate;
|
friend class SymRSstate;
|
||||||
friend class CtxAut;
|
|
||||||
public:
|
public:
|
||||||
typedef unsigned int Entity;
|
typedef unsigned int Entity;
|
||||||
typedef std::set<Entity> Entities;
|
typedef std::set<Entity> Entities;
|
||||||
@@ -98,17 +97,36 @@ public:
|
|||||||
|
|
||||||
class RctSysWithCtxAut : private RctSys
|
class RctSysWithCtxAut : private RctSys
|
||||||
{
|
{
|
||||||
|
friend class CtxAut;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Context Automaton
|
// Context Automaton
|
||||||
class CtxAut
|
class CtxAut
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
typedef unsigned int State;
|
typedef unsigned int State;
|
||||||
typedef std::set<State> States;
|
typedef std::vector<std::string> StatesById;
|
||||||
|
typedef std::map<std::string, State> StatesByName;
|
||||||
struct Transition {
|
struct Transition {
|
||||||
State src_state;
|
State src_state;
|
||||||
|
RctSys::Entities ctx;
|
||||||
State dst_state;
|
State dst_state;
|
||||||
};
|
};
|
||||||
|
bool hasState(std::string name);
|
||||||
|
void addState(std::string stateName);
|
||||||
|
void addTransition(std::string srcStateName, std::string dstStateName);
|
||||||
|
void pushContextEntity(std::string entityName);
|
||||||
|
void setOptions(Options *opts)
|
||||||
|
{
|
||||||
|
this->opts = opts;
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
Options *opts;
|
||||||
|
StatesById states_ids;
|
||||||
|
StatesByName states_names;
|
||||||
|
RctSys::Entities tmpEntities;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user