Fawkes API Fawkes Development Version
globals_adapter.h
1
2/***************************************************************************
3 * globals_adapter.h - PLEXIL adapter for global state
4 *
5 * Created: Wed Aug 22 11:27:34 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_GLOBALS_ADAPTER_H_
23#define __PLUGINS_PLEXIL_GLOBALS_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#include <set>
33
34/** Interface adapter to provide logging facilities. */
35class GlobalStatePlexilAdapter : public PLEXIL::InterfaceAdapter
36{
37public:
38 GlobalStatePlexilAdapter(PLEXIL::AdapterExecInterface &execInterface);
39 GlobalStatePlexilAdapter(PLEXIL::AdapterExecInterface &execInterface, pugi::xml_node const xml);
40
41 /// @cond DELETED
42 GlobalStatePlexilAdapter() = delete;
44 GlobalStatePlexilAdapter &operator=(const GlobalStatePlexilAdapter &) = delete;
45 /// @endcond
46
48
49 virtual bool initialize();
50 virtual bool start();
51 virtual bool stop();
52 virtual bool reset();
53 virtual bool shutdown();
54
55 virtual void subscribe(const PLEXIL::State &state);
56 virtual void unsubscribe(const PLEXIL::State &state);
57
58 virtual void executeCommand(PLEXIL::Command *cmd);
59 virtual void invokeAbort(PLEXIL::Command *cmd);
60
61 virtual void lookupNow(PLEXIL::State const &state, PLEXIL::StateCacheEntry &cache_entry);
62
63private:
64 void global_set_value(PLEXIL::Command *cmd, PLEXIL::ValueType value_type);
65 void global_print_all(PLEXIL::Command *cmd);
66
67private:
68 fawkes::Configuration *config_;
69 fawkes::Logger * logger_;
70
71 bool cfg_default_adapter_;
72
73 std::map<std::string, std::function<void(PLEXIL::Command *)>> commands_;
74
75 std::map<PLEXIL::State, std::pair<PLEXIL::ValueType, PLEXIL::Value>> values_;
76 std::set<PLEXIL::State> subscribed_states_;
77};
78
79extern "C" {
80void initGlobalState();
81}
82
83#endif
Interface adapter to provide logging facilities.
virtual void executeCommand(PLEXIL::Command *cmd)
Perform given command.
virtual bool start()
Start adapter.
virtual bool initialize()
Initialize adapter.
virtual ~GlobalStatePlexilAdapter()
Destructor.
virtual void subscribe(const PLEXIL::State &state)
Subscribe to updates for given state.
virtual void unsubscribe(const PLEXIL::State &state)
Unsubscribe from updates.
virtual bool stop()
Stop adapter.
virtual bool shutdown()
Shut adapter down.
virtual bool reset()
Reset adapter.
GlobalStatePlexilAdapter(PLEXIL::AdapterExecInterface &execInterface)
Constructor.
virtual void invokeAbort(PLEXIL::Command *cmd)
Abort currently running execution.
virtual void lookupNow(PLEXIL::State const &state, PLEXIL::StateCacheEntry &cache_entry)
Immediate lookup of value.
Interface for configuration handling.
Definition: config.h:68
Interface for logging.
Definition: logger.h:42