ADTF  3.18.2
builds/digitalwerk/solutions/adtf_content/adtf_base/adtf_core/extern/pkg_ddl/include/adtfddl/ddlrepresentation/ddl.h
Go to the documentation of this file.
1 
7 #ifndef _DDL_H_INCLUDED_
8 #define _DDL_H_INCLUDED_
9 
10 namespace adtf_ddl
11 {
12 
16  class cDDL : public IDDL
17  {
18  public:
19 
23  virtual ~cDDL(){}
24 
25  virtual bool IsInitialized() const;
26 
27  virtual bool IsPredefined() const;
28 
29  virtual bool IsOverwriteable() const;
30 
31  virtual int GetCreationLevel() const;
32 
40  template<typename T>
41  static T* DeleteChild(T *pvObj)
42  {
43  if (NULL != pvObj)
44  {
45  if (pvObj->IsPredefined())
46  {
47  return pvObj;
48  }
49  else
50  {
51  delete pvObj;
52  }
53  }
54  return NULL;
55  }
56 
65  template<typename T>
66  static tResult MoveChild(T *pvObj, const int nFrom, const int nTo)
67  {
69 
70  if (-1 == nFrom || -1 == nTo ||
71  (int)pvObj->size() < nFrom || (int)pvObj->size() < nTo)
72  {
73  RETURN_ERROR(ERR_OUT_OF_RANGE);
74  }
75 
76  if (nFrom != nTo)
77  {
78  if (nFrom < nTo)
79  {
80  std::rotate(pvObj->begin() + nFrom,
81  pvObj->begin() + nFrom + 1,
82  pvObj->begin() + nTo + 1);
83  }
84  else
85  {
86  std::rotate(pvObj->begin() + nTo,
87  pvObj->begin() + nFrom,
88  pvObj->begin() + nFrom + 1);
89  }
90  }
92  }
93 
102  template<typename T>
103  static T* Clone(T* pvObj)
104  {
105  if (NULL != pvObj)
106  {
107  if (pvObj->IsPredefined())
108  {
109  return Ref<T>(pvObj);
110  }
111  return new T(*pvObj);
112  }
113  return NULL;
114  }
115 
124  template<typename T>
125  static T* Ref(T* pvObj)
126  {
127  if (NULL != pvObj)
128  {
129  return pvObj;
130  }
131  return NULL;
132  }
133 
142  static bool IsEqual(IDDL* poLHS, IDDL* poRHS);
143 
152  static bool IsSorted(IDDL* poLHS, IDDL* poRHS);
153  };
154 
156  template<typename T = IDDL>
158  {
161 
167  cDDLCompareFunctor(const A_UTILS_NS::cString& strPattern): m_strPattern(strPattern)
168  {
169  }
170 
178  bool operator()(const T* poEntry)
179  {
180  if (NULL == poEntry)
181  {
182  return false;
183  }
184  return m_strPattern.IsEqual(poEntry->GetName());
185  }
186  };
187 
188 } // namespace adtf_ddl
189 
190 #endif // _DDL_H_INCLUDED_
#define RETURN_NOERROR
Return status ERR_NOERROR, which requires the calling function's return type to be tResult.
#define RETURN_ERROR(code)
Return specific error code, which requires the calling function's return type to be tResult.
#define RETURN_IF_POINTER_NULL(_ptr)
Return ERR_POINTER if _ptr is nullptr, which requires the calling function's return type to be tResul...
tBool IsEqual(const _myType &strCmp, tSize nPos=0, tSize nLength=InvalidPos) const
This function checks if the two strings are equal (case sensitive)
Definition: string.h:755
Interface class for object representation of DDL descriptions.
Definition: ddl_intf.h:25
virtual int GetCreationLevel() const
Getter for the creation level.
virtual bool IsOverwriteable() const
Getter for the predefinition flag.
static T * Ref(T *pvObj)
Functor for use with std::transform() to ref the objects where the elements of a vector point at,...
static T * DeleteChild(T *pvObj)
Functor for use with std::transform() to delete all objects where the elements of a vector point at.
virtual bool IsInitialized() const
Getter for the initialization flag.
virtual bool IsPredefined() const
Getter for the predefinition flag.
static tResult MoveChild(T *pvObj, const int nFrom, const int nTo)
Method moves element within the list.
static bool IsEqual(IDDL *poLHS, IDDL *poRHS)
Predicate to compare 2 DDL representation objects (for use with std::unique()).
static T * Clone(T *pvObj)
Functor for use with std::transform() to clone the objects where the elements of a vector point at.
static bool IsSorted(IDDL *poLHS, IDDL *poRHS)
Sort predicate to compare to 2 DDL representation objects (for use with std::sort()).
Namespace for the mainpage_pkg_ddl.