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 <boost/function.hpp>
26#include <bsoncxx/document/value.hpp>
27#include <bsoncxx/document/view.hpp>
28#include <list>
29#include <mongocxx/client.hpp>
30
32{
33public:
35 bsoncxx::document::value query_to_compute,
36 std::string collection,
37 const boost::function<std::list<bsoncxx::document::value>(bsoncxx::document::view, std::string)>
38 & compute_function,
39 double caching_time = 0.0,
40 int priority = 0);
41 virtual ~Computable();
42
43 std::list<bsoncxx::document::value> compute(bsoncxx::document::view query);
44 bsoncxx::document::value get_query();
45 std::string get_collection();
46 int get_priority();
47
48private:
49 boost::function<std::list<bsoncxx::document::value>(bsoncxx::document::view, std::string)>
50 compute_function;
51 bsoncxx::document::value query_to_compute;
52 std::string collection;
53 int caching_time; //in milliseconds
54 int priority;
55};
56
57#endif /* FAWKES_SRC_PLUGINS_ROBOT_MEMORY_COMPUTABLE_H_ */
Class holding information for a single computable this class also enhances computed documents by addi...
Definition: computable.h:32
std::string get_collection()
Gets the collection the computable adds information to.
Definition: computable.cpp:106
int get_priority()
Gets the priority of the computable.
Definition: computable.cpp:116
bsoncxx::document::value get_query()
Gets the query that defines what information is computed by the Computable.
Definition: computable.cpp:96
std::list< bsoncxx::document::value > compute(bsoncxx::document::view query)
Compute demanded information and insert it into the robot memory.
Definition: computable.cpp:68
Computable(bsoncxx::document::value query_to_compute, std::string collection, const boost::function< std::list< bsoncxx::document::value >(bsoncxx::document::view, std::string)> &compute_function, double caching_time=0.0, int priority=0)
Constructor for object holding information about a computable.
Definition: computable.cpp:44