Browse Source

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

LIB-11
heck 11 months ago
parent
commit
bb831cc338
2 changed files with 19 additions and 6 deletions
  1. +3
    -2
      test/pitytest11/src/PityTree.hh
  2. +16
    -4
      test/pitytest11/src/PityTree.hxx

+ 3
- 2
test/pitytest11/src/PityTree.hh View File

@ -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


+ 16
- 4
test/pitytest11/src/PityTree.hxx View File

@ -21,13 +21,13 @@ namespace pEp {
namespace PityTest11 {
template<class T>
PityTree<T>::PityTree(T& self, const std::string &name) :
PityTree<T>::PityTree(T& self, const std::string& name) :
_self{ self }, _nodename{ _normalizeName(name) }
{
}
template<class T>
PityTree<T>::PityTree(T& self, const std::string &name, T& parent) :
PityTree<T>::PityTree(T& self, const std::string& name, T& parent) :
_self(self), _nodename{ _normalizeName(name) }
{
parent.add(_self);
@ -42,13 +42,13 @@ namespace pEp {
}
template<class T>
void PityTree<T>::setParent(T *parent)
void PityTree<T>::setParent(T* parent)
{
_parent = parent;
}
template<class T>
T *PityTree<T>::getParent() const
T* PityTree<T>::getParent() const
{
return _parent;
}
@ -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