Fawkes API  Fawkes Development Version
plugin.h
1 
2 /***************************************************************************
3  * Protoboard plugin template
4  * - Main plugin template: Instantiate this with the appropriate interface
5  * handler mappings to create a domain-specific plugin.
6  *
7  * Copyright 2019 Victor MatarĂ©
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef PROTOBOARD_PLUGIN_H
24 #define PROTOBOARD_PLUGIN_H
25 
26 #include "blackboard_manager.h"
27 #include "protobuf_thread.h"
28 
29 #include <core/plugin.h>
30 
31 /**
32  * The main class template that generates a domain-specific plugin
33  * @tparam IfaceManagerTs A list of @a bb_iface_manager instantiations that specify
34  * what message types should be handled on a given interface type.
35  */
36 template <class... IfaceManagerTs>
38 {
39 public:
40  /**
41  * Initializes all threads required for the plugin.
42  * @param cfg The fawkes config
43  */
45  {
46  protoboard::ProtobufThead * protobuf_thread = new protoboard::ProtobufThead();
47  protoboard::BlackboardManager *bb_mgr = new protoboard::BlackboardManager(protobuf_thread);
49  protobuf_thread->set_bb_manager(bb_mgr);
50  thread_list.push_back(bb_mgr);
51  thread_list.push_back(protobuf_thread);
52  }
53 };
54 
55 #endif // PROTOBOARD_PLUGIN_H
protoboard::ProtobufThead
Receive incoming ProtoBuf messages and pass them on to the BlackboardManager for publication to the a...
Definition: protobuf_thread.h:55
fawkes::Plugin::thread_list
ThreadList thread_list
Thread list member.
Definition: plugin.h:53
fawkes::ThreadList::push_back
void push_back(Thread *thread)
Add thread to the end.
Definition: thread_list.cpp:773
ProtoboardPlugin::ProtoboardPlugin
ProtoboardPlugin(fawkes::Configuration *cfg)
Initializes all threads required for the plugin.
Definition: plugin.h:44
protoboard::BlackboardManager::set_protobuf_sender
void set_protobuf_sender(AbstractProtobufSender *sender)
The ProtoBuf sender must be initialized after construction to beak a dependency loop.
Definition: blackboard_manager.cpp:52
fawkes::Configuration
Interface for configuration handling.
Definition: config.h:65
protoboard::BlackboardManager
The main thread that is woken each time a message arrives on any of the interfaces watched by a bb_if...
Definition: blackboard_manager.h:201
Plugin
Plugin representation for JSON transfer.
Definition: Plugin.h:28
ProtoboardPlugin
The main class template that generates a domain-specific plugin.
Definition: plugin.h:38
protoboard::ProtobufSender
Sends out ProtoBuf messages for all given interface managers.
Definition: blackboard_manager.h:173
protoboard::ProtobufThead::set_bb_manager
void set_bb_manager(BlackboardManager *bb_manager)
Deferred initialization of the pointer to the BlackboardManager.
Definition: protobuf_thread.h:108
fawkes::Plugin
Plugin interface class.
Definition: plugin.h:34