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 
26 
28 
29 template class ::IceInternal::Handle<::armarx::DataFieldIdentifier>;
30 
31 namespace armarx
32 {
33  DataFieldIdentifier::DataFieldIdentifier(std::string dataFieldIdentifierStr)
34  {
35  const std::string tmpStr = dataFieldIdentifierStr + "..";
36 
37  const size_t pos1 = tmpStr.find_first_of(".") + 1; // one after the point
38  const size_t pos2 = tmpStr.find_first_of(".", pos1); // on the point
39  observerName = tmpStr.substr(0, pos1 - 1);
40  channelName = tmpStr.substr(pos1, pos2 - pos1);
41  if (pos2 < dataFieldIdentifierStr.size())
42  {
43  //we do not want to copy the trailing points
44  datafieldName = dataFieldIdentifierStr.substr(pos2 + 1);
45  }
46  }
47 
48  DataFieldIdentifier::DataFieldIdentifier(std::string observerName, std::string channelName, std::string datafieldName)
49  {
50  this->observerName = observerName;
51  this->channelName = channelName;
52  this->datafieldName = datafieldName;
53  }
54 
55 
56  std::string DataFieldIdentifier::getIdentifierStr() const
57  {
58  return observerName + "." + channelName + "." + datafieldName;
59  }
60 
61  bool DataFieldIdentifier::equals(const DataFieldIdentifier& dataFieldIdentifier)
62  {
63  std::string thisStr = getIdentifierStr();
64  std::string otherStr = dataFieldIdentifier.getIdentifierStr();
65 
66  return (thisStr.compare(otherStr) == 0);
67  }
68 
69  bool DataFieldIdentifier::beginsWith(const DataFieldIdentifier& dataFieldIdentifier)
70  {
71  std::string thisStr = getIdentifierStr();
72  std::string otherStr = dataFieldIdentifier.getIdentifierStr();
73 
74  return (thisStr.compare(0, otherStr.length(), otherStr) == 0);
75  }
76 }
DataFieldIdentifier.h
StringHelpers.h
armarx::DataFieldIdentifier::getIdentifierStr
std::string getIdentifierStr() const
Retrieve data field identifier string.
Definition: DataFieldIdentifier.cpp:56
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::DataFieldIdentifier
DataFieldIdentifier provide the basis to identify data field within a distributed ArmarX scenario.
Definition: DataFieldIdentifier.h:48