CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
QueryableVector.h
Go to the documentation of this file.
1 #ifndef INCLUDE_ORA_QUERYABLEVECTOR_H
2 #define INCLUDE_ORA_QUERYABLEVECTOR_H
3 
4 #include "QueryableVectorData.h"
5 #include "Selection.h"
6 
7 namespace ora {
8 
9  template <typename Tp> class Range {
10  public:
11 
12  typedef const Tp& const_reference;
15 
16  public:
17  Range();
18 
19  explicit Range(boost::shared_ptr<QueryableVectorData<Tp> >& data);
20 
21  Range(const Range& rhs);
22 
23  virtual ~Range();
24 
25  Range& operator=(const Range& rhs);
26 
27  const_iterator begin() const;
28 
29  const_iterator end() const;
30 
32 
34 
35  size_t size() const;
36 
37  size_t frontIndex() const;
38 
39  size_t backIndex() const;
40 
41  private:
42 
43  boost::shared_ptr<QueryableVectorData<Tp> > m_data;
44  };
45 
46  template <typename Tp> class Query: public LoaderClient {
47  public:
48  explicit Query(boost::shared_ptr<IVectorLoader>& loader);
49 
50  virtual ~Query(){
51  }
52 
53  template <typename Prim> void addSelection(const std::string& dataMemberName, SelectionItemType stype, Prim selectionData);
54 
55  size_t count();
56 
58 
59  private:
61  };
62 
63  template <typename Tp> class QueryableVector: public LoaderClient {
64 
65  public:
66 
67  // std::vector like typedefs
68  typedef Tp& reference;
69  typedef const Tp& const_reference;
75  // pool specific typedefs
76  typedef Query<Tp> pquery;
77  typedef Range<Tp> prange;
81 
82  public:
83  // default constructor
85 
86  // constructor
87  explicit QueryableVector(size_t n, const Tp& value=Tp());
88 
89  // copy constructor: not sure what to do...
91 
92  // destructor
93  virtual ~QueryableVector();
94 
95  // assignment operator: not sure what to do...
97 
98  public:
99 
100  Range<Tp> select(int startIndex, int endIndex=Selection::endOfRange) const;
101 
102  Range<Tp> select(const Selection& sel) const;
103 
104  Query<Tp> query() const;
105 
106  bool lock();
107 
108  bool isLocked() const;
109 
110  public:
111 
112  iterator begin();
113 
114  iterator end();
115 
116  const_iterator begin() const;
117 
118  const_iterator end() const;
119 
121 
123 
125 
127 
128  size_t size() const;
129 
130  size_t max_size() const;
131 
132  void resize(size_t n, const Tp& value=Tp());
133 
134  size_t capacity() const;
135 
136  bool empty() const;
137 
138  void reserve(size_t n);
139 
140  reference operator[] ( size_t n );
141 
142  const_reference operator[] ( size_t n ) const;
143 
144  reference at( size_t n );
145 
146  const_reference at( size_t n ) const;
147 
148  reference front ( );
149 
150  const_reference front ( ) const;
151 
152  reference back ( );
153 
154  const_reference back ( ) const;
155 
156  void assign ( size_t n, const Tp& u );
157 
158  void push_back ( const Tp& x );
159 
160  void pop_back ();
161 
162  void clear ( );
163 
164  void reset ( );
165 
166  // equals operator
167  bool operator==(const QueryableVector& vec) const;
168 
169  bool operator!=(const QueryableVector& vec) const;
170 
171  public:
172 
173  // access to persistent size
174  size_t persistentSize() const;
175 
176  const void* storageAddress() const;
177 
178  void load() const;
179 
180  private:
181 
182  void initialize() const;
183 
184  private:
185 
186  boost::shared_ptr<QueryableVectorData<Tp> > m_data;
188  mutable bool m_isLoaded;
189 
190 };
191 
192 }
193 
194 #include "QueryableVectorImpl.h"
195 
196 #endif
const_reverse_iterator rbegin() const
static const int endOfRange
Definition: Selection.h:18
const_iterator end() const
const_iterator begin() const
size_t persistentSize() const
void addSelection(const std::string &dataMemberName, SelectionItemType stype, Prim selectionData)
QueryableVector< Tp > & operator=(const QueryableVector< Tp > &rhs)
const Tp & const_reference
bool operator!=(const QueryableVector &vec) const
Range< Tp > select(int startIndex, int endIndex=Selection::endOfRange) const
ora::PVector< std::pair< size_t, Tp > >::store_type store_type
const void * storageAddress() const
reference operator[](size_t n)
CRIterator< Tp > const_reverse_iterator
void resize(size_t n, const Tp &value=Tp())
std::pair< size_t, Tp > store_item_type
virtual ~Range()
boost::shared_ptr< IVectorLoader > loader() const
std::vector< Tp >::value_type value_type
void assign(size_t n, const Tp &u)
Selection m_selection
Iterator< Tp > iterator
reverse_iterator rbegin()
QueryableVectorData< Tp >::store_base_type store_base_type
QueryableVectorData< Tp >::store_item_type store_item_type
size_t size() const
void push_back(const Tp &x)
CIterator< Tp > const_iterator
virtual ~Query()
const Tp & const_reference
Range & operator=(const Range &rhs)
Container::value_type value_type
CRIterator< Tp > const_reverse_iterator
boost::shared_ptr< QueryableVectorData< Tp > > m_data
size_t backIndex() const
reverse_iterator rend()
bool operator==(const QueryableVector &vec) const
size_t frontIndex() const
const_reverse_iterator rend() const
QueryableVectorData< Tp >::store_type store_type
Definition: DDAxes.h:10
Query(boost::shared_ptr< IVectorLoader > &loader)
Range< Tp > execute()
RIterator< Tp > reverse_iterator
CIterator< Tp > const_iterator
Query< Tp > query() const
reference at(size_t n)
boost::shared_ptr< QueryableVectorData< Tp > > m_data
SelectionItemType
Definition: Selection.h:13