Browse Source

Test: PityTest - PityTree addCopy() for lvalue refs, too, please, add getChildrenCount(), debatable, copy-assign i think i like to avoid it.

LIB-11
heck 11 months ago
parent
commit
8fa9e24d1e
2 changed files with 29 additions and 11 deletions
  1. +7
    -2
      test/pitytest11/src/PityTree.hh
  2. +22
    -9
      test/pitytest11/src/PityTree.hxx

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

@ -29,7 +29,7 @@ namespace pEp {
explicit PityTree(const PityTree& rhs, T& owner);
// copy-assign
PityTree& operator=(const PityTree<T>& rhs);
// PityTree& operator=(const PityTree<T>& rhs);
// clone
virtual PityTree* clone() = 0;
@ -39,16 +39,21 @@ namespace pEp {
template<typename CT, typename... Args>
CT& addNew(Args&&... args);
// Creates a copy, add the copy as child and returns a ref to it
// Creates a copy, adds the copy as child and returns a ref to it
template<typename CT>
CT& addCopy(const CT&& child, const std::string& new_name = "");
template<typename CT>
CT& addCopy(const CT& child, const std::string& new_name = "");
// Just adds child as a non-owned reference.
T& addRef(T& child);
// Query
virtual T& getSelf() = 0;
T* getParent() const;
ChildRefs getChildRefs() const;
int getChildCount() const;
T& getChild(const std::string& name);
T& getRoot();


+ 22
- 9
test/pitytest11/src/PityTree.hxx View File

@ -37,15 +37,15 @@ namespace pEp {
_copyChildRefs(rhs);
}
template<class T>
PityTree<T>& PityTree<T>::operator=(const PityTree<T>& rhs)
{
_nodename = rhs._nodename;
_parent = nullptr;
_copyChildRefs(rhs);
return *this;
}
// template<class T>
// PityTree<T>& PityTree<T>::operator=(const PityTree<T>& rhs)
// {
// _nodename = rhs._nodename;
// _parent = nullptr;
// _copyChildRefs(rhs);
// return *this;
// }
//
template<typename T>
template<typename CT, typename... Args>
CT& PityTree<T>::addNew(Args&&... args)
@ -71,6 +71,13 @@ namespace pEp {
return *tmpraw;
}
template<typename T>
template<typename CT>
CT& PityTree<T>::addCopy(const CT& child, const std::string& new_name)
{
return addCopy(std::move(child));
}
template<class T>
T& PityTree<T>::addRef(T& child)
{
@ -201,6 +208,12 @@ namespace pEp {
addRef(ret);
}
}
template<class T>
int PityTree<T>::getChildCount() const
{
return _childrefs.size();
}
} // namespace PityTest11
} // namespace pEp

Loading…
Cancel
Save