Fawkes API  Fawkes Development Version
computable.h
1 /***************************************************************************
2  * computable.h - Class holding information for a single computable
3  *
4  *
5  * Created: 6:57:45 PM 2016
6  * Copyright 2016 Frederik Zwilling
7  ****************************************************************************/
8 
9 /* This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Library General Public License for more details.
18  *
19  * Read the full text in the LICENSE.GPL file in the doc directory.
20  */
21 
22 #ifndef FAWKES_SRC_PLUGINS_ROBOT_MEMORY_COMPUTABLE_H_
23 #define FAWKES_SRC_PLUGINS_ROBOT_MEMORY_COMPUTABLE_H_
24 
25 #include <mongo/client/dbclient.h>
26 
27 #include <boost/function.hpp>
28 
30 {
31 public:
32  Computable(
33  mongo::Query query_to_compute,
34  std::string collection,
35  const boost::function<std::list<mongo::BSONObj>(mongo::BSONObj, std::string)> &compute_function,
36  double caching_time = 0.0,
37  int priority = 0);
38  virtual ~Computable();
39 
40  std::list<mongo::BSONObj> compute(mongo::BSONObj query);
41  mongo::Query get_query();
42  std::string get_collection();
43  int get_priority();
44 
45 private:
46  boost::function<std::list<mongo::BSONObj>(mongo::BSONObj, std::string)> compute_function;
47  mongo::Query query_to_compute;
48  std::string collection;
49  int caching_time; //in milliseconds
50  int priority;
51 };
52 
53 #endif /* FAWKES_SRC_PLUGINS_ROBOT_MEMORY_COMPUTABLE_H_ */
int get_priority()
Gets the priority of the computable.
Definition: computable.cpp:113
Class holding information for a single computable this class also enhances computed documents by addi...
Definition: computable.h:29
std::list< mongo::BSONObj > compute(mongo::BSONObj query)
Compute demanded information and insert it into the robot memory.
Definition: computable.cpp:67
mongo::Query get_query()
Gets the query that defines what information is computed by the Computable.
Definition: computable.cpp:93
Computable(mongo::Query query_to_compute, std::string collection, const boost::function< std::list< mongo::BSONObj >(mongo::BSONObj, std::string)> &compute_function, double caching_time=0.0, int priority=0)
Constructor for object holding information about a computable.
Definition: computable.cpp:42
std::string get_collection()
Gets the collection the computable adds information to.
Definition: computable.cpp:103