YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
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>
9
10#include "MonitorSharedLib.h"
11
12
13using namespace yarp::os;
14
15
16
18 bool select(Searchable& options) override {
19 return options.check("type",Value("none")).asString() == "portmonitor";
20 }
21};
22
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:33
Value & find(const std::string &key) const override
Gets a value corresponding to a given keyword.
A base class for nested structures that can be searched.
Definition Searchable.h:31
virtual bool check(const std::string &key) const =0
Check if there exists a property of the given name.
bool open(SharedLibraryClassFactory< T > &factory)
Construct an instance using the specified factory.
virtual bool close()
Destroy an instance if one has been created.
bool isValid() const
Check whether a valid instance has been created.
std::string getBaseClassName() const
Get the base type associated with this factory.
std::string getClassName() const
Get the type associated with this factory.
std::string getName() const
Get the name associated with this factory.
Base class for generic things.
Definition Things.h:18
A single value (typically within a Bottle).
Definition Value.h:43
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.
bool setSelector(YarpPluginSelector &selector)
Use a selector to find a plugin or plugins.
void setLibraryMethodName(const std::string &dll_name, const std::string &fn_name)
Set the name of the library to load and the method name to use as a factory.
void setPluginName(const std::string &name)
Set the name of the plugin to load.
void setClassInfo(const std::string &class_name, const std::string &baseclass_name)
Set the information about the class and the base class constructed by this plugin.
SharedLibraryClassFactory< T > * getFactory() const
Definition YarpPlugin.h:179
bool open(YarpPluginSettings &settings)
Load a library and prepare an object factory, based on the hints supplied.
Definition YarpPlugin.h:58
An interface to the operating system, including Port based communication.