test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
RelationalStreamerFactory.cc
Go to the documentation of this file.
3 #include "MappingElement.h"
4 #include "ClassUtils.h"
5 #include "PrimitiveStreamer.h"
6 #include "BlobStreamer.h"
7 #include "ObjectStreamer.h"
8 #include "STLContainerStreamer.h"
9 #include "CArrayStreamer.h"
10 #include "InlineCArrayStreamer.h"
11 #include "OraReferenceStreamer.h"
12 #include "NamedRefStreamer.h"
13 #include "OraPtrStreamer.h"
14 #include "PVectorStreamer.h"
16 #include "UniqueRefStreamer.h"
17 //
18 #include <memory>
19 
21  m_containerSchema( contSchema ){
22 }
23 
25 }
26 
28  MappingElement& mapping ){
29  IRelationalStreamer* newStreamer = 0;
30  if ( mapping.elementType() == MappingElement::Primitive ) { // Primitives
31  if( ! ClassUtils::isTypePrimitive( type ) ){
32  throwException( "Mapped variable \"" + mapping.variableName() +
33  "\", declared as Primitive, is associated to non-primitive type \""+type.name()+"\"",
34  "RelationalStreamerFactory::newStreamer" );
35  }
36  newStreamer = new PrimitiveStreamer( type, mapping );
37  } else if ( mapping.elementType() == MappingElement::Blob ){
38  newStreamer = new BlobStreamer( type, mapping, m_containerSchema );
39  } else if ( mapping.elementType() == MappingElement::Object ){
40  newStreamer = new ObjectStreamer( type, mapping, m_containerSchema );
41  } else if ( mapping.elementType() == MappingElement::Array ){
42  if ( !ClassUtils::isTypeContainer( type ) ) {
43  throwException( "Mapped variable \"" + mapping.variableName() +" of type "+
44  mapping.variableType() +
45  "\", declared as Array, is associated to the non-container type \""+
46  type.name()+"\".",
47  "RelationalStreamerFactory::newStreamer" );
48  }
49  newStreamer = new STLContainerStreamer( type, mapping, m_containerSchema );
50  } else if ( mapping.elementType() == MappingElement::CArray ) {
51  if ( ! type.isArray() ) {
52  throwException( "Mapped variable \"" + mapping.variableName() +" of type "+
53  mapping.variableType() +
54  "\", declared as C-Array, is associated to the non-array type \""+
55  type.name()+"\".",
56  "RelationalStreamerFactory::newStreamer" );
57  }
58  newStreamer = new CArrayStreamer( type, mapping, m_containerSchema );
59  } else if ( mapping.elementType() == MappingElement::InlineCArray ) {
60  if ( ! type.isArray() ) {
61  throwException( "Mapped variable \"" + mapping.variableName() +" of type "+
62  mapping.variableType() +
63  "\", declared as Inline C-Array, is associated to the non-array type \""+
64  type.name()+"\".",
65  "RelationalStreamerFactory::newStreamer" );
66  }
67  newStreamer = new InlineCArrayStreamer( type, mapping, m_containerSchema );
68  } else if ( mapping.elementType() == MappingElement::OraArray ) {
69  if ( ! ClassUtils::isTypeOraVector( type ) ) {
70  throwException( "Mapped variable \"" + mapping.variableName() +" of type "+
71  mapping.variableType() +
72  "\", declared as OraArray, is associated to the non-array type \""+
73  type.name()+"\".",
74  "RelationalStreamerFactory::newStreamer" );
75  }
76  if( ClassUtils::isTypePVector( type ) )
77  newStreamer = new PVectorStreamer( type, mapping, m_containerSchema );
78  else if ( ClassUtils::isTypeQueryableVector( type ))
79  newStreamer = new QueryableVectorStreamer( type, mapping, m_containerSchema );
80  } else if ( mapping.elementType() == MappingElement::OraPointer ) {
81  if ( ! ClassUtils::isTypeOraPointer( type )) {
82  throwException( "Mapped variable \"" + mapping.variableName() +" of type "+
83  mapping.variableType() +
84  "\", declared as a OraPointer, is associated to the type \""+
85  type.name()+"\".",
86  "RelationalStreamerFactory::newStreamer" );
87  }
88  newStreamer = new OraPtrStreamer( type, mapping, m_containerSchema );
89  } else if ( mapping.elementType() == MappingElement::OraReference ) {
90  if ( ! ClassUtils::isTypeOraReference( type )) {
91  throwException( "Mapped variable \"" + mapping.variableName() +" of type "+
92  mapping.variableType() +
93  "\", declared as a OraReference, is associated to the type \""+
94  type.name()+"\".",
95  "RelationalStreamerFactory::newStreamer" );
96  }
97  newStreamer = new OraReferenceStreamer( type, mapping, m_containerSchema );
98  } else if ( mapping.elementType() == MappingElement::NamedReference ) {
99  if ( ! ClassUtils::isTypeNamedReference( type )) {
100  throwException( "Mapped variable \"" + mapping.variableName() +" of type "+
101  mapping.variableType() +
102  "\", declared as a NamedReference, is associated to the type \""+
103  type.name()+"\".",
104  "RelationalStreamerFactory::newStreamer" );
105  }
106  newStreamer = new NamedRefStreamer( type, mapping, m_containerSchema );
107  } else if ( mapping.elementType() == MappingElement::UniqueReference ) {
108  if ( ! ClassUtils::isTypeUniqueReference( type )) {
109  throwException( "Mapped variable \"" + mapping.variableName() +" of type "+
110  mapping.variableType() +
111  "\", declared as a UniqueReference, is associated to the type \""+
112  type.name()+"\".",
113  "RelationalStreamerFactory::newStreamer" );
114  }
115  newStreamer = new UniqueRefStreamer( type, mapping, m_containerSchema );
116  } else {
117  throwException( "Cannot find a streamer suitable for mapped variable \"" + mapping.variableName() +" of type "+
118  mapping.variableType() +
119  "\".",
120  "RelationalStreamerFactory::newStreamer" );
121  }
122 
123  return newStreamer;
124 }
125 
126 
127 
129  MappingElement& mapping ){
130  std::auto_ptr<IRelationalStreamer> streamer( newStreamer( type, mapping ) );
131  return streamer->newWriter();
132 }
133 
135  MappingElement& mapping ){
136  std::auto_ptr<IRelationalStreamer> streamer( newStreamer( type, mapping ) );
137  return streamer->newUpdater();
138 }
139 
141  MappingElement& mapping ){
142  std::auto_ptr<IRelationalStreamer> streamer( newStreamer( type, mapping ) );
143  return streamer->newReader();
144 }
type
Definition: HCALResponse.h:21
RelationalStreamerFactory(ContainerSchema &contSchema)
const std::string & variableName() const
bool isTypeNamedReference(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:339
ElementType elementType() const
bool isTypePrimitive(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:221
bool isTypeOraPointer(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:323
bool isArray() const
std::string name() const
bool isTypePVector(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:355
bool isTypeUniqueReference(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:343
IRelationalWriter * newWriter(const edm::TypeWithDict &dataType, MappingElement &dataMapping)
bool isTypeOraVector(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:379
bool isTypeOraReference(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:335
IRelationalReader * newReader(const edm::TypeWithDict &dataType, MappingElement &dataMapping)
bool isTypeQueryableVector(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:367
const std::string & variableType() const
void throwException(const std::string &message, const std::string &methodName) __attribute__((noreturn))
Definition: Exception.cc:10
IRelationalUpdater * newUpdater(const edm::TypeWithDict &dataType, MappingElement &dataMapping)
bool isTypeContainer(const edm::TypeWithDict &typ)
Definition: ClassUtils.cc:225
IRelationalStreamer * newStreamer(const edm::TypeWithDict &dataType, MappingElement &dataMapping)