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.
5 #include "PVectorHandler.h"
6 #include "ClassUtils.h"
7 // externals
8 #include "RVersion.h"
9 #include <cassert>
10 #include <cstring>
11 
13  TVirtualCollectionProxy& collProxy,
14  const edm::TypeWithDict& iteratorReturnType,
15  size_t startElement):
16  m_returnType(iteratorReturnType),
17  m_collProxy(collProxy),
18  m_currentElement(0),
19  m_Iterators(TGenericCollectionIterator::New(address, &collProxy)),
20  m_startElement(startElement){
21 
22  m_currentElement = m_Iterators->Next();
23 
24  if(startElement){
25  size_t i = 0;
26  while(i<startElement){
27  increment();
28  i++;
29  }
30  }
31 }
32 
34 }
35 
36 void
38  m_currentElement = m_Iterators->Next();
39 }
40 
41 void*
43  return m_currentElement;
44 }
45 
48  return m_returnType;
49 }
50 
52  m_type( dictionary ),
53  m_iteratorReturnType(),
54  m_collProxy(),
55  m_persistentSizeAttributeOffset(0),
56  m_vecAttributeOffset(0)
57 {
58  edm::MemberWithDict privateVectorAttribute = m_type.dataMemberByName("m_vec");
59  if(privateVectorAttribute){
60  m_vecAttributeOffset = privateVectorAttribute.offset();
61  TClass* cl = privateVectorAttribute.typeOf().getClass();
62  m_collProxy = cl->GetCollectionProxy();
63  if( !m_collProxy ){
64  throwException( "Cannot create \"TVirtualCollectionProxy\" for type \""+m_type.cppName()+"\"",
65  "PVectorHandler::PVectorHandler");
66  }
67  }
68 
69  edm::MemberWithDict persistentSizeAttribute = m_type.dataMemberByName("m_persistentSize");
70  if( persistentSizeAttribute ){
71  m_persistentSizeAttributeOffset = persistentSizeAttribute.offset();
72  }
73 
74  // find the iterator return type as the member type_value of the containers
77 }
78 
80 }
81 
82 size_t
83 ora::PVectorHandler::size( const void* address ){
84  TVirtualCollectionProxy::TPushPop helper(m_collProxy, static_cast<char*>(const_cast<void*>(address))+m_vecAttributeOffset );
85  return m_collProxy->Size();
86 }
87 
88 size_t
90  const void* persistentSizeAddress = static_cast<const char *>(address) + m_persistentSizeAttributeOffset;
91  size_t persistentSize = *static_cast<const size_t*>(persistentSizeAddress);
92 
93  TVirtualCollectionProxy::TPushPop helper(m_collProxy, static_cast<char*>(const_cast<void*>(address))+m_vecAttributeOffset );
94  size_t transientSize = m_collProxy->Size();
95 
96  size_t startElement = 0;
97  if(persistentSize < transientSize) startElement = persistentSize;
98  return startElement;
99 }
100 
101 size_t* ora::PVectorHandler::persistentSize( const void* address ){
102  void* persistentSizeAddress = static_cast<char*>(const_cast<void*>(address))+m_persistentSizeAttributeOffset;
103  return static_cast<size_t*>(persistentSizeAddress);
104 }
105 
107 ora::PVectorHandler::iterate( const void* address ){
108  if ( ! m_iteratorReturnType ) {
109  throwException( "Missing the dictionary information for the value_type member of the container \"" +
110  m_type.cppName() + "\"",
111  "PVectorHandler" );
112  }
113  void *addr = static_cast<char*>(const_cast<void*>(address))+m_vecAttributeOffset;
114 
115  return new PVectorIteratorHandler( addr,*m_collProxy,m_iteratorReturnType,startElementIndex(address) );
116 }
117 
118 void
120 
121  void* addr = static_cast<char*>(const_cast<void*>(address))+m_vecAttributeOffset;
122  m_collProxy->Insert(data, addr, 1);
123 }
124 
125 void
126 ora::PVectorHandler::clear( const void* address ){
127  void* addr = static_cast<char*>(const_cast<void*>(address))+m_vecAttributeOffset;
128  TVirtualCollectionProxy::TPushPop helper(m_collProxy, const_cast<void*>(addr));
129  m_collProxy->Clear();
130 }
131 
134  return m_iteratorReturnType;
135 }
136 
137 void ora::PVectorHandler::finalize( void* address ){
138  size_t transSize = size( address );
139  void* persistentSizeAttributeAddress = static_cast<char*>(address)+m_persistentSizeAttributeOffset;
140  *static_cast<size_t*>(persistentSizeAttributeAddress) = transSize;
141 }
142 
143 
144 
145 
size_t m_persistentSizeAttributeOffset
int i
Definition: DBlmapReader.cc:9
edm::TypeWithDict m_iteratorReturnType
The iterator return type.
edm::TypeWithDict resolvedType(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:486
PVectorHandler(const edm::TypeWithDict &dictionary)
Constructor.
edm::TypeWithDict m_type
The dictionary information.
size_t offset() const
edm::TypeWithDict & returnType()
Returns the return type of the iterator dereference method.
size_t size(const void *address)
Returns the size of the container.
void finalize(void *address)
execute the ending procedure for the container
MemberWithDict dataMemberByName(std::string const &) const
edm::TypeWithDict & iteratorReturnType()
Returns the iterator return type.
TClass * getClass() const
std::string cppName() const
void appendNewElement(void *address, void *data)
Appends a new element and returns its address of the object reference.
TypeWithDict typeOf() const
virtual ~PVectorHandler()
Destructor.
void increment()
Increments itself.
size_t startElementIndex(const void *address)
Returns the index of the first element.
void * object()
Returns the current object.
PVectorIteratorHandler(void *address, TVirtualCollectionProxy &collProxy, const edm::TypeWithDict &iteratorReturnType, size_t startElement)
Constructor.
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
TGenericCollectionIterator * m_Iterators
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
edm::TypeWithDict containerValueType(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:410
size_t * persistentSize(const void *address)
Returns the persistent size of the container.
TVirtualCollectionProxy * m_collProxy
Proxy of the generic collection.
void * m_currentElement
Current element object pointer.
tuple size
Write out results.
virtual ~PVectorIteratorHandler()
Destructor.
void clear(const void *address)
Clear the content of the container.