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. */
34 class ConfigurationPlexilAdapter : public PLEXIL::InterfaceAdapter
35 {
36 public:
37  ConfigurationPlexilAdapter(PLEXIL::AdapterExecInterface &execInterface);
38  ConfigurationPlexilAdapter(PLEXIL::AdapterExecInterface &execInterface, pugi::xml_node const xml);
39 
40  /// @cond DELETED
41  ConfigurationPlexilAdapter() = delete;
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 
57 private:
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 
62 private:
63  fawkes::Configuration *config_;
64  fawkes::Logger * logger_;
65 
66  std::map<std::string, std::function<void(PLEXIL::Command *)>> commands_;
67 };
68 
69 extern "C" {
70 void initFawkesConfigurationAdapter();
71 }
72 
73 #endif
ConfigurationPlexilAdapter::~ConfigurationPlexilAdapter
virtual ~ConfigurationPlexilAdapter()
Destructor.
Definition: config_adapter.cpp:61
ConfigurationPlexilAdapter
Interface adapter to provide logging facilities.
Definition: config_adapter.h:34
ConfigurationPlexilAdapter::reset
virtual bool reset()
Reset adapter.
Definition: config_adapter.cpp:133
ConfigurationPlexilAdapter::stop
virtual bool stop()
Stop adapter.
Definition: config_adapter.cpp:124
ConfigurationPlexilAdapter::initialize
virtual bool initialize()
Initialize adapter.
Definition: config_adapter.cpp:69
ConfigurationPlexilAdapter::ConfigurationPlexilAdapter
ConfigurationPlexilAdapter(PLEXIL::AdapterExecInterface &execInterface)
Constructor.
Definition: config_adapter.cpp:44
fawkes::Configuration
Definition: config.h:70
fawkes::Logger
Definition: logger.h:41
ConfigurationPlexilAdapter::start
virtual bool start()
Start adapter.
Definition: config_adapter.cpp:115
ConfigurationPlexilAdapter::shutdown
virtual bool shutdown()
Shut adapter down.
Definition: config_adapter.cpp:142
ConfigurationPlexilAdapter::invokeAbort
void invokeAbort(PLEXIL::Command *cmd)
Abort currently running execution.
Definition: config_adapter.cpp:171
ConfigurationPlexilAdapter::executeCommand
void executeCommand(PLEXIL::Command *cmd)
Perform given command.
Definition: config_adapter.cpp:151