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.
4 #include "PVectorHandler.h"
5 #include "ClassUtils.h"
6 // externals
7 #include "RVersion.h"
8 #include <cassert>
9 #include <cstring>
10 
12  TVirtualCollectionProxy& collProxy,
13  const edm::TypeWithDict& iteratorReturnType,
14  size_t startElement):
15  m_returnType(iteratorReturnType),
16  m_collProxy(collProxy),
17  m_currentElement(0),
18  m_Iterators(TGenericCollectionIterator::New(address, &collProxy)),
19  m_startElement(startElement){
20 
21  m_currentElement = m_Iterators->Next();
22 
23  if(startElement){
24  size_t i = 0;
25  while(i<startElement){
26  increment();
27  i++;
28  }
29  }
30 }
31 
33 }
34 
35 void
37  m_currentElement = m_Iterators->Next();
38 }
39 
40 void*
42  return m_currentElement;
43 }
44 
47  return m_returnType;
48 }
49 
51  m_type( dictionary ),
52  m_iteratorReturnType(),
53  m_collProxy(),
54  m_persistentSizeAttributeOffset(0),
55  m_vecAttributeOffset(0)
56 {
57  edm::MemberWithDict privateVectorAttribute = m_type.dataMemberByName("m_vec");
58  if(privateVectorAttribute){
59  m_vecAttributeOffset = privateVectorAttribute.offset();
60  TClass* cl = privateVectorAttribute.typeOf().getClass();
61  m_collProxy = cl->GetCollectionProxy();
62  if( !m_collProxy ){
63  throwException( "Cannot create \"TVirtualCollectionProxy\" for type \""+m_type.cppName()+"\"",
64  "PVectorHandler::PVectorHandler");
65  }
66  }
67 
68  edm::MemberWithDict persistentSizeAttribute = m_type.dataMemberByName("m_persistentSize");
69  if( persistentSizeAttribute ){
70  m_persistentSizeAttributeOffset = persistentSizeAttribute.offset();
71  }
72 
73  // find the iterator return type as the member type_value of the containers
76 }
77 
79 }
80 
81 size_t
82 ora::PVectorHandler::size( const void* address ){
83  TVirtualCollectionProxy::TPushPop helper(m_collProxy, static_cast<char*>(const_cast<void*>(address))+m_vecAttributeOffset );
84  return m_collProxy->Size();
85 }
86 
87 size_t
89  const void* persistentSizeAddress = static_cast<const char *>(address) + m_persistentSizeAttributeOffset;
90  size_t persistentSize = *static_cast<const size_t*>(persistentSizeAddress);
91 
92  TVirtualCollectionProxy::TPushPop helper(m_collProxy, static_cast<char*>(const_cast<void*>(address))+m_vecAttributeOffset );
93  size_t transientSize = m_collProxy->Size();
94 
95  size_t startElement = 0;
96  if(persistentSize < transientSize) startElement = persistentSize;
97  return startElement;
98 }
99 
100 size_t* ora::PVectorHandler::persistentSize( const void* address ){
101  void* persistentSizeAddress = static_cast<char*>(const_cast<void*>(address))+m_persistentSizeAttributeOffset;
102  return static_cast<size_t*>(persistentSizeAddress);
103 }
104 
106 ora::PVectorHandler::iterate( const void* address ){
107  if ( ! m_iteratorReturnType ) {
108  throwException( "Missing the dictionary information for the value_type member of the container \"" +
109  m_type.cppName() + "\"",
110  "PVectorHandler" );
111  }
112  void *addr = static_cast<char*>(const_cast<void*>(address))+m_vecAttributeOffset;
113 
114  return new PVectorIteratorHandler( addr,*m_collProxy,m_iteratorReturnType,startElementIndex(address) );
115 }
116 
117 void
119 
120  void* addr = static_cast<char*>(const_cast<void*>(address))+m_vecAttributeOffset;
121  m_collProxy->Insert(data, addr, 1);
122 }
123 
124 void
125 ora::PVectorHandler::clear( const void* address ){
126  void* addr = static_cast<char*>(const_cast<void*>(address))+m_vecAttributeOffset;
127  TVirtualCollectionProxy::TPushPop helper(m_collProxy, const_cast<void*>(addr));
128  m_collProxy->Clear();
129 }
130 
133  return m_iteratorReturnType;
134 }
135 
136 void ora::PVectorHandler::finalize( void* address ){
137  size_t transSize = size( address );
138  void* persistentSizeAttributeAddress = static_cast<char*>(address)+m_persistentSizeAttributeOffset;
139  *static_cast<size_t*>(persistentSizeAttributeAddress) = transSize;
140 }
141 
142 
143 
144 
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.