YARP
Yet Another Robot Platform
MonitorSharedLib.cpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 #include <yarp/os/Network.h>
7 #include <yarp/os/Log.h>
8 #include <yarp/os/YarpPlugin.h>
9 
10 #include "MonitorSharedLib.h"
11 
12 
13 using namespace yarp::os;
14 
15 
16 
18  bool select(Searchable& options) override {
19  return options.check("type",Value("none")).asString() == "portmonitor";
20  }
21 };
22 
27 {
28 }
29 
31 {
32  if (monitor.isValid()) {
33  monitor->destroy();
34  }
35  monitor.close();
36 }
37 
39 {
40  MonitorSelector selector;
41  selector.scan();
42 
43  settings.setPluginName(options.find("filename").asString());
44  if (!settings.setSelector(selector)) {
45  return false;
46  }
47 
48  if (!plugin.open(settings)) {
49  return false;
50  }
51 
52  monitor.open(*plugin.getFactory());
53  if (!monitor.isValid()) {
54  return false;
55  }
56 
57  settings.setLibraryMethodName(plugin.getFactory()->getName(),
58  settings.getMethodName());
59  settings.setClassInfo(plugin.getFactory()->getClassName(),
60  plugin.getFactory()->getBaseClassName());
61 
62  return monitor->create(options);
63 }
64 
66 {
67  return monitor->setparam(params);
68 }
69 
71 {
72  return monitor->getparam(params);
73 }
74 
76 {
77  return monitor->accept(thing);
78 }
79 
80 
82 {
83  return monitor->update(thing);
84 }
85 
87 {
88  return monitor->updateReply(thing);
89 }
90 
91 
93 {
94  monitor->trig();
95  return true;
96 }
97 
99 {
100  if (constraint == "") {
101  return true;
102  }
103  //TODO: constraint checking should be implemented here!
104  return true;
105 }
yarp::os::Things & updateData(yarp::os::Things &thing) override
bool canAccept() override
bool peerTrigged() override
bool acceptData(yarp::os::Things &thing) override
bool setParams(const yarp::os::Property &params) override
MonitorSharedLib()
Class MonitorSharedLib.
yarp::os::Things & updateReply(yarp::os::Things &thing) override
bool load(const yarp::os::Property &options) override
~MonitorSharedLib() override
bool getParams(yarp::os::Property &params) override
A class for storing options and configuration information.
Definition: Property.h:34
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
Definition: Property.cpp:1051
A base class for nested structures that can be searched.
Definition: Searchable.h:66
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
Base class for generic things.
Definition: Things.h:19
A single value (typically within a Bottle).
Definition: Value.h:45
virtual std::string asString() const
Get string value.
Definition: Value.cpp:234
Pick out a set of relevant plugins.
void scan()
Find plugin configuration files, and run [plugin] sections through the select method.
Definition: YarpPlugin.cpp:210
An interface to the operating system, including Port based communication.