CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
STLContainerHandler.cc
Go to the documentation of this file.
2 #include "STLContainerHandler.h"
3 #include "ClassUtils.h"
4 // externals
5 #include "RVersion.h"
6 
8  Reflex::CollFuncTable& collProxy,
9  const Reflex::Type& iteratorReturnType ):
10  m_returnType(iteratorReturnType),
11  m_collEnv(collEnv),
12  m_collProxy(collProxy),
13  m_currentElement(0){
14 
15  // retrieve the first element
16  m_currentElement = m_collProxy.first_func(&m_collEnv);
17 }
18 
20 
21 void
23  // this is required! It sets the number of memory slots (of size sizeof(Class)) to be used for the step
24  m_collEnv.fIdx = 1;
25  m_currentElement = m_collProxy.next_func(&m_collEnv);
26 }
27 
28 void*
30 {
31  return m_currentElement;
32 }
33 
34 
37 {
38  return m_returnType;
39 }
40 
42  m_type( dictionary ),
43  m_iteratorReturnType(),
44  m_isAssociative( false ),
45  m_collEnv(),
46  m_collProxy(){
48 
49  Reflex::Member method = m_type.MemberByName("createCollFuncTable");
50  if(method){
51  Reflex::CollFuncTable* collProxyPtr;
52  method.Invoke( collProxyPtr );
53  m_collProxy.reset( collProxyPtr );
54  }
55  if( !m_collProxy.get() ){
56  throwException( "Cannot find \"createCollFuncTable\" function for type \""+m_type.Name(Reflex::SCOPED)+"\"",
57  "STLContainerHandler::STLContainerHandler");
58  }
59 
60  // find the iterator return type as the member type_value of the containers
63 
64 }
65 
67 }
68 
69 size_t
70 ora::STLContainerHandler::size( const void* address ){
71  m_collEnv.fObject = const_cast<void*>(address);
72  return *(static_cast<size_t*>(m_collProxy->size_func(&m_collEnv)));
73 }
74 
75 
77 ora::STLContainerHandler::iterate( const void* address ){
78  if ( ! m_iteratorReturnType ) {
79  throwException( "Missing the dictionary information for the value_type member of the container \"" +
80  m_type.Name(Reflex::SCOPED|Reflex::FINAL) + "\"",
81  "STLContainerHandler::iterate" );
82  }
83  m_collEnv.fObject = const_cast<void*>(address);
84  return new STLContainerIteratorHandler( m_collEnv,*m_collProxy,m_iteratorReturnType );
85 }
86 
87 
88 void
90 #if ROOT_VERSION_CODE < ROOT_VERSION(5,28,0)
91  m_collEnv.fObject = address;
92  m_collEnv.fSize = 1;
93  m_collEnv.fStart = data;
94  m_collProxy->feed_func(&m_collEnv);
95 #else
96  m_collProxy->feed_func(data,address,1);
97 #endif
98 }
99 
100 void
101 ora::STLContainerHandler::clear( const void* address ){
102  m_collEnv.fObject = const_cast<void*>(address);
103  m_collProxy->clear_func(&m_collEnv);
104 }
105 
108  return m_iteratorReturnType;
109 }
110 
112  m_containerHandler(),
113  m_containerOffset( 0 )
114 {
115  // update dictionary to include base classes members
116  dictionary.UpdateMembers();
117  for ( unsigned int i=0;i<dictionary.DataMemberSize();i++){
118 
119  Reflex::Member field = dictionary.DataMemberAt(i);
120  Reflex::Type fieldType = field.TypeOf();
121  if ( ! fieldType ) {
122  throwException( "The dictionary of the underlying container of \"" +
123  dictionary.Name(Reflex::SCOPED|Reflex::FINAL) + "\" is not available",
124  "SpecialSTLContainerHandler" );
125  }
126  if ( ClassUtils::isTypeContainer(fieldType) ) {
127  m_containerHandler.reset( new STLContainerHandler( fieldType ) );
128  m_containerOffset = field.Offset();
129  break;
130  }
131  }
132  if ( !m_containerHandler.get() ) {
133  throwException( "Could not retrieve the underlying container of \"" +
134  dictionary.Name(Reflex::SCOPED|Reflex::FINAL) + "\" is not available",
135  "SpecialSTLContainerHandler" );
136  }
137 }
138 
139 
141 {
142 }
143 
144 
145 size_t
147 {
148  return m_containerHandler->size( static_cast< const char* >( address ) + m_containerOffset );
149 }
150 
151 
154 {
155  return m_containerHandler->iterate( static_cast< const char* >( address ) + m_containerOffset );
156 }
157 
158 
159 void
161 {
162  m_containerHandler->appendNewElement( static_cast< char* >( address ) + m_containerOffset, data );
163 }
164 
165 void
167 {
168  m_containerHandler->clear( static_cast< const char* >( address ) + m_containerOffset );
169 }
170 
173 {
174  return m_containerHandler->iteratorReturnType();
175 }
int i
Definition: DBlmapReader.cc:9
void appendNewElement(void *address, void *data)
Appends a new element and returns its address of the object reference.
STLContainerHandler(const Reflex::Type &dictionary)
Constructor.
Reflex::CollFuncTable & m_collProxy
Proxy of the generic collection.
IArrayIteratorHandler * iterate(const void *address)
Returns an initialized iterator.
Reflex::Type & iteratorReturnType()
Returns the iterator return type.
void * m_currentElement
Current element object pointer.
std::auto_ptr< IArrayHandler > m_containerHandler
The handler of the unserlying container.
Reflex::Type m_iteratorReturnType
The iterator return type.
SpecialSTLContainerHandler(const Reflex::Type &dictionary)
Constructor.
std::auto_ptr< Reflex::CollFuncTable > m_collProxy
Proxy of the generic collection.
Reflex::Environ< long > m_collEnv
Structure containing parameters of the collection instance.
bool isTypeContainer(const Reflex::Type &typ)
Definition: ClassUtils.cc:147
Reflex::Type containerValueType(const Reflex::Type &typ)
Definition: ClassUtils.cc:341
size_t size(const void *address)
Returns the size of the container.
Reflex::Type & iteratorReturnType()
Returns the iterator return type.
Reflex::Type resolvedType(const Reflex::Type &typ)
Definition: ClassUtils.cc:404
bool isTypeKeyedContainer(const Reflex::Type &typ)
Definition: ClassUtils.cc:173
Reflex::Type & returnType()
Returns the return type of the iterator dereference method.
int m_containerOffset
The offset of the underlying container.
Reflex::Type m_type
The dictionary information.
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
STLContainerIteratorHandler(const Reflex::Environ< long > &collEnv, Reflex::CollFuncTable &collProxy, const Reflex::Type &iteratorReturnType)
Constructor.
void increment()
Increments itself.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
IArrayIteratorHandler * iterate(const void *address)
Returns an initialized iterator.
void appendNewElement(void *address, void *data)
Appends a new element and returns its address of the object reference.
bool m_isAssociative
Flag indicating whether the container is associative.
volatile std::atomic< bool > shutdown_flag false
void clear(const void *address)
Clear the content of the container.
void clear(const void *address)
Clear the content of the container.
size_t size(const void *address)
Returns the size of the container.
void * object()
Returns the current object.