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