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 
71 const std::string& ora::Container::name(){
72  return m_dbContainer->name();
73 }
74 
75 const std::string& ora::Container::className(){
76  return m_dbContainer->className();
77 }
78 
79 const std::string& ora::Container::mappingVersion(){
80  return m_dbContainer->mappingVersion();
81 }
82 
84  return m_dbContainer->size();
85 }
86 
88  Handle<IteratorBuffer> buff = m_dbContainer->iteratorBuffer();
89  return ContainerIterator( buff );
90 }
91 
92 void ora::Container::extendSchema( const std::type_info& typeInfo ){
94  m_dbContainer->extendSchema( type );
95 }
96 
98  bool forWrite ){
99  m_dbContainer->setAccessPermission( principal, forWrite );
100 }
101 
103  return Object( m_dbContainer->fetchItem(itemId), m_dbContainer->type() );
104 }
105 
106 boost::shared_ptr<void> ora::Container::fetchItemAsType(int itemId,
107  const std::type_info& asTypeInfo){
108  Reflex::Type asType = ClassUtils::lookupDictionary( asTypeInfo );
109  void* ptr = m_dbContainer->fetchItemAsType(itemId, asType );
110  if(!ptr) return boost::shared_ptr<void>();
111  return boost::shared_ptr<void>( ptr, RflxDeleter( m_dbContainer->type() ) );
112 }
113 
115  return m_dbContainer->lock();
116 }
117 
119  return m_dbContainer->isLocked();
120 }
121 
123  const Reflex::Type& objType = data.type();
124  if(!objType){
125  throwException("Object class has not been found in the dictionary.",
126  "Container::insertItem");
127  }
128  return m_dbContainer->insertItem( data.address(), objType );
129 }
130 
132  const std::type_info& typeInfo ){
134  return m_dbContainer->insertItem( data, type );
135 }
136 
137 void ora::Container::updateItem( int itemId,
138  const Object& data ){
139  const Reflex::Type& objType = data.type();
140  if(!objType){
141  throwException("Object class has not been found in the dictionary.",
142  "Container::updateItem");
143  }
144  return m_dbContainer->updateItem( itemId, data.address(), objType );
145 }
146 
147 void ora::Container::updateItem( int itemId,
148  const void* data,
149  const std::type_info& typeInfo ){
151  m_dbContainer->updateItem( itemId, data, type );
152 }
153 
154 void ora::Container::erase( int itemId ){
155  m_dbContainer->erase(itemId );
156 }
157 
159  m_dbContainer->flush();
160 }
161 
162 void ora::Container::setItemName( const std::string& name,
163  int itemId ){
164  m_dbContainer->setItemName( name, itemId );
165 }
166 
167 bool ora::Container::getNames( std::vector<std::string>& destination ){
168  return m_dbContainer->getNames( destination );
169 }
170 
171 
type
Definition: HCALResponse.h:22
bool isLocked()
Definition: Container.cc:118
void updateItem(int itemId, const Object &data)
Definition: Container.cc:137
void * address() const
Definition: Object.cc:41
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
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
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
const Reflex::Type & type() const
Definition: Object.cc:45
size_t size()
Definition: Container.cc:83
Container & operator=(const Container &rhs)
Definition: Container.cc:62
void throwException(const std::string &message, const std::string &methodName)
Definition: Exception.cc:10
virtual ~ContainerIterator()
Definition: Container.cc:17
bool getNames(std::vector< std::string > &destination)
Definition: Container.cc:167
Handle< DatabaseContainer > m_dbContainer
Definition: Container.h:108
Reflex::Type lookupDictionary(const std::type_info &typeInfo, bool throwFlag=true)
Definition: ClassUtils.cc:93
ContainerIterator iterator()
Definition: Container.cc:87
ContainerIterator & operator=(const ContainerIterator &rhs)
Definition: Container.cc:20