Browse Source

Tests: PityTree - add setName() / getChild()

LIB-11
heck 4 years ago
parent
commit
bb831cc338
  1. 5
      test/pitytest11/src/PityTree.hh
  2. 12
      test/pitytest11/src/PityTree.hxx

5
test/pitytest11/src/PityTree.hh

@ -28,9 +28,10 @@ namespace pEp {
T* getParent() const;
Children getChildren() const;
T& getChild(const std::string& name);
T& getRoot();
void setName(const std::string& name);
std::string getName() const;
std::string getPath() const;
bool isRoot() const; // true if has no parent
@ -47,7 +48,7 @@ namespace pEp {
private:
// Fields
const std::string _nodename;
std::string _nodename;
T& _self;
T* _parent = nullptr; //nullptr if RootUnit
Children _children; // map to guarantee uniqueness of sibling-names

12
test/pitytest11/src/PityTree.hxx

@ -63,6 +63,12 @@ namespace pEp {
}
}
template<class T>
void PityTree<T>::setName(const std::string& name)
{
_nodename = name;
}
template<class T>
std::string PityTree<T>::getName() const
{
@ -120,6 +126,12 @@ namespace pEp {
return _children;
}
template<class T>
T& PityTree<T>::getChild(const std::string& name)
{
return _children.at(name);
}
// name is alphanumeric only (everything else will be replaced by an underscore)
// static
template<class T>

Loading…
Cancel
Save