Fawkes API Fawkes Development Version
config_adapter.h
1
2/***************************************************************************
3 * config_adapter.h - PLEXIL adapter for the configuration
4 *
5 * Created: Tue Aug 21 15:41:47 2018
6 * Copyright 2006-2018 Tim Niemueller [www.niemueller.de]
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 __PLUGINS_PLEXIL_CONFIG_ADAPTER_H_
23#define __PLUGINS_PLEXIL_CONFIG_ADAPTER_H_
24
25#include <config/config.h>
26#include <logging/logger.h>
27
28#include <InterfaceAdapter.hh>
29#include <Value.hh>
30#include <functional>
31#include <memory>
32
33/** Interface adapter to provide logging facilities. */
34class ConfigurationPlexilAdapter : public PLEXIL::InterfaceAdapter
35{
36public:
37 ConfigurationPlexilAdapter(PLEXIL::AdapterExecInterface &execInterface);
38 ConfigurationPlexilAdapter(PLEXIL::AdapterExecInterface &execInterface, pugi::xml_node const xml);
39
40 /// @cond DELETED
43 ConfigurationPlexilAdapter &operator=(const ConfigurationPlexilAdapter &) = delete;
44 /// @endcond
45
47
48 virtual bool initialize();
49 virtual bool start();
50 virtual bool stop();
51 virtual bool reset();
52 virtual bool shutdown();
53
54 void executeCommand(PLEXIL::Command *cmd);
55 void invokeAbort(PLEXIL::Command *cmd);
56
57private:
58 void config_get_value(PLEXIL::Command *cmd, PLEXIL::ValueType value_type);
59 void config_get_value_or_default(PLEXIL::Command *cmd, PLEXIL::ValueType value_type);
60 void config_exists(PLEXIL::Command *cmd);
61
62private:
63 fawkes::Configuration *config_;
64 fawkes::Logger * logger_;
65
66 std::map<std::string, std::function<void(PLEXIL::Command *)>> commands_;
67};
68
69extern "C" {
70void initFawkesConfigurationAdapter();
71}
72
73#endif
Interface adapter to provide logging facilities.
virtual bool initialize()
Initialize adapter.
ConfigurationPlexilAdapter(PLEXIL::AdapterExecInterface &execInterface)
Constructor.
virtual bool start()
Start adapter.
virtual bool stop()
Stop adapter.
void invokeAbort(PLEXIL::Command *cmd)
Abort currently running execution.
void executeCommand(PLEXIL::Command *cmd)
Perform given command.
virtual bool reset()
Reset adapter.
virtual ~ConfigurationPlexilAdapter()
Destructor.
virtual bool shutdown()
Shut adapter down.
Interface for configuration handling.
Definition: config.h:68
Interface for logging.
Definition: logger.h:42