| 1 |
/* |
| 2 |
* Copyright (C) 2013-2015, 2019 by the Konclude Developer Team. |
| 3 |
* |
| 4 |
* This file is part of the reasoning system Konclude. |
| 5 |
* For details and support, see <http://konclude.com/>. |
| 6 |
* |
| 7 |
* Konclude is free software: you can redistribute it and/or modify |
| 8 |
* it under the terms of version 3 of the GNU Lesser General Public |
| 9 |
* License (LGPLv3) as published by the Free Software Foundation. |
| 10 |
* |
| 11 |
* Konclude is distributed in the hope that it will be useful, |
| 12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 |
* GNU (Lesser) General Public License for more details. |
| 15 |
* |
| 16 |
* You should have received a copy of the GNU (Lesser) General Public |
| 17 |
* License along with Konclude. If not, see <http://www.gnu.org/licenses/>. |
| 18 |
* |
| 19 |
*/ |
| 20 |
|
| 21 |
#ifndef KONCLUDE_UTILITIES_CONTAINER_CDYNAMICREFERENCEVECTOR_H |
| 22 |
#define KONCLUDE_UTILITIES_CONTAINER_CDYNAMICREFERENCEVECTOR_H |
| 23 |
|
| 24 |
// Namespace includes |
| 25 |
#include "ContainerSettings.h" |
| 26 |
|
| 27 |
// Library includes |
| 28 |
|
| 29 |
// Other includes |
| 30 |
#include "CDynamicReferenceBucket.h" |
| 31 |
|
| 32 |
// Logger includes |
| 33 |
|
| 34 |
|
| 35 |
namespace Konclude { |
| 36 |
|
| 37 |
using namespace Context; |
| 38 |
|
| 39 |
namespace Utilities { |
| 40 |
|
| 41 |
namespace Container { |
| 42 |
|
| 43 |
|
| 44 |
/*! |
| 45 |
* |
| 46 |
* \class CDynamicReferenceVectorBase |
| 47 |
* \author Andreas Steigmiller |
| 48 |
* \version 0.1 |
| 49 |
* \brief TODO |
| 50 |
* |
| 51 |
*/ |
| 52 |
template<class T, class S, cint64 bucket2Size = 5> |
| 53 |
class CDynamicReferenceVectorBase { |
| 54 |
// public methods |
| 55 |
public: |
| 56 |
//! Constructor |
| 57 |
inline CDynamicReferenceVectorBase(CContext* context = nullptr); |
| 58 |
|
| 59 |
//! Destructor |
| 60 |
inline ~CDynamicReferenceVectorBase(); |
| 61 |
|
| 62 |
inline const T getData(cint64 index, const T& defaultValue); |
| 63 |
inline const T getData(cint64 index, const T& defaultValue, bool* localFlag); |
| 64 |
inline const T getLocalData(cint64 index, const T& defaultValue); |
| 65 |
inline const T getReferenceData(cint64 index, const T& defaultValue); |
| 66 |
|
| 67 |
inline S* setLocalData(cint64 index, const T& data); |
| 68 |
inline S* setData(cint64 index, const T& data); |
| 69 |
|
| 70 |
inline bool hasLocalData(cint64 index); |
| 71 |
inline bool hasData(cint64 index); |
| 72 |
inline bool hasReferencedData(cint64 index); |
| 73 |
|
| 74 |
inline S* clear(); |
| 75 |
inline S* referenceVector(CDynamicReferenceVectorBase<T,S,bucket2Size>* refVector); |
| 76 |
|
| 77 |
inline cint64 getItemCount(); |
| 78 |
inline cint64 getItemMaxIndex(); |
| 79 |
|
| 80 |
inline cint64 getReferencedItemCount(); |
| 81 |
inline cint64 getReferencedItemMaxIndex(); |
| 82 |
|
| 83 |
// protected methods |
| 84 |
protected: |
| 85 |
|
| 86 |
// protected variables |
| 87 |
protected: |
| 88 |
CContext* mContext; |
| 89 |
cint64 mMaxIndex; |
| 90 |
cint64 mRootBucketDepth; |
| 91 |
cint64 mMaxItem; |
| 92 |
cint64 mReferencedMaxItem; |
| 93 |
|
| 94 |
CDynamicReferenceVectorBase<T,S,bucket2Size>* mReferenceVector; |
| 95 |
|
| 96 |
CDynamicReferenceBucketBase<T,bucket2Size>* mRootBucket; |
| 97 |
|
| 98 |
// private methods |
| 99 |
private: |
| 100 |
|
| 101 |
// private variables |
| 102 |
private: |
| 103 |
}; |
| 104 |
|
| 105 |
|
| 106 |
|
| 107 |
/*! |
| 108 |
* |
| 109 |
* \class CDynamicReferenceVector |
| 110 |
* \author Andreas Steigmiller |
| 111 |
* \version 0.1 |
| 112 |
* \brief TODO |
| 113 |
* |
| 114 |
*/ |
| 115 |
template<class T, cint64 bucket2Size = 5> |
| 116 |
class CDynamicReferenceVector : public CDynamicReferenceVectorBase<T,CDynamicReferenceVector<T,bucket2Size>,bucket2Size> { |
| 117 |
// public methods |
| 118 |
public: |
| 119 |
// Constructor |
| 120 |
inline CDynamicReferenceVector(CContext* context = nullptr) : CDynamicReferenceVectorBase<T,CDynamicReferenceVector<T,bucket2Size>,bucket2Size>(context) {}; |
| 121 |
|
| 122 |
//! Destructor |
| 123 |
inline ~CDynamicReferenceVector() {}; |
| 124 |
}; |
| 125 |
|
| 126 |
|
| 127 |
}; // end namespace Container |
| 128 |
|
| 129 |
}; // end namespace Utilities |
| 130 |
|
| 131 |
}; // end namespace Konclude |
| 132 |
|
| 133 |
#include "CDynamicReferenceVector.cpp" |
| 134 |
|
| 135 |
#endif // KONCLUDE_UTILITIES_CONTAINER_CDYNAMICREFERENCEVECTOR_H |