DABC (Data Acquisition Backbone Core)  2.9.9
ReferencesVector.h
Go to the documentation of this file.
1 // $Id: ReferencesVector.h 1763 2013-07-23 13:33:07Z linev $
2 
3 /************************************************************
4  * The Data Acquisition Backbone Core (DABC) *
5  ************************************************************
6  * Copyright (C) 2009 - *
7  * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
8  * Planckstr. 1, 64291 Darmstadt, Germany *
9  * Contact: http://dabc.gsi.de *
10  ************************************************************
11  * This software can be used under the GPL license *
12  * agreements as stated in LICENSE.txt file *
13  * which is part of the distribution. *
14  ************************************************************/
15 
16 #ifndef DABC_ReferencesVector
17 #define DABC_ReferencesVector
18 
19 #ifndef DABC_Reference
20 #include "dabc/Reference.h"
21 #endif
22 
23 #include <vector>
24 
25 namespace dabc {
26 
33  private:
34 
35  typedef std::vector<Reference> refs_vector;
36 
38 
39  void ExpandVector();
40 
41  public:
43  ReferencesVector() throw();
44 
46  virtual ~ReferencesVector() throw();
47 
49  bool Add(Reference& ref) throw();
50 
52  bool AddAt(Reference& ref, unsigned pos) throw();
53 
55  bool Remove(Object* obj) throw();
56 
58  void RemoveAt(unsigned n) throw();
59 
61  bool Clear(bool asowner = false) throw();
62 
64  unsigned GetSize() const { return fVector->size(); }
65 
67  inline Object* GetObject(unsigned n) const
68  { return (n<GetSize()) ? fVector->at(n).GetObject() : 0; }
69 
71  inline Reference Get(unsigned n) const { return Reference(n<GetSize() ? fVector->at(n).GetObject() : 0); }
72 
74  inline Reference operator[](unsigned n) const { return Get(n); }
75 
77  Reference TakeRef(unsigned n);
78 
81 
83  bool ExtractRef(unsigned n, Reference& ref);
84 
86  bool ExtractRef(Object* obj, Reference& ref);
87 
88 
90  Object* FindObject(const char* name, int len = -1) const;
91 
93  bool HasObject(Object* ptr);
94  };
95 
96 }
97 
98 #endif
Base class for most of the DABC classes.
Definition: Object.h:116
Reference on the arbitrary object
Definition: Reference.h:73
Vector of dabc::Reference objects.
Object * FindObject(const char *name, int len=-1) const
Simple search of object by name, no any subfolder structures.
unsigned GetSize() const
Returns number of items in vector.
Reference operator[](unsigned n) const
Returns new reference on object with index n.
bool HasObject(Object *ptr)
Return true if vector has pointer on the object.
void RemoveAt(unsigned n)
Remove reference on specified object
Reference Get(unsigned n) const
Returns new reference on object with index n.
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.
Object * GetObject(unsigned n) const
Returns pointer on the object.
Event manipulation API.
Definition: api.h:23