test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Container.cc
Go to the documentation of this file.
2 #include "DatabaseContainer.h"
3 #include "ClassUtils.h"
4 
6  m_buffer(){
7 }
8 
10  m_buffer( iteratorBuffer ){
11 }
12 
14  m_buffer( rhs.m_buffer ){
15 }
16 
18 }
19 
21  if(this != &rhs ) m_buffer = rhs.m_buffer;
22  return *this;
23 }
24 
26  m_buffer->reset();
27 }
28 
30  return m_buffer->next();
31 }
32 
34  return m_buffer->itemId();
35 }
36 
38  return Object( m_buffer->getItem(), m_buffer->type() );
39 }
40 
41 boost::shared_ptr<void> ora::ContainerIterator::getItemAsType( const std::type_info& asTypeInfo ){
42  Reflex::Type castType = ClassUtils::lookupDictionary( asTypeInfo );
43  void* ptr = m_buffer->getItemAsType( castType );
44  return boost::shared_ptr<void>( ptr, RflxDeleter( m_buffer->type() ) );
45 }
46 
48  m_dbContainer(){
49 }
50 
52  m_dbContainer( dbContainer ){
53 }
54 
56  m_dbContainer( rhs.m_dbContainer ){
57 }
58 
60 }
61 
63  if(this != &rhs ) m_dbContainer = rhs.m_dbContainer;
64  return *this;
65 }
66 
68  return m_dbContainer->id();
69 }
70 
72  return m_dbContainer->name();
73 }
74 
76  return m_dbContainer->className();
77 }
78 
81  std::string ret = ClassUtils::demangledName( type.TypeInfo() );
82  ret.erase( std::remove( ret.begin(), ret.end(), ' ' ), ret.end() );
83  return ret;
84 }
85 
87  return m_dbContainer->mappingVersion();
88 }
89 
91  return m_dbContainer->size();
92 }
93 
95  Handle<IteratorBuffer> buff = m_dbContainer->iteratorBuffer();
96  return ContainerIterator( buff );
97 }
98 
99 void ora::Container::extendSchema( const std::type_info& typeInfo ){
101  m_dbContainer->extendSchema( type );
102 }
103 
105  bool forWrite ){
106  m_dbContainer->setAccessPermission( principal, forWrite );
107 }
108 
110  return Object( m_dbContainer->fetchItem(itemId), m_dbContainer->type() );
111 }
112 
113 boost::shared_ptr<void> ora::Container::fetchItemAsType(int itemId,
114  const std::type_info& asTypeInfo){
115  Reflex::Type asType = ClassUtils::lookupDictionary( asTypeInfo );
116  void* ptr = m_dbContainer->fetchItemAsType(itemId, asType );
117  if(!ptr) return boost::shared_ptr<void>();
118  return boost::shared_ptr<void>( ptr, RflxDeleter( m_dbContainer->type() ) );
119 }
120 
122  return m_dbContainer->lock();
123 }
124 
126  return m_dbContainer->isLocked();
127 }
128 
130  const Reflex::Type& objType = data.type();
131  if(!objType){
132  throwException("Object class has not been found in the dictionary.",
133  "Container::insertItem");
134  }
135  return m_dbContainer->insertItem( data.address(), objType );
136 }
137 
139  const std::type_info& typeInfo ){
141  return m_dbContainer->insertItem( data, type );
142 }
143 
144 void ora::Container::updateItem( int itemId,
145  const Object& data ){
146  const Reflex::Type& objType = data.type();
147  if(!objType){
148  throwException("Object class has not been found in the dictionary.",
149  "Container::updateItem");
150  }
151  return m_dbContainer->updateItem( itemId, data.address(), objType );
152 }
153 
154 void ora::Container::updateItem( int itemId,
155  const void* data,
156  const std::type_info& typeInfo ){
158  m_dbContainer->updateItem( itemId, data, type );
159 }
160 
161 void ora::Container::erase( int itemId ){
162  m_dbContainer->erase(itemId );
163 }
164 
166  m_dbContainer->flush();
167 }
168 
170  int itemId ){
171  m_dbContainer->setItemName( name, itemId );
172 }
173 
174 bool ora::Container::getNames( std::vector<std::string>& destination ){
175  return m_dbContainer->getNames( destination );
176 }
177 
178 
type
Definition: HCALResponse.h:21
bool isLocked()
Definition: Container.cc:125
void updateItem(int itemId, const Object &data)
Definition: Container.cc:144
void * address() const
Definition: Object.cc:51
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
string destination
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
std::string demangledName(const std::type_info &typeInfo)
Definition: ClassUtils.cc:82
const std::string & mappingVersion()
Definition: Container.cc:86
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
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
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
const Reflex::Type & type() const
Definition: Object.cc:55
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
Handle< DatabaseContainer > m_dbContainer
Definition: Container.h:110
Reflex::Type lookupDictionary(const std::type_info &typeInfo, bool throwFlag=true)
Definition: ClassUtils.cc:93
ContainerIterator iterator()
Definition: Container.cc:94
ContainerIterator & operator=(const ContainerIterator &rhs)
Definition: Container.cc:20
std::string className(const T &t)
Definition: ClassName.h:30