test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PVectorHandler.cc
Go to the documentation of this file.
2 #include "PVectorHandler.h"
3 #include "ClassUtils.h"
4 // externals
5 #include "RVersion.h"
6 
7 ora::PVectorIteratorHandler::PVectorIteratorHandler( const Reflex::Environ<long>& collEnv,
8  Reflex::CollFuncTable& collProxy,
9  const Reflex::Type& iteratorReturnType,
10  size_t startElement):
11  m_returnType(iteratorReturnType),
12  m_collEnv(collEnv),
13  m_collProxy(collProxy),
14  m_currentElement(0),
15  m_startElement(startElement){
16  // retrieve the first element
17  m_currentElement = m_collProxy.first_func(&m_collEnv);
18 
19  if(startElement){
20  size_t i = 0;
21  while(i<startElement){
22  increment();
23  i++;
24  }
25  }
26 }
27 
29 }
30 
31 void
33  // this is requiredd! It sets the number of memory slots (of size sizeof(Class)) to be used for the step
34  m_collEnv.fIdx = 1;
35  m_currentElement = m_collProxy.next_func(&m_collEnv);
36 }
37 
38 void*
40  return m_currentElement;
41 }
42 
45  return m_returnType;
46 }
47 
49  m_type( dictionary ),
50  m_iteratorReturnType(),
51  m_isAssociative( false ),
52  m_collEnv(),
53  m_collProxy(),
54  m_persistentSizeAttributeOffset(0),
55  m_vecAttributeOffset(0)
56 {
57  Reflex::Member privateVectorAttribute = m_type.DataMemberByName("m_vec");
58  if(privateVectorAttribute){
59  m_vecAttributeOffset = privateVectorAttribute.Offset();
60  Reflex::Member method = privateVectorAttribute.TypeOf().MemberByName("createCollFuncTable");
61  if(method){
62  Reflex::CollFuncTable* collProxyPtr;
63  method.Invoke(collProxyPtr);
64  m_collProxy.reset( collProxyPtr );
65  }
66  if(! m_collProxy.get() ){
67  throwException( "Cannot find \"createCollFuncTable\" function for type \""+m_type.Name(Reflex::SCOPED)+"\"",
68  "PVectorHandler::PVectorHandler");
69  }
70  }
71 
72  Reflex::Member persistentSizeAttribute = m_type.DataMemberByName("m_persistentSize");
73  if( persistentSizeAttribute ){
74  m_persistentSizeAttributeOffset = persistentSizeAttribute.Offset();
75  }
76 
77  // find the iterator return type as the member type_value of the containers
80 }
81 
83 }
84 
85 size_t
86 ora::PVectorHandler::size( const void* address ){
87  m_collEnv.fObject = static_cast<char*>(const_cast<void*>(address))+m_vecAttributeOffset;
88  size_t transientSize = *(static_cast<size_t*>(m_collProxy->size_func(&m_collEnv)));
89  return transientSize;
90 }
91 
92 size_t
94  const void* persistentSizeAddress = static_cast<const char *>(address) + m_persistentSizeAttributeOffset;
95  size_t persistentSize = *static_cast<const size_t*>(persistentSizeAddress);
96  size_t transientSize = *(static_cast<size_t*>(m_collProxy->size_func(&m_collEnv)));
97  size_t startElement = 0;
98  if(persistentSize < transientSize) startElement = persistentSize;
99  return startElement;
100 }
101 
102 size_t* ora::PVectorHandler::persistentSize( const void* address ){
103  void* persistentSizeAddress = static_cast<char*>(const_cast<void*>(address))+m_persistentSizeAttributeOffset;
104  return static_cast<size_t*>(persistentSizeAddress);
105 }
106 
108 ora::PVectorHandler::iterate( const void* address ){
109  if ( ! m_iteratorReturnType ) {
110  throwException( "Missing the dictionary information for the value_type member of the container \"" +
111  m_type.Name(Reflex::SCOPED|Reflex::FINAL) + "\"",
112  "PVectorHandler" );
113  }
114  m_collEnv.fObject = static_cast<char*>(const_cast<void*>(address))+m_vecAttributeOffset;
115  return new PVectorIteratorHandler( m_collEnv,*m_collProxy,m_iteratorReturnType,startElementIndex(address) );
116 }
117 
118 void
120  void* dest_address = static_cast<char*>(address)+m_vecAttributeOffset;
121 #if ROOT_VERSION_CODE < ROOT_VERSION(5,28,0)
122  m_collEnv.fObject = dest_address;
123  m_collEnv.fSize = 1;
124  m_collEnv.fStart = data;
125  m_collProxy->feed_func(&m_collEnv);
126 #else
127  m_collProxy->feed_func(data,dest_address,1);
128 #endif
129 }
130 
131 void
132 ora::PVectorHandler::clear( const void* address ){
133  m_collEnv.fObject = static_cast<char*>(const_cast<void*>(address))+m_vecAttributeOffset;
134  m_collProxy->clear_func(&m_collEnv);
135 }
136 
139  return m_iteratorReturnType;
140 }
141 
142 void ora::PVectorHandler::finalize( void* address ){
143  size_t transSize = size( address );
144  void* persistentSizeAttributeAddress = static_cast<char*>(address)+m_persistentSizeAttributeOffset;
145  *static_cast<size_t*>(persistentSizeAttributeAddress) = transSize;
146 }
147 
148 
149 
150 
size_t m_persistentSizeAttributeOffset
int i
Definition: DBlmapReader.cc:9
Reflex::Type & iteratorReturnType()
Returns the iterator return type.
Reflex::Type m_type
The dictionary information.
PVectorIteratorHandler(const Reflex::Environ< long > &collEnv, Reflex::CollFuncTable &collProxy, const Reflex::Type &iteratorReturnType, size_t startElement)
Constructor.
size_t size(const void *address)
Returns the size of the container.
void finalize(void *address)
execute the ending procedure for the container
Reflex::Type m_iteratorReturnType
The iterator return type.
void appendNewElement(void *address, void *data)
Appends a new element and returns its address of the object reference.
Reflex::Environ< long > m_collEnv
Structure containing parameters of the collection instance.
Reflex::CollFuncTable & m_collProxy
Proxy of the generic collection.
virtual ~PVectorHandler()
Destructor.
void increment()
Increments itself.
Reflex::Type containerValueType(const Reflex::Type &typ)
Definition: ClassUtils.cc:341
size_t startElementIndex(const void *address)
Returns the index of the first element.
Reflex::Type resolvedType(const Reflex::Type &typ)
Definition: ClassUtils.cc:404
void * object()
Returns the current object.
std::auto_ptr< Reflex::CollFuncTable > m_collProxy
Proxy of the generic collection.
IArrayIteratorHandler * iterate(const void *address)
Returns an initialized iterator.
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
Reflex::Type & returnType()
Returns the return type of the iterator dereference method.
size_t * persistentSize(const void *address)
Returns the persistent size of the container.
volatile std::atomic< bool > shutdown_flag false
void * m_currentElement
Current element object pointer.
PVectorHandler(const Reflex::Type &dictionary)
Constructor.
tuple size
Write out results.
virtual ~PVectorIteratorHandler()
Destructor.
void clear(const void *address)
Clear the content of the container.