hardware_interface.h
Go to the documentation of this file.
1 // Copyright (C) 2012, hiDOF INC.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright notice,
7 // this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name of hiDOF, Inc. nor the names of its
12 // contributors may be used to endorse or promote products derived from
13 // this software without specific prior written permission.
14 //
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
19 // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 // POSSIBILITY OF SUCH DAMAGE.
27 
28 /*
29  * Author: Wim Meeussen
30  */
31 
32 #pragma once
33 
34 
35 #include <exception>
36 #include <string>
37 #include <set>
38 #include <typeinfo>
39 
40 
41 namespace hardware_interface{
42 
47 {
48 public:
49  virtual ~HardwareInterface() = default;
50 
54  virtual void claim(std::string resource) { claims_.insert(resource); }
56 
58  void clearClaims() { claims_.clear(); }
59 
61  std::set<std::string> getClaims() const { return claims_; }
62 
63  /*\}*/
64 
65 private:
66  std::set<std::string> claims_;
67 };
68 
69 
71 class HardwareInterfaceException: public std::exception
72 {
73 public:
74  HardwareInterfaceException(const std::string& message) : msg(message) {}
75  const char* what() const noexcept override {return msg.c_str();}
76 private:
77  std::string msg;
78 };
79 }
hardware_interface::HardwareInterfaceException::what
const char * what() const noexcept override
Definition: hardware_interface.h:75
hardware_interface::HardwareInterface::clearClaims
void clearClaims()
Clear the resources this interface is claiming.
Definition: hardware_interface.h:58
hardware_interface::HardwareInterface
Abstract Hardware Interface.
Definition: hardware_interface.h:46
hardware_interface::HardwareInterface::getClaims
std::set< std::string > getClaims() const
Get the list of resources this interface is currently claiming.
Definition: hardware_interface.h:61
hardware_interface
Definition: actuator_command_interface.h:36
hardware_interface::HardwareInterface::~HardwareInterface
virtual ~HardwareInterface()=default
hardware_interface::HardwareInterface::claims_
std::set< std::string > claims_
Definition: hardware_interface.h:66
hardware_interface::HardwareInterfaceException::HardwareInterfaceException
HardwareInterfaceException(const std::string &message)
Definition: hardware_interface.h:74
hardware_interface::HardwareInterfaceException
An exception related to a HardwareInterface.
Definition: hardware_interface.h:71
hardware_interface::HardwareInterface::claim
virtual void claim(std::string resource)
Claim a resource by name.
Definition: hardware_interface.h:55
hardware_interface::HardwareInterfaceException::msg
std::string msg
Definition: hardware_interface.h:77


hardware_interface
Author(s): Wim Meeussen, Adolfo Rodriguez Tsouroukdissian
autogenerated on Tue Oct 15 2024 02:08:19