DataFieldIdentifier.cpp
Go to the documentation of this file.
1/*
2* This file is part of ArmarX.
3*
4* Copyright (C) 2011-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5*
6* ArmarX is free software; you can redistribute it and/or modify
7* it under the terms of the GNU General Public License version 2 as
8* published by the Free Software Foundation.
9*
10* ArmarX is distributed in the hope that it will be useful, but
11* WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17*
18* @package ArmarX::Core
19* @author Kai Welke (welke _at_ kit _dot_ edu)
20* @date 2011 Kai Welke
21* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22* GNU General Public License
23*/
24
27
28template class ::IceInternal::Handle<::armarx::DataFieldIdentifier>;
29
30namespace armarx
31{
32 DataFieldIdentifier::DataFieldIdentifier(std::string dataFieldIdentifierStr)
33 {
34 const std::string tmpStr = dataFieldIdentifierStr + "..";
35
36 const size_t pos1 = tmpStr.find_first_of(".") + 1; // one after the point
37 const size_t pos2 = tmpStr.find_first_of(".", pos1); // on the point
38 observerName = tmpStr.substr(0, pos1 - 1);
39 channelName = tmpStr.substr(pos1, pos2 - pos1);
40 if (pos2 < dataFieldIdentifierStr.size())
41 {
42 //we do not want to copy the trailing points
43 datafieldName = dataFieldIdentifierStr.substr(pos2 + 1);
44 }
45 }
46
48 std::string channelName,
49 std::string datafieldName)
50 {
51 this->observerName = observerName;
52 this->channelName = channelName;
53 this->datafieldName = datafieldName;
54 }
55
56 std::string
58 {
59 return observerName + "." + channelName + "." + datafieldName;
60 }
61
62 bool
64 {
65 std::string thisStr = getIdentifierStr();
66 std::string otherStr = dataFieldIdentifier.getIdentifierStr();
67
68 return (thisStr.compare(otherStr) == 0);
69 }
70
71 bool
73 {
74 std::string thisStr = getIdentifierStr();
75 std::string otherStr = dataFieldIdentifier.getIdentifierStr();
76
77 return (thisStr.compare(0, otherStr.length(), otherStr) == 0);
78 }
79} // namespace armarx
bool equals(const DataFieldIdentifier &dataFieldIdentifier)
Test two DataFieldIdentifier for equality.
DataFieldIdentifier()
Creates an empty DataFieldIdentifier.
bool beginsWith(const DataFieldIdentifier &dataFieldIdentifier)
Test if one DataFieldIdentifier contains the other.
std::string getIdentifierStr() const
Retrieve data field identifier string.
This file offers overloads of toIce() and fromIce() functions for STL container types.