ChimeraTK-DeviceAccess 03.25.00
Loading...
Searching...
No Matches
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
9namespace 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 */
Class to store a register path name.
std::string path
path in standardised notation
static const char separator[]
separator character to separate the elements in the path
void setAltSeparator(const std::string &altSeparator)
set alternative separator.
std::string getCommonAltSeparator(const RegisterPath &otherPath) const
return common alternative separator for this RegisterPath and the specified other RegisterPath object...
void removeExtraSeparators()
Search for duplicate separators (e.g.
std::string separator_alt
altenative separator character
std::string operator+(const std::string &leftHandSide, const RegisterPath &rightHandSide)
non-member + operator for RegisterPath: concatenate with normal strings.
RegisterPath operator/(const RegisterPath &leftHandSide, const RegisterPath &rightHandSide)
non-member / operator: add a new element to the path.
std::ostream & operator<<(std::ostream &stream, const DataDescriptor::FundamentalType &fundamentalType)
RegisterPath operator*(const RegisterPath &leftHandSide, int rightHandSide)
std::string to_string(const std::string &v)