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 
65 
66  const std::string& mappingVersion();
67 
68  size_t size();
69 
70  void extendSchema( const std::type_info& typeInfo );
71 
72  template <typename T> void extendSchema();
73 
74  void setAccessPermission( const std::string& principal, bool forWrite );
75 
77 
78  Object fetchItem( int itemId );
79 
80  template <typename T> boost::shared_ptr<T> fetch( int itemId );
81 
82  bool lock();
83 
84  bool isLocked();
85 
86  int insertItem( const Object& data );
87 
88  template <typename T> int insert( const T& data );
89 
90  void updateItem( int itemId, const Object& data );
91 
92  template <typename T> void update( int itemId, const T& data );
93 
94  void erase( int itemId );
95 
96  void flush();
97 
98  void setItemName( const std::string& name, int itemId );
99 
100  bool getNames( std::vector<std::string>& destination );
101 
102  private:
103  boost::shared_ptr<void> fetchItemAsType(int itemId, const std::type_info& asTypeInfo);
104  int insertItem( const void* data, const std::type_info& typeInfo );
105  void updateItem( int itemId, const void* data, const std::type_info& typeInfo );
106 
107 
108 
109  private:
111  };
112 
113 }
114 
115 template <typename T>
116 inline
117 boost::shared_ptr<T> ora::ContainerIterator::get(){
118  return boost::static_pointer_cast<T>( getItemAsType( typeid(T) ));
119 }
120 
121 template <typename T>
122 inline
124  extendSchema( typeid(T) );
125 }
126 
127 template <typename T>
128 inline
129 boost::shared_ptr<T> ora::Container::fetch( int itemId){
130  return boost::static_pointer_cast<T>( fetchItemAsType( itemId, typeid(T) ));
131 }
132 
133 template <typename T>
134 inline
136  return insertItem( &data, typeid( data ) );
137 }
138 
139 template <typename T>
140 inline
141 void ora::Container::update( int itemId, const T& data ){
142  return updateItem( itemId, &data, typeid( data ) );
143 }
144 
145 #endif
int insert(const T &data)
Definition: Container.h:135
bool isLocked()
Definition: Container.cc:125
void updateItem(int itemId, const Object &data)
Definition: Container.cc:144
Handle< IteratorBuffer > m_buffer
Definition: Container.h:42
const std::string & name()
Definition: Container.cc:71
int insertItem(const Object &data)
Definition: Container.cc:129
boost::shared_ptr< T > get()
Definition: Container.h:117
void setAccessPermission(const std::string &principal, bool forWrite)
Definition: Container.cc:104
Object fetchItem(int itemId)
Definition: Container.cc:109
virtual ~Container()
Definition: Container.cc:59
void setItemName(const std::string &name, int itemId)
Definition: Container.cc:169
const std::string & className()
Definition: Container.cc:75
const std::string & mappingVersion()
Definition: Container.cc:86
void update(int itemId, const T &data)
Definition: Container.h:141
boost::shared_ptr< void > fetchItemAsType(int itemId, const std::type_info &asTypeInfo)
Definition: Container.cc:113
void extendSchema()
Definition: Container.h:123
void erase(int itemId)
Definition: Container.cc:161
std::string realClassName()
Definition: Container.cc:79
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:129
size_t size()
Definition: Container.cc:90
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:174
long double T
Handle< DatabaseContainer > m_dbContainer
Definition: Container.h:110
ContainerIterator iterator()
Definition: Container.cc:94
ContainerIterator & operator=(const ContainerIterator &rhs)
Definition: Container.cc:20