22 #include "blackboard_computable.h" 31 using namespace mongo;
45 robot_memory_ = robot_memory;
46 blackboard_ = blackboard;
50 Query query = fromjson(
"{interface:{$exists:true}}");
51 int priority = config->
get_int(
"plugins/robot-memory/computables/blackboard/priority");
53 config->
get_float(
"plugins/robot-memory/computables/blackboard/caching-time");
54 computable = robot_memory_->register_computable(query,
56 &BlackboardComputable::compute_interfaces,
62 BlackboardComputable::~BlackboardComputable()
64 robot_memory_->remove_computable(computable);
67 std::list<mongo::BSONObj>
68 BlackboardComputable::compute_interfaces(
const mongo::BSONObj &query,
const std::string &collection)
70 std::list<mongo::BSONObj> res;
71 std::string type = query.getField(
"interface").String();
73 if (query.hasField(
"id"))
74 id = query.getField(
"id").String();
76 for (
Interface *interface : blackboard_->open_multiple_for_reading(type.c_str(),
id.c_str())) {
80 b <<
"interface" << interface->type() <<
"id" << interface->id();
82 if (it.get_length() > 1 && it.get_type() !=
IFT_STRING) {
83 b << it.get_name() << get_interface_fields(it);
85 switch (it.get_type()) {
86 case IFT_BOOL: b << it.get_name() << it.get_bool();
break;
87 case IFT_INT8: b << it.get_name() << it.get_int8();
break;
88 case IFT_UINT8: b << it.get_name() << it.get_uint8();
break;
89 case IFT_INT16: b << it.get_name() << it.get_int16();
break;
90 case IFT_UINT16: b << it.get_name() << it.get_uint16();
break;
91 case IFT_INT32: b << it.get_name() << it.get_int32();
break;
92 case IFT_UINT32: b << it.get_name() << it.get_uint32();
break;
93 case IFT_INT64: b << it.get_name() << (
long long int)it.get_int64();
break;
94 case IFT_UINT64: b << it.get_name() << (
unsigned int)it.get_uint64();
break;
95 case IFT_FLOAT: b << it.get_name() << it.get_float();
break;
96 case IFT_DOUBLE: b << it.get_name() << it.get_double();
break;
97 case IFT_STRING: b << it.get_name() << it.get_string();
break;
98 case IFT_BYTE: b << it.get_name() << it.get_byte();
break;
99 case IFT_ENUM: b << it.get_name() << it.get_enum_string();
break;
103 res.push_back(b.obj());
104 blackboard_->close(interface);
112 BSONArrayBuilder arr_b;
113 for (
unsigned int i = 0; i < it.
get_length(); i++) {
Interface field iterator.
uint16_t get_uint16(unsigned int index=0) const
Get value of current field as unsigned integer.
double get_double(unsigned int index=0) const
Get value of current field as double.
BlackboardComputable(RobotMemory *robot_memory, fawkes::BlackBoard *blackboard, fawkes::Logger *logger, fawkes::Configuration *config)
Constructor with references to objects of the plugin.
Fawkes library namespace.
bool get_bool(unsigned int index=0) const
Get value of current field as bool.
8 bit unsigned integer field
16 bit unsigned integer field
interface_fieldtype_t get_type() const
Get type of current field.
byte field, alias for uint8
float get_float(unsigned int index=0) const
Get value of current field as float.
virtual int get_int(const char *path)=0
Get value from configuration which is of type int.
Base class for all Fawkes BlackBoard interfaces.
uint8_t get_byte(unsigned int index=0) const
Get value of current field as byte.
int16_t get_int16(unsigned int index=0) const
Get value of current field as integer.
int8_t get_int8(unsigned int index=0) const
Get value of current field as integer.
uint8_t get_uint8(unsigned int index=0) const
Get value of current field as unsigned integer.
uint64_t get_uint64(unsigned int index=0) const
Get value of current field as unsigned integer.
64 bit unsigned integer field
const char * get_enum_string(unsigned int index=0) const
Get value of current enum field as string.
const char * get_string() const
Get value of current field as string.
uint32_t get_uint32(unsigned int index=0) const
Get value of current field as unsigned integer.
size_t get_length() const
Get length of current field.
Access to the robot memory based on mongodb.
The BlackBoard abstract class.
int32_t get_int32(unsigned int index=0) const
Get value of current field as integer.
Interface for configuration handling.
virtual float get_float(const char *path)=0
Get value from configuration which is of type float.
32 bit unsigned integer field
field with interface specific enum type
int64_t get_int64(unsigned int index=0) const
Get value of current field as integer.