37 if ((fVector->size() == 0) || (fVector->size() < fVector->capacity()))
return;
39 unsigned new_capacity = fVector->capacity()*2;
42 vect->reserve(new_capacity);
45 for (
unsigned n=0;n<fVector->size();n++) {
47 vect->back() << fVector->at(n);
58 if (ref.GetObject()==0)
return false;
65 fVector->back() << ref;
73 if (ref.GetObject()==0)
return false;
79 if (pos >= fVector->size()) {
80 fVector->back() << ref;
82 for (
unsigned n=fVector->size()-1; n>pos; n--)
83 fVector->at(n) << fVector->at(n-1);
84 fVector->at(pos) << ref;
93 if ((obj==0) || (GetSize()==0))
return false;
95 unsigned n = GetSize();
97 if (fVector->at(n).GetObject()==obj) RemoveAt(n);
105 if (n>=fVector->size())
return;
108 ref << fVector->at(n);
111 for (
unsigned indx = n; indx < fVector->size()-1;indx++)
112 fVector->at(indx) << fVector->at(indx+1);
129 if (n>=GetSize())
return false;
132 ref << fVector->at(n);
139 for (
unsigned n=0;n<GetSize();n++)
140 if (fVector->at(n).GetObject() == obj)
141 return ExtractRef(n, ref);
152 ref << fVector->back();
162 for (
unsigned n=0;n<fVector->size();n++) {
164 ref << fVector->at(n);
176 for (
unsigned n=0; n<fVector->size(); n++) {
178 if (obj && obj->
IsName(name, len))
return obj;
185 if (ptr==0)
return false;
186 for (
unsigned n=0; n<fVector->size(); n++)
187 if (fVector->at(n).GetObject() == ptr)
return true;
Base class for most of the DABC classes.
bool IsName(const char *str) const
Checks if object name is same as provided string, thread safe
Reference on the arbitrary object
void Release()
Releases reference on the object.
void Destroy()
Release reference and starts destroyment of referenced object.
Object * FindObject(const char *name, int len=-1) const
Simple search of object by name, no any subfolder structures.
virtual ~ReferencesVector()
Destructor.
bool HasObject(Object *ptr)
Return true if vector has pointer on the object.
void RemoveAt(unsigned n)
Remove reference on specified object
ReferencesVector()
Constructor.
Reference TakeLast()
Remove last reference from vector.
Reference TakeRef(unsigned n)
Remove reference from vector and return it to the user.
std::vector< Reference > refs_vector
refs_vector * fVector
vector with references
bool Clear(bool asowner=false)
Clear all references, if owner specified objects will be destroyed.
bool Add(Reference &ref)
Add reference to the vector.
bool Remove(Object *obj)
Remove reference on specified object
bool AddAt(Reference &ref, unsigned pos)
Add reference to the vector at specified position.
bool ExtractRef(unsigned n, Reference &ref)
Remove reference at specified position.