ChimeraTK-DeviceAccess  03.18.00
RegisterPath.cc
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Deutsches Elektronen-Synchrotron DESY, MSK, ChimeraTK Project <chimeratk-support@desy.de>
2 // SPDX-License-Identifier: LGPL-3.0-or-later
3 
4 #include "RegisterPath.h"
5 
6 #include <iostream>
7 #include <tuple>
8 
9 namespace ChimeraTK {
10 
11  const char RegisterPath::separator[] = "/";
12 
13  /********************************************************************************************************************/
14 
15  RegisterPath operator/(const RegisterPath& leftHandSide, const RegisterPath& rightHandSide) {
16  std::ignore =
17  leftHandSide.getCommonAltSeparator(rightHandSide); // just to check compatibility of the two RegisterPaths
18  RegisterPath ret(leftHandSide);
19  ret.path += rightHandSide.path; // rightHandSide has a leading separator
21  return ret;
22  }
23 
24  /********************************************************************************************************************/
25 
26  std::string operator+(const std::string& leftHandSide, const RegisterPath& rightHandSide) {
27  return leftHandSide + ((std::string)rightHandSide);
28  }
29 
30  /********************************************************************************************************************/
31 
32  RegisterPath operator+(const RegisterPath& leftHandSide, const std::string& rightHandSide) {
33  RegisterPath ret(leftHandSide);
34  ret.path += rightHandSide;
36  return ret;
37  }
38 
39  /********************************************************************************************************************/
40 
41  RegisterPath operator/(const RegisterPath& leftHandSide, int rightHandSide) {
42  return leftHandSide / std::to_string(rightHandSide);
43  }
44 
45  /********************************************************************************************************************/
46 
47  RegisterPath operator*(const RegisterPath& leftHandSide, int rightHandSide) {
48  RegisterPath ret(std::string(leftHandSide) + std::string("*") + std::to_string(rightHandSide));
49  ret.setAltSeparator(leftHandSide.separator_alt);
51  return ret;
52  }
53 
54  /********************************************************************************************************************/
55 
56  std::ostream& operator<<(std::ostream& os, const RegisterPath& me) {
57  return os << std::string(me);
58  }
59 
60 } /* namespace ChimeraTK */
ChimeraTK::RegisterPath::removeExtraSeparators
void removeExtraSeparators()
Search for duplicate separators (e.g.
Definition: RegisterPath.h:192
ChimeraTK::RegisterPath::setAltSeparator
void setAltSeparator(const std::string &altSeparator)
set alternative separator.
Definition: RegisterPath.h:37
ChimeraTK::operator*
RegisterPath operator*(const RegisterPath &leftHandSide, int rightHandSide)
Definition: RegisterPath.cc:47
ChimeraTK::operator+
std::string operator+(const std::string &leftHandSide, const RegisterPath &rightHandSide)
non-member + operator for RegisterPath: concatenate with normal strings.
Definition: RegisterPath.cc:26
ChimeraTK::operator/
RegisterPath operator/(const RegisterPath &leftHandSide, const RegisterPath &rightHandSide)
non-member / operator: add a new element to the path.
Definition: RegisterPath.cc:15
ChimeraTK::RegisterPath::separator
static const char separator[]
separator character to separate the elements in the path
Definition: RegisterPath.h:185
ChimeraTK::RegisterPath::getCommonAltSeparator
std::string getCommonAltSeparator(const RegisterPath &otherPath) const
return common alternative separator for this RegisterPath and the specified other RegisterPath object...
Definition: RegisterPath.h:224
ChimeraTK::RegisterPath
Class to store a register path name.
Definition: RegisterPath.h:16
ChimeraTK::operator<<
std::ostream & operator<<(std::ostream &stream, const DataDescriptor::FundamentalType &fundamentalType)
Definition: DataDescriptor.cpp:195
ChimeraTK::RegisterPath::separator_alt
std::string separator_alt
altenative separator character
Definition: RegisterPath.h:188
ChimeraTK
Definition: DummyBackend.h:16
ChimeraTK::to_string
std::string to_string(Boolean &value)
Definition: SupportedUserTypes.h:59
ChimeraTK::RegisterPath::path
std::string path
path in standardised notation
Definition: RegisterPath.h:182
RegisterPath.h