Fawkes API  Fawkes Development Version
ComputablesManager Class Reference

This class manages registering computables and can check if any computables are invoced by a query. More...

#include <computables_manager.h>

Public Member Functions

 ComputablesManager (fawkes::Configuration *config, RobotMemory *robot_memory)
 Constructor for class managing computables with refereces to plugin objects. More...
 
bool check_and_compute (mongo::Query query, std::string collection)
 Checks if computable knowledge is queried and calls the compute functions in this case. More...
 
void remove_computable (Computable *computable)
 Remove previously registered computable. More...
 
void cleanup_computed_docs ()
 Clean up all collections containing documents computed on demand. More...
 
template<typename T >
Computableregister_computable (const mongo::Query &query_to_compute, const std::string &collection, std::list< mongo::BSONObj >(T::*compute_func)(const mongo::BSONObj &, const std::string &), T *obj, double caching_time=0.0, int priority=0)
 Registers a Computable which provides information in the robot memory that is computed on demand. More...
 

Detailed Description

This class manages registering computables and can check if any computables are invoced by a query.

Author
Frederik Zwilling

Definition at line 40 of file computables_manager.h.

Constructor & Destructor Documentation

◆ ComputablesManager()

ComputablesManager::ComputablesManager ( fawkes::Configuration config,
RobotMemory robot_memory 
)

Constructor for class managing computables with refereces to plugin objects.

Parameters
configConfiguration
robot_memoryRobot Memory

Definition at line 43 of file computables_manager.cpp.

References fawkes::Configuration::get_string().

Member Function Documentation

◆ check_and_compute()

bool ComputablesManager::check_and_compute ( mongo::Query  query,
std::string  collection 
)

Checks if computable knowledge is queried and calls the compute functions in this case.

Parameters
queryThe query that might ask for computable knowledge
collectionThe collection that is querried
Returns
Were computed documents added?

Definition at line 85 of file computables_manager.cpp.

References RobotMemory::drop_collection(), RobotMemory::insert(), and RobotMemory::query().

◆ cleanup_computed_docs()

void ComputablesManager::cleanup_computed_docs ( )

Clean up all collections containing documents computed on demand.

Definition at line 130 of file computables_manager.cpp.

References RobotMemory::remove().

◆ register_computable()

template<typename T >
Computable* ComputablesManager::register_computable ( const mongo::Query &  query_to_compute,
const std::string &  collection,
std::list< mongo::BSONObj >(T::*)(const mongo::BSONObj &, const std::string &)  compute_func,
T *  obj,
double  caching_time = 0.0,
int  priority = 0 
)
inline

Registers a Computable which provides information in the robot memory that is computed on demand.

Parameters
query_to_computeQuery describing what the function computes. Yor computable is called when an new query matches query_to_compute.
collectiondb.collection to fill with computed information
compute_funcCallback function that computes the information and retruns a list of computed documents
objPointer to class the callback is a function of (usaually this)
caching_timeHow long should computed results for a query be cached and be used for identical queries in that time?
priorityComputable priority ordering the evaluation
Returns
Computable Object pointer used for removing it

Definition at line 62 of file computables_manager.h.

Referenced by RobotMemory::register_computable().

◆ remove_computable()

void ComputablesManager::remove_computable ( Computable computable)

Remove previously registered computable.

Parameters
computableThe computable to remove

Definition at line 66 of file computables_manager.cpp.


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