DataStoreItem.h
Go to the documentation of this file.
1 #ifndef GAUDIKERNEL_DATASTOREITEM_H
2 #define GAUDIKERNEL_DATASTOREITEM_H
3 
4 // STL include files
5 #include <string>
6 
18 protected:
22  int m_depth;
23 public:
26  : m_path(std::move(path)), m_depth(depth) {
27  analyse();
28  }
31  : m_path(item.m_path), m_depth(item.m_depth) {
32  analyse();
33  }
35  virtual ~DataStoreItem() = default;
36 
38  bool operator==(const DataStoreItem& cmp) const {
39  return m_path == cmp.path() && m_depth == cmp.depth();
40  }
42  bool operator!=(const DataStoreItem& cmp) const {
43  return ! ( m_path == cmp.path() && m_depth == cmp.depth() );
44  }
47  m_path = cmp.path();
48  m_depth = cmp.depth();
49  analyse();
50  return *this;
51  }
53  void analyse() {
54  int len = m_path.length()-1;
55  if ( m_path[len] == '*' ) {
56  m_depth = 99999999;
57  (m_path[len-1] == '/') ? m_path.erase(len-1, 2) : m_path.erase(len, 1);
58  }
59  else if ( m_path[len] == '+' ) {
60  (m_path[len-1] == '/') ? m_path.erase(len-1, 2) : m_path.erase(len, 1);
61  m_depth = 2;
62  }
63  }
65  const std::string& path() const {
66  return m_path;
67  }
69  int depth() const {
70  return m_depth;
71  }
72 };
73 #endif // GAUDIKERNEL_DATASTOREITEM_H
int depth() const
Accessor: Retrieve load depth.
Definition: DataStoreItem.h:69
std::string m_path
Path of item to be loaded.
Definition: DataStoreItem.h:20
bool operator!=(const DataStoreItem &cmp) const
Inequality operator.
Definition: DataStoreItem.h:42
STL namespace.
Description of the DataStoreItem class.
Definition: DataStoreItem.h:17
const std::string & path() const
Accessor: Retrieve load path.
Definition: DataStoreItem.h:65
STL class.
void analyse()
Interprete the load path for special options.
Definition: DataStoreItem.h:53
DataStoreItem(std::string path, int depth=1)
Standard Constructor.
Definition: DataStoreItem.h:25
T erase(T...args)
int m_depth
Depth to be auto-loaded from the requested path onwards.
Definition: DataStoreItem.h:22
bool operator==(const DataStoreItem &cmp) const
Equality operator.
Definition: DataStoreItem.h:38
T length(T...args)
virtual ~DataStoreItem()=default
Standard Destructor.
DataStoreItem & operator=(const DataStoreItem &cmp)
Equivalence operator.
Definition: DataStoreItem.h:46
DataStoreItem(const DataStoreItem &item)
Copy constructor.
Definition: DataStoreItem.h:30