SimpleAI
 All Classes Namespaces Files Functions Variables Typedefs Macros Groups Pages
Classes | Macros | Typedefs
ICondition.h File Reference

Condition related stuff. More...

#include <string>
#include <vector>
#include <sstream>
#include <memory>
#include "common/MemoryAllocator.h"
#include "common/Thread.h"
#include "AIFactories.h"
Include dependency graph for ICondition.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  ai::ICondition
 A condition can be placed on a TreeNode to decide which node is going to get executed. In general they are stateless. If they are not, it should explicitly get noted. More...
 

Macros

#define CONDITION_CLASS(ConditionName)
 Macro to simplify the condition creation. Just give the class name of the condition as parameter. More...
 
#define CONDITION_FACTORY_NO_IMPL(ConditionName)
 A condition factory macro to ease and unify the registration at AIRegistry. You still have to implement the Factory::create method. More...
 
#define CONDITION_FACTORY(ConditionName)
 A condition factory macro to ease and unify the registration at AIRegistry. More...
 
#define CONDITION_FACTORY_SINGLETON
 A condition factory singleton macro to ease and unify the registration at AIRegistry. Nothing from the given context is taken, if you need this, use the instance based factory, not the singleton based. More...
 
#define CONDITION_CLASS_SINGLETON(ConditionName)
 Macro to create a singleton conditions for very easy conditions without a state. More...
 
#define CONDITION_PRINT_SUBCONDITIONS_GETCONDITIONNAMEWITHVALUE
 

Typedefs

typedef std::shared_ptr
< ICondition > 
ai::ConditionPtr
 
typedef std::vector< ConditionPtr > ai::Conditions
 
typedef Conditions::iterator ai::ConditionsIter
 
typedef Conditions::const_iterator ai::ConditionsConstIter
 

Detailed Description

Condition related stuff.

Macro Definition Documentation

#define CONDITION_CLASS (   ConditionName)
Value:
explicit ConditionName(const std::string& parameters = "") : \
::ai::ICondition(#ConditionName, parameters) { \
} \
public: \
virtual ~ConditionName() { \
}

Macro to simplify the condition creation. Just give the class name of the condition as parameter.

#define CONDITION_CLASS_SINGLETON (   ConditionName)
Value:
private: \
CONDITION_CLASS(ConditionName) \
public: \
static ConditionPtr& get() { \
AI_THREAD_LOCAL ConditionName* c = nullptr; \
if (c == nullptr) { c = new ConditionName; } \
AI_THREAD_LOCAL ConditionPtr _instance(c); \
return _instance; \
} \
#define CONDITION_CLASS(ConditionName)
Macro to simplify the condition creation. Just give the class name of the condition as parameter...
Definition: ICondition.h:29
#define CONDITION_FACTORY_SINGLETON
A condition factory singleton macro to ease and unify the registration at AIRegistry. Nothing from the given context is taken, if you need this, use the instance based factory, not the singleton based.
Definition: ICondition.h:73

Macro to create a singleton conditions for very easy conditions without a state.

#define CONDITION_FACTORY (   ConditionName)
Value:
public: \
class Factory: public ::ai::IConditionFactory { \
public: \
::ai::ConditionPtr create (const ::ai::ConditionFactoryContext *ctx) const override { \
return std::make_shared<ConditionName>(ctx->parameters); \
} \
}; \
static const Factory& getFactory() { \
static Factory FACTORY; \
return FACTORY; \
}

A condition factory macro to ease and unify the registration at AIRegistry.

#define CONDITION_FACTORY_NO_IMPL (   ConditionName)
Value:
public: \
class Factory: public ::ai::IConditionFactory { \
public: \
::ai::ConditionPtr create (const ::ai::ConditionFactoryContext *ctx) const override; \
}; \
static const Factory& getFactory() { \
static Factory FACTORY; \
return FACTORY; \
}

A condition factory macro to ease and unify the registration at AIRegistry. You still have to implement the Factory::create method.

#define CONDITION_FACTORY_SINGLETON
Value:
public: \
class Factory: public ::ai::IConditionFactory { \
::ai::ConditionPtr create (const ::ai::ConditionFactoryContext */*ctx*/) const { \
return get(); \
} \
}; \
static const Factory& getFactory() { \
static Factory FACTORY; \
return FACTORY; \
}

A condition factory singleton macro to ease and unify the registration at AIRegistry. Nothing from the given context is taken, if you need this, use the instance based factory, not the singleton based.

#define CONDITION_PRINT_SUBCONDITIONS_GETCONDITIONNAMEWITHVALUE
Value:
void getConditionNameWithValue(std::stringstream& s, const ::ai::AIPtr& entity) override { \
bool first = true; \
s << "("; \
for (::ai::ConditionsConstIter i = _conditions.begin(); i != _conditions.end(); ++i) { \
if (!first) { \
s << ","; \
} \
s << (*i)->getNameWithConditions(entity); \
first = false; \
} \
s << ")"; \
}