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