DeviceBase.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package RobotAPI
17 * @author Raphael Grimm ( raphael dot grimm at kit dot edu )
18 * @date 2017
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
23#pragma once
24
25#include "../util.h"
26
27namespace armarx
28{
30 {
31 public:
32 /// @brief Create a Device with the given name
33 DeviceBase(const std::string& name) : deviceName{name}
34 {
35 }
36
37 virtual ~DeviceBase() = default;
38 /// @return The Device's name
39 const std::string& getDeviceName() const;
40 /// @return The Device's name
41 const char* rtGetDeviceName() const;
42 //tags
43 /// @return Thes set of tags for this Device
44 const std::set<std::string>& getTags() const;
45 /// @return Whether the device has the given tag
46 bool hasTag(const std::string& tag) const;
47
48 virtual bool
50 {
51 return false;
52 }
53
54 protected:
55 /// @brief adds the given tag to the Device
56 void addDeviceTag(const std::string& tag);
57
58 private:
59 std::set<std::string> tags;
60 const std::string deviceName;
61 };
62} // namespace armarx
63
64//inline functions
65namespace armarx
66{
67 inline bool
68 DeviceBase::hasTag(const std::string& tag) const
69 {
70 return getTags().count(tag);
71 }
72
73 inline void
74 DeviceBase::addDeviceTag(const std::string& tag)
75 {
76 tags.emplace(tag);
77 }
78
79 inline const std::string&
81 {
82 return deviceName;
83 }
84
85 inline const char*
87 {
88 return deviceName.c_str();
89 }
90
91 inline const std::set<std::string>&
93 {
94 return tags;
95 }
96} // namespace armarx
const char * rtGetDeviceName() const
Definition DeviceBase.h:86
const std::set< std::string > & getTags() const
Definition DeviceBase.h:92
DeviceBase(const std::string &name)
Create a Device with the given name.
Definition DeviceBase.h:33
bool hasTag(const std::string &tag) const
Definition DeviceBase.h:68
void addDeviceTag(const std::string &tag)
adds the given tag to the Device
Definition DeviceBase.h:74
const std::string & getDeviceName() const
Definition DeviceBase.h:80
virtual bool hasError()
Definition DeviceBase.h:49
virtual ~DeviceBase()=default
This file offers overloads of toIce() and fromIce() functions for STL container types.