YARP
Yet Another Robot Platform
logicresource.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 
7 
8 #include <cstring>
9 
10 
11 using namespace yarp::manager;
12 
13 
18 {
19 }
20 
21 Platform::Platform(const char* szName) : GenericResource("Platform")
22 {
23  setName(szName);
24 }
25 
27 {
28  auto* resource = new Platform(*this);
29  return resource;
30 }
31 
33 {
34  if (!getAvailability() || getDisable()) {
35  return false;
36  }
37 
38  auto* os = dynamic_cast<Platform*>(resource);
39  if (os) {
40  return satisfy_platform(os);
41  }
42 
43  return false;
44 }
45 
46 bool Platform::satisfy_platform(Platform* os)
47 {
48  bool ret = (!strlen(os->getName()))? true : (compareString(getName(), os->getName()));
49  ret &= (!strlen(os->getDistribution()))? true : (compareString(strDistrib.c_str(), os->getDistribution()));
50  ret &= (!strlen(os->getRelease()))? true : (compareString(strRelease.c_str(), os->getRelease()));
51  return ret;
52 }
53 
54 Platform::~Platform() = default;
55 
56 
57 
62 {
63  timeout = 0;
64  strRequest = strReply = "";
65 }
66 
67 ResYarpPort::ResYarpPort(const char* szName) : GenericResource("ResYarpPort")
68 {
69  timeout = 0;
70  setName(szName);
71 }
72 
74 {
75  auto* resource = new ResYarpPort(*this);
76  return resource;
77 }
78 
80 {
81  if (!getAvailability() || getDisable()) {
82  return false;
83  }
84 
85  auto* resport = dynamic_cast<ResYarpPort*>(resource);
86  if (!resport) {
87  return false;
88  }
89  return (strPort == std::string(resport->getPort()) ||
90  strPort == std::string(resport->getName()) );
91 }
92 
93 ResYarpPort::~ResYarpPort() = default;
bool ret
void setName(const char *szName)
Definition: resource.h:28
a Node of a Graph
Definition: node.h:65
Node * clone() override
Platform()
Class Platform.
const char * getDistribution()
Definition: logicresource.h:30
const char * getRelease()
Definition: logicresource.h:31
bool satisfy(GenericResource *resource) override
bool satisfy(GenericResource *resource) override
ResYarpPort()
Class ResYarpPort.
bool compareString(const char *szFirst, const char *szSecond)
Definition: utility.cpp:310