20 template <
class Type,
int N,
class ComponentType>
34 if (!
copy(*cloneArray)) {
46 static_cast<std::vector<Type>&
>(dest) =
47 static_cast<const std::vector<Type>&
>(*
this);
48 }
catch (
const std::bad_alloc&) {
59 }
catch (
const std::bad_alloc&) {
67 inline bool isAllocated()
const {
return this->capacity() != 0; }
71 bool initNewElements =
false,
72 const Type* valueForNewElements =
nullptr) {
74 if (initNewElements) {
75 if (!valueForNewElements) {
77 "[ccArray::resizeSafe] Internal error: no new "
81 this->resize(
count, *valueForNewElements);
85 }
catch (
const std::bad_alloc&) {
96 inline virtual bool isShareable()
const override {
return true; }
100 inline Type&
getValue(
size_t index) {
return this->
at(index); }
101 inline const Type&
getValue(
size_t index)
const {
return this->
at(index); }
102 inline void setValue(
size_t index,
const Type& value) {
103 this->
at(index) = value;
105 inline void addElement(
const Type& value) { this->emplace_back(value); }
106 inline void fill(
const Type& value) {
108 this->resize(this->capacity(), value);
110 std::fill(this->begin(), this->end(), value);
113 return static_cast<unsigned>(this->
size());
115 inline void clear(
bool releaseMemory =
false) {
119 this->std::vector<Type>::clear();
121 inline void swap(
size_t i1,
size_t i2) {
133 if (dataVersion < 20) {
138 ComponentType>(*
this,
150 *
this, in, dataVersion,
"array");
int64_t CV_CLASS_ENUM
Type of object type flags (64 bits)
virtual void release()
Decrease counter and deletes object when 0.
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
Shareable array that can be properly inserted in the DB tree.
const Type & getValue(size_t index) const
Type & getValue(size_t index)
ccArray< Type, N, ComponentType > Base
Base type.
void fill(const Type &value)
bool isAllocated() const
Returns whether some memory has been allocated or not.
bool resizeSafe(size_t count, bool initNewElements=false, const Type *valueForNewElements=nullptr)
Resizes memory (no exception thrown)
bool reserveSafe(size_t count)
Reserves memory (no exception thrown)
void setValue(size_t index, const Type &value)
unsigned currentSize() const
void addElement(const Type &value)
virtual bool isSerializable() const override
Returns whether object is serializable of not.
virtual Base * clone()
Duplicates array.
virtual ~ccArray()
Destructor (protected)
void swap(size_t i1, size_t i2)
virtual CV_CLASS_ENUM getClassID() const override
Returns class ID.
bool toFile_MeOnly(QFile &out, short dataVersion) const override
Save own object data.
virtual bool isShareable() const override
Returns whether object is shareable or not.
bool copy(Base &dest) const
Copies the content of this array in another one.
bool fromFile_MeOnly(QFile &in, short dataVersion, int flags, LoadedIDMap &oldToNewIDMap) override
Loads own object data.
void clear(bool releaseMemory=false)
short minimumFileVersion_MeOnly() const override
ccArray(QString name=QString())
Default constructor.
Hierarchical CLOUDVIEWER Object.
virtual void setFlagState(CV_OBJECT_FLAG flag, bool state)
Sets flag state.
virtual QString getName() const
Returns object name.
QMultiMap< unsigned, unsigned > LoadedIDMap
Map of loaded unique IDs (old ID --> new ID)
static bool GenericArrayFromFile(std::vector< Type > &data, QFile &in, short dataVersion, const QString &verboseDescription)
Helper: loads a vector structure from file.
static bool GenericArrayToFile(const std::vector< Type > &data, QFile &out)
Helper: saves a vector to file.
static short GenericArrayToFileMinVersion()
Returns the minimum file version to save/load a 'generic array'.
void swap(cloudViewer::core::SmallVectorImpl< T > &LHS, cloudViewer::core::SmallVectorImpl< T > &RHS)
Implement std::swap in terms of SmallVector swap.