Fledge
An open source edge computing platform for industrial users
north_plugin.h
1 #ifndef _NORTH_PLUGIN
2 #define _NORTH_PLUGIN
3 /*
4  * Fledge north plugin.
5  *
6  * Copyright (c) 2018 Dianomic Systems
7  *
8  * Released under the Apache 2.0 Licence
9  *
10  * Author: Massimiliano Pinto
11  */
12 
13 #include <plugin.h>
14 #include <plugin_manager.h>
15 #include <reading.h>
16 #include <config_category.h>
17 #include <plugin_data.h>
18 
30 class NorthPlugin : public Plugin {
31  public:
32  // Methods
33  NorthPlugin(const PLUGIN_HANDLE handle);
34  ~NorthPlugin();
35 
36  void shutdown();
37  std::string shutdownSaveData();
38  uint32_t send(const std::vector<Reading* >& readings) const;
39  PLUGIN_HANDLE init(const ConfigCategory& config);
40  bool persistData() { return info->options & SP_PERSIST_DATA; };
41  void start();
42  void startData(const std::string& pluginData);
43 
44  private:
45  // Function pointers
46  void (*pluginShutdown)(const PLUGIN_HANDLE);
47  std::string (*pluginShutdownData)(const PLUGIN_HANDLE);
48  uint32_t (*pluginSend)(const PLUGIN_HANDLE,
49  const std::vector<Reading* >& readings);
50  PLUGIN_HANDLE (*pluginInit)(const ConfigCategory* config);
51  void (*pluginStart)(PLUGIN_HANDLE);
52  void (*pluginStartData)(PLUGIN_HANDLE,
53  const std::string& pluginData);
54 
55  public:
56  // Persist plugin data
57  PluginData* m_plugin_data;
58 
59  private:
60  // Attributes
61  PLUGIN_HANDLE m_instance;
62 };
63 
64 #endif
unsigned int options
The set of option flags that apply to this plugin.
Definition: plugin_api.h:29
uint32_t send(const std::vector< Reading *> &readings)
Call the send method in the plugin.
Definition: north_plugin.cpp:103
Definition: config_category.h:56
NorthPlugin(PLUGIN_HANDLE handle, const ConfigCategory &category)
Constructor for the class that wraps the north plugin.
Definition: north_plugin.cpp:31
A generic representation of a plugin.
Definition: plugin.h:20
Definition: plugin_data.h:15
void shutdown()
Call the shutdown method in the plugin.
Definition: north_plugin.cpp:169
Class that represents a north plugin.
Definition: north_plugin.h:33
PLUGIN_HANDLE init(const ConfigCategory &config)
Initialise the plugin with configuration data.
Definition: north_plugin.cpp:57
std::string shutdownSaveData()
Call the shutdown method in the plugin and return plugin data to parsist as JSON string.
Definition: north_plugin.cpp:192
void start()
Call the start method in the plugin with no persisted data.
Definition: north_plugin.cpp:78