21 class RuleInvalid :
public runtime_error,
public domain_error {
26 RuleInvalid(
const string& whatArg) : runtime_error(whatArg), domain_error(whatArg){
27 cerr <<
"EXCEPTION RuleInvalid -> " << whatArg << endl;
50 _precond.push_back(precondition);
51 ensure(
RuleInvalid,!_precond[0].
get().isNull(),
"makePrecondition: assignment of formula is invalid");
52 ensure(
RuleInvalid,_precond[0].
get().equivalent(precondition),
"makePrecondition: assignment of formula is not logiclly equivalent");
57 _effect.push_back(effect);
58 ensure(
RuleInvalid,!_effect[0].
get().isNull(),
"makeEffect: assignment of formula is invalid");
59 ensure(
RuleInvalid,!_effect[0].
get().equivalent(effect),
"makeEffect: assignment of formula is not logiclly equivalent");
63 return (_event != 0) && (!_precond.empty()) && (!_precond[0].
get().isNull())
64 && (!_effect.empty()) && (!_effect[0].
get().isNull());
70 require(
RuleInvalid, (!_precond.empty()) && (!_precond[0].
get().isNull()),
"precondition: the return precondition is invalid");
75 require(
RuleInvalid, (!_effect.empty()) && (!_effect[0].
get().isNull()),
"effect: the return effect is invalid");
79 const list<const Event *> &
outputEvents()
const {
return _events; }
87 "setInputEvent, wrong event type");
88 require(
RuleInvalid, _event == 0,
"setInputEvent, the rule has already an input event");
94 "setOutputEvent, wrong event type");
95 _events.push_back(&evt);
100 for(vector<int *>::size_type i = 0; i < cubes.size(); ++i)
110 vector<int *>::size_type index = 0;
113 cubes.push_back(
new int[size]);
114 for(
int i = 0; i < size; ++i)
123 vector<int *>::const_iterator
beginOfCubes()
const {
return cubes.begin(); }
124 vector<int *>::const_iterator
endOfCubes()
const {
return cubes.end(); }
vector< int * >::const_iterator endOfCubes() const
void setInputEvent(const Event &evt)
const Formula & precondition() const
vector< Formula::ConstReference > _effect
vector< Formula::ConstReference > _precond
const Event & inputEvent() const
#define ensure(Exception, expr, message)
const list< const Event * > & outputEvents() const
void makePrecondition(const Formula &precondition)
int * currentCube() const
ostream & operator<<(ostream &os, const StateNode< T > &stateNode)
void makeEffect(const Formula &effect)
#define require(Exception, expr, message)
Namespace of the Diades project.
const Formula & effect() const
vector< int * >::const_iterator beginOfCubes() const
void insertOutputEvent(const Event &evt)
RuleInvalid(const string &whatArg)
list< const Event * > _events