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 
3 #include "ClassUtils.h"
4 #include "STLContainerHandler.h"
5 // externals
6 #include "RVersion.h"
8 
10  TVirtualCollectionProxy& collProxy,
11  const edm::TypeWithDict& iteratorReturnType ):
12  m_returnType(iteratorReturnType),
13  m_collProxy(collProxy),
14  m_currentElement(nullptr),
15  m_Iterators(TGenericCollectionIterator::New(address, &collProxy))
16 {
17  m_currentElement = m_Iterators->Next();
18 }
19 
21 
22 void
24  m_currentElement = m_Iterators->Next();
25 }
26 
27 void*
29 {
30  return m_currentElement;
31 }
32 
33 
36 {
37  return m_returnType;
38 }
39 
41  m_type( dictionary ),
42  m_iteratorReturnType(),
43  m_isAssociative( false ),
44  m_collProxy(){
46 
47  TClass* cl = dictionary.getClass();
48  m_collProxy = cl->GetCollectionProxy();
49  if( !m_collProxy ){
50  throwException( "Cannot create \"TVirtualCollectionProxy\" for type \""+m_type.cppName()+"\"",
51  "STLContainerHandler::STLContainerHandler");
52  }
53 
54  // find the iterator return type as the member type_value of the containers
57 
58 }
59 
61 }
62 
63 size_t
64 ora::STLContainerHandler::size( const void* address ){
65  //m_collEnv.fObject = const_cast<void*>(address);
66  //return *(static_cast<size_t*>(m_collProxy->size_func(&m_collEnv)));
67  TVirtualCollectionProxy::TPushPop helper(m_collProxy, const_cast<void*>(address));
68  return m_collProxy->Size();
69 }
70 
71 
73 ora::STLContainerHandler::iterate( const void* address ){
74  if ( ! m_iteratorReturnType ) {
75  throwException( "Missing the dictionary information for the value_type member of the container \"" +
76  m_type.cppName() + "\"",
77  "STLContainerHandler::iterate" );
78  }
79  void *addr = const_cast<void*>(address);
80  return new STLContainerIteratorHandler( addr,*m_collProxy,m_iteratorReturnType );
81 }
82 
83 
84 void
86  // m_collProxy->feed_func(data,address,1);
87  m_collProxy->Insert(data, address, 1);
88 }
89 
90 void
91 ora::STLContainerHandler::clear( const void* address ){
92  //m_collEnv.fObject = const_cast<void*>(address);
93  //m_collProxy->clear_func(&m_collEnv);
94  TVirtualCollectionProxy::TPushPop helper(m_collProxy, const_cast<void*>(address));
95  return m_collProxy->Clear();
96 }
97 
100  return m_iteratorReturnType;
101 }
102 
104  m_containerHandler(),
105  m_containerOffset( 0 )
106 {
107  // update dictionary to include base classes members
108  //-ap ignore for now: dictionary.UpdateMembers();
109  edm::TypeDataMembers members(dictionary);
110  for (auto const & member : members) {
111  edm::MemberWithDict field(member);
112  edm::TypeWithDict fieldType = field.typeOf();
113  if ( ! fieldType ) {
114  throwException( "The dictionary of the underlying container of \"" +
115  dictionary.cppName() + "\" is not available",
116  "SpecialSTLContainerHandler" );
117  }
118  if ( ClassUtils::isTypeContainer(fieldType) ) {
119  m_containerHandler.reset( new STLContainerHandler( fieldType ) );
120  m_containerOffset = field.offset();
121  break;
122  }
123  }
124  if ( !m_containerHandler.get() ) {
125  throwException( "Could not retrieve the underlying container of \"" +
126  dictionary.cppName() + "\" is not available",
127  "SpecialSTLContainerHandler" );
128  }
129 }
130 
131 
133 {
134 }
135 
136 
137 size_t
139 {
140  return m_containerHandler->size( static_cast< const char* >( address ) + m_containerOffset );
141 }
142 
143 
146 {
147  return m_containerHandler->iterate( static_cast< const char* >( address ) + m_containerOffset );
148 }
149 
150 
151 void
153 {
154  m_containerHandler->appendNewElement( static_cast< char* >( address ) + m_containerOffset, data );
155 }
156 
157 void
159 {
160  m_containerHandler->clear( static_cast< const char* >( address ) + m_containerOffset );
161 }
162 
165 {
166  return m_containerHandler->iteratorReturnType();
167 }
void appendNewElement(void *address, void *data)
Appends a new element and returns its address of the object reference.
edm::TypeWithDict resolvedType(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:486
edm::TypeWithDict & iteratorReturnType()
Returns the iterator return type.
bool isTypeKeyedContainer(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:250
edm::TypeWithDict m_type
The dictionary information.
size_t offset() const
TGenericCollectionIterator * m_Iterators
edm::TypeWithDict & returnType()
Returns the return type of the iterator dereference method.
#define nullptr
SpecialSTLContainerHandler(const edm::TypeWithDict &dictionary)
Constructor.
IArrayIteratorHandler * iterate(const void *address)
Returns an initialized iterator.
void * m_currentElement
Current element object pointer.
std::auto_ptr< IArrayHandler > m_containerHandler
The handler of the unserlying container.
TVirtualCollectionProxy * m_collProxy
Proxy of the generic collection.
TClass * getClass() const
std::string cppName() const
STLContainerIteratorHandler(void *address, TVirtualCollectionProxy &collProxy, const edm::TypeWithDict &iteratorReturnType)
Constructor.
TypeWithDict typeOf() const
STLContainerHandler(const edm::TypeWithDict &dictionary)
Constructor.
size_t size(const void *address)
Returns the size of the container.
int m_containerOffset
The offset of the underlying container.
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
void increment()
Increments itself.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
edm::TypeWithDict m_iteratorReturnType
The iterator return type.
IArrayIteratorHandler * iterate(const void *address)
Returns an initialized iterator.
edm::TypeWithDict containerValueType(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:410
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.
bool isTypeContainer(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:225
edm::TypeWithDict & iteratorReturnType()
Returns the iterator return type.
size_t size(const void *address)
Returns the size of the container.
void * object()
Returns the current object.