Fawkes API Fawkes Development Version
utils.h
1/***************************************************************************
2 * utils.h - Common utility functions used with Golog++
3 *
4 * Created: Wed 30 Oct 2019 14:36:46 CET 14:36
5 * Copyright 2019 Till Hofmann <hofmann@kbsg.rwth-aachen.de>
6 ****************************************************************************/
7
8/* This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU Library General Public License for more details.
17 *
18 * Read the full text in the LICENSE.GPL file in the doc directory.
19 */
20
21#pragma once
22
23#include <golog++/model/value.h>
24
25#include <boost/variant/variant.hpp>
26
27namespace gologpp {
28class Value;
29}
30
31namespace fawkes {
32class InterfaceFieldIterator;
33
34namespace gpp {
35
36class ValueToFieldVisitor : public boost::static_visitor<>
37{
38public:
39 ValueToFieldVisitor(InterfaceFieldIterator *field, unsigned int index = 0);
40 void operator()(unsigned int v);
41 void operator()(int v);
42 void operator()(unsigned long v);
43 void operator()(long v);
44 void operator()(double v);
45 void operator()(std::string v);
46 void operator()(bool v);
47 void operator()(gologpp::CompoundType::Representation v);
48 void operator()(gologpp::ListType::Representation v);
49 void operator()(void *v);
50
51private:
53 unsigned int index;
54};
55
56void value_to_field(const gologpp::Value &value, InterfaceFieldIterator *field);
57gologpp::Value *field_to_value(InterfaceFieldIterator &fi, unsigned int idx);
58
59} // namespace gpp
60} // namespace fawkes
Interface field iterator.
A visitor that converts a gologpp::Value to an interface field value.
Definition: utils.h:37
void operator()(unsigned int v)
Convert the given value and set the field accordingly.
Definition: utils.cpp:51
ValueToFieldVisitor(InterfaceFieldIterator *field, unsigned int index=0)
Constructor.
Definition: utils.cpp:42
Fawkes library namespace.