1 #ifndef __DIADES__AUTOMATA__EVENT__HH 2 #define __DIADES__AUTOMATA__EVENT__HH 13 #include<unordered_map> 23 using std::unordered_map;
55 static string typeName() {
return "Automata::Event"; }
105 static void allocateEvents(
size_t capacity);
111 static void destroyEvents();
124 Event(EventDataPointer data):_ptr(data) {}
172 bool isValid()
const {
return _ptr !=
nullptr; }
180 const Label & label()
const;
191 require(Exception,isValid(),
"nickname: the event is invalid.");
208 require(Exception,isValid(),
"id: the event is invalid.");
224 bool operator < (
const Event & e)
const {
225 if( (!isValid()) && (!e.
isValid()))
237 return id() < e.
id();
245 bool operator == (
const Event & e)
const {
248 return (
id() == e.
id() );
250 return (!isValid()) && (!e.
isValid());
258 bool operator != (
const Event & e)
const {
259 return !(*
this == e);
269 bool operator > (
const Event & e)
const {
270 return !( ((*this) < e) || ((*
this) == e));
293 return os << e.
label();
302 friend istream & operator >>(istream & is,
Event & e);
311 ostream &
save(ostream & os)
const 313 require(Exception,isValid(),
"save: invalid event");
314 return os << id() <<
" " << label() <<
" " << nickname();
322 istream &
load(istream & is);
359 static string typeName() {
return "Automata::EventFactory"; }
const Label & label() const
ostream & save(ostream &os) const
Event getEvent(Event::Id id)
const Label & nickname() const
void load(Archive &ar, std::unordered_map< Key, HashFcn, EqualKey, Allocator > &t, const unsigned int)
static void init(size_t capacity)
Event::Label _nullEventLabel
DdAutFsm::EventPropertyId Event
Event setEvent(Event::Id id, const Event::Label &label, const Event::Label &nick)
static EventFactory * _instance
size_t operator()(const Diades::Automata::Event &e) const
#define require(Exception, expr, message)
Namespace of the Diades project.
Event(EventDataPointer data)
Diades::Utils::Exception< Event > Exception
EventData * EventDataPointer
const Event::Label & nullEventLabel() const
int dataMemoryUsage() const
Event & operator=(const Event &e)
static EventFactory * factory()
ostream & operator<<(ostream &os, const DiagState &dstate)
void setNickname(const Label &nick)
Diades::Utils::Exception< EventFactory > Exception
unordered_map< Event::Label, Event > _mapping