CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Container.h
Go to the documentation of this file.
1 #ifndef INCLUDE_ORA_CONTAINER_H
2 #define INCLUDE_ORA_CONTAINER_H
3 
4 #include "Object.h"
5 #include "Handle.h"
6 //
7 #include <typeinfo>
8 #include <boost/shared_ptr.hpp>
9 
10 namespace ora {
11 
12  class IteratorBuffer;
13  class DatabaseContainer;
14 
16 
17  public:
19 
20  explicit ContainerIterator( Handle<IteratorBuffer>& iteratorBuffer );
21 
23 
24  virtual ~ContainerIterator();
25 
27 
28  Object getItem();
29 
30  template <typename T> boost::shared_ptr<T> get();
31 
32  int itemId();
33 
34  bool next();
35 
36  void reset();
37 
38  private:
39  boost::shared_ptr<void> getItemAsType( const std::type_info& asTypeInfo );
40 
41  private:
43  };
44 
45  class Container {
46 
47  public:
48  Container();
49 
50  explicit Container( Handle<DatabaseContainer>& dbContainer );
51 
52  Container( const Container& rhs );
53 
54  virtual ~Container();
55 
56  Container& operator=( const Container& rhs );
57 
58  int id();
59 
60  const std::string& name();
61 
62  const std::string& className();
63 
64  const std::string& mappingVersion();
65 
66  size_t size();
67 
68  void extendSchema( const std::type_info& typeInfo );
69 
70  template <typename T> void extendSchema();
71 
72  void setAccessPermission( const std::string& principal, bool forWrite );
73 
75 
76  Object fetchItem( int itemId );
77 
78  template <typename T> boost::shared_ptr<T> fetch( int itemId );
79 
80  bool lock();
81 
82  bool isLocked();
83 
84  int insertItem( const Object& data );
85 
86  template <typename T> int insert( const T& data );
87 
88  void updateItem( int itemId, const Object& data );
89 
90  template <typename T> void update( int itemId, const T& data );
91 
92  void erase( int itemId );
93 
94  void flush();
95 
96  void setItemName( const std::string& name, int itemId );
97 
98  bool getNames( std::vector<std::string>& destination );
99 
100  private:
101  boost::shared_ptr<void> fetchItemAsType(int itemId, const std::type_info& asTypeInfo);
102  int insertItem( const void* data, const std::type_info& typeInfo );
103  void updateItem( int itemId, const void* data, const std::type_info& typeInfo );
104 
105 
106 
107  private:
109  };
110 
111 }
112 
113 template <typename T>
114 inline
115 boost::shared_ptr<T> ora::ContainerIterator::get(){
116  return boost::static_pointer_cast<T>( getItemAsType( typeid(T) ));
117 }
118 
119 template <typename T>
120 inline
122  extendSchema( typeid(T) );
123 }
124 
125 template <typename T>
126 inline
127 boost::shared_ptr<T> ora::Container::fetch( int itemId){
128  return boost::static_pointer_cast<T>( fetchItemAsType( itemId, typeid(T) ));
129 }
130 
131 template <typename T>
132 inline
134  return insertItem( &data, typeid( data ) );
135 }
136 
137 template <typename T>
138 inline
139 void ora::Container::update( int itemId, const T& data ){
140  return updateItem( itemId, &data, typeid( data ) );
141 }
142 
143 #endif
int insert(const T &data)
Definition: Container.h:133
bool isLocked()
Definition: Container.cc:118
void updateItem(int itemId, const Object &data)
Definition: Container.cc:137
Handle< IteratorBuffer > m_buffer
Definition: Container.h:42
const std::string & name()
Definition: Container.cc:71
int insertItem(const Object &data)
Definition: Container.cc:122
boost::shared_ptr< T > get()
Definition: Container.h:115
void setAccessPermission(const std::string &principal, bool forWrite)
Definition: Container.cc:97
Object fetchItem(int itemId)
Definition: Container.cc:102
virtual ~Container()
Definition: Container.cc:59
void setItemName(const std::string &name, int itemId)
Definition: Container.cc:162
const std::string & className()
Definition: Container.cc:75
const std::string & mappingVersion()
Definition: Container.cc:79
void update(int itemId, const T &data)
Definition: Container.h:139
boost::shared_ptr< void > fetchItemAsType(int itemId, const std::type_info &asTypeInfo)
Definition: Container.cc:106
void extendSchema()
Definition: Container.h:121
void erase(int itemId)
Definition: Container.cc:154
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
boost::shared_ptr< void > getItemAsType(const std::type_info &asTypeInfo)
Definition: Container.cc:41
boost::shared_ptr< T > fetch(int itemId)
Definition: Container.h:127
size_t size()
Definition: Container.cc:83
Container & operator=(const Container &rhs)
Definition: Container.cc:62
virtual ~ContainerIterator()
Definition: Container.cc:17
bool getNames(std::vector< std::string > &destination)
Definition: Container.cc:167
long double T
Handle< DatabaseContainer > m_dbContainer
Definition: Container.h:108
ContainerIterator iterator()
Definition: Container.cc:87
ContainerIterator & operator=(const ContainerIterator &rhs)
Definition: Container.cc:20