Grail (C++)  1.3.0
A multi-platform, modular, universal engine for embedding advanced AI in games.
grail::planner::ParametrizedObject Class Reference
Inheritance diagram for grail::planner::ParametrizedObject:
Collaboration diagram for grail::planner::ParametrizedObject:

Public Member Functions

void MergeParameters (const ParametrizedObject &other)
 MergeParameters - Adds other parameters to own, replacing parameter with other in case of conflict. More...
 
std::size_t GetParametersSize () const
 
bool Contains (const std::string &paramName) const
 
template<typename ParameterType >
void SetParameter (const std::string &paramName, const ParameterType &paramValue)
 
template<typename ParameterType >
ParameterType GetParameterValue (const std::string &paramName) const
 
bool CollectionContains (const std::string &collectionName, unsigned int objectIndex) const
 
void AddCollection (const std::string &collectionName)
 
std::set< unsigned int > * GetCollection (const std::string &name)
 
const std::set< unsigned int > * GetCollection (const std::string &name) const
 
bool HasEqualParams (const ParametrizedObject &other) const
 
Returns
true if the other object contains identical set of parameters (including the contents of collections)

 
void SetSerializeSnapshotFunction (std::function< void(const ParametrizedObject &object, std::map< std::string, std::string > &nameValues)> function)
 SetSerializeSnapshotFunction - Sets a function serializing a snapshot of parameter values to string. More...
 
ParametrizedObjectoperator= (const ParametrizedObject &other)
 
ParametrizedObjectoperator= (ParametrizedObject &&other)=default
 

Protected Member Functions

 ParametrizedObject (MemoryPool *memory)
 
 ParametrizedObject (const ParametrizedObject &other)
 
 ParametrizedObject (ParametrizedObject &&other)=default
 

Protected Attributes

std::map< std::string, ObjectParameter * > parameters {}
 
std::map< std::string, std::set< unsigned int > > indexCollections {}
 
MemoryPoolmemory
 

Friends

struct grail::data::PlannerActionSnapshot
 

Member Function Documentation

◆ AddCollection()

void grail::planner::ParametrizedObject::AddCollection ( const std::string &  collectionName)

Creates a new collection object under the provided name, which can be used to group many IDs of objects together.
The name should be unique or you will otherwise override an existing collection.

◆ CollectionContains()

bool grail::planner::ParametrizedObject::CollectionContains ( const std::string &  collectionName,
unsigned int  objectIndex 
) const
Returns
true if the object contains objectIndex in a collection identified collectionName

◆ Contains()

bool grail::planner::ParametrizedObject::Contains ( const std::string &  paramName) const
Returns
true if the object contains a parameter with the given name, false otherwise

◆ GetCollection() [1/2]

std::set< unsigned int > * grail::planner::ParametrizedObject::GetCollection ( const std::string &  name)
Parameters
collectionNameThe name of the collection to retrieve. See AddCollection.
Returns
The collection with the given name or null if such does not exist.

◆ GetCollection() [2/2]

const std::set< unsigned int > * grail::planner::ParametrizedObject::GetCollection ( const std::string &  name) const
Parameters
collectionNameThe name of the collection to retrieve. See AddCollection.
Returns
The collection with the given name or null if such does not exist.

◆ GetParametersSize()

std::size_t grail::planner::ParametrizedObject::GetParametersSize ( ) const
Returns
The number of parameters assigned to this object

◆ GetParameterValue()

template<typename ParameterType >
ParameterType grail::planner::ParametrizedObject::GetParameterValue ( const std::string &  paramName) const
inline
Returns
The parameter's value if a parameter with the given name exists, the default value otherwise

◆ MergeParameters()

void grail::planner::ParametrizedObject::MergeParameters ( const ParametrizedObject other)

MergeParameters - Adds other parameters to own, replacing parameter with other in case of conflict.

Parameters
otherObject to merge parameters from

◆ SetParameter()

template<typename ParameterType >
void grail::planner::ParametrizedObject::SetParameter ( const std::string &  paramName,
const ParameterType &  paramValue 
)
inline

Updates the value of a parameter identified by the given name. If there's no such parameter, it will be added.

◆ SetSerializeSnapshotFunction()

void grail::planner::ParametrizedObject::SetSerializeSnapshotFunction ( std::function< void(const ParametrizedObject &object, std::map< std::string, std::string > &nameValues)>  function)

SetSerializeSnapshotFunction - Sets a function serializing a snapshot of parameter values to string.

Parameters
function- serialization function returning a map where keys represent parameter identifiers and values - parameter values serialized to string.

The documentation for this class was generated from the following files: