4 #include "boost/algorithm/string.hpp"
5 #include "boost/thread/tss.hpp"
7 #include "Reflex/Base.h"
8 #include "Reflex/Member.h"
9 #include "Reflex/TypeTemplate.h"
21 using Reflex::TypeTemplate;
22 using Reflex::Type_Iterator;
27 while (t.IsTypedef()) t = t.ToType();
33 Type const& type_to_search,
37 i = type_to_search.SubType_Begin(),
38 e = type_to_search.SubType_End();
41 if (
i->Name() == nested_type) {
52 TypeTemplate primary_template_id(possible_ref.TemplateFamily());
53 if (primary_template_id == TypeTemplate::ByName(
"edm::Ref", 3)) {
57 result = possible_ref;
65 TypeTemplate primary_template_id(possible_ref.TemplateFamily());
66 if (primary_template_id == TypeTemplate::ByName(
"edm::Ptr", 1)) {
70 result = possible_ref;
78 TypeTemplate primary_template_id(possible_ref.TemplateFamily());
79 if (primary_template_id == TypeTemplate::ByName(
"edm::RefToBase", 1)) {
83 result = possible_ref;
90 Type& found_sequence_value_type) {
91 Type possible_sequence;
96 Type outer_value_type;
102 found_sequence_value_type)) {
105 found_sequence_value_type)) {
108 found_sequence_value_type);
118 static TypeTemplate ref_vector_template_id(TypeTemplate::ByName(
"edm::RefVector", 3));
119 static std::string member_type(
"member_type");
120 TypeTemplate primary_template_id(possible_ref_vector.TemplateFamily());
121 if (primary_template_id == ref_vector_template_id) {
131 static TypeTemplate ref_vector_template_id(TypeTemplate::ByName(
"edm::PtrVector", 1));
132 static std::string member_type(
"member_type");
133 static std::string val_type(
"value_type");
134 TypeTemplate primary_template_id(possible_ref_vector.TemplateFamily());
135 if (primary_template_id == ref_vector_template_id) {
148 static TypeTemplate ref_vector_template_id(TypeTemplate::ByName(
"edm::RefToBaseVector", 1));
149 static std::string member_type(
"member_type");
150 TypeTemplate primary_template_id(possible_ref_vector.TemplateFamily());
151 if (primary_template_id == ref_vector_template_id) {
159 int const oneParamArraySize = 6;
160 std::string
const oneParam[oneParamArraySize] = {
168 int const twoParamArraySize = 3;
169 std::string
const twoParam[twoParamArraySize] = {
177 hasCintDictionary(std::string
const&
name) {
178 std::auto_ptr<G__ClassInfo> ci(
new G__ClassInfo(name.c_str()));
179 return (ci.get() && ci->IsLoaded());
190 static boost::thread_specific_ptr<StringSet> found_types;
191 if (0 == found_types.get()) {
200 for (
Type x = t.ToType();
x != null &&
x !=
t; t =
x,
x = t.ToType()) {}
202 std::string name = t.Name(SCOPED);
210 if (name.empty() || t.IsFundamental() || t.IsEnum()) {
211 found_types->insert(name);
216 if (hasCintDictionary(name)) {
217 found_types->insert(name);
224 found_types->insert(name);
225 if (noComponents)
return;
227 if (name.find(
"std::") == 0) {
228 if (t.IsTemplateInstance()) {
231 if (
std::find(oneParam, oneParam + oneParamArraySize, name.substr(5, n - 5)) != oneParam + oneParamArraySize) {
233 }
else if (
std::find(twoParam, twoParam + twoParamArraySize, name.substr(5, n - 5)) != twoParam + twoParamArraySize) {
236 for(
int i = 0;
i < cnt; ++
i) {
241 int mcnt = t.DataMemberSize();
242 for(
int i = 0;
i < mcnt; ++
i) {
243 Member
m = t.DataMemberAt(
i);
244 if(m.IsTransient() || m.IsStatic())
continue;
247 int cnt = t.BaseSize();
248 for(
int i = 0;
i < cnt; ++
i) {
256 static boost::thread_specific_ptr<StringSet> missingTypes_;
257 if (0 == missingTypes_.get()) {
260 return *missingTypes_.get();
265 Type t = Type::ByName(name);
270 checkType(Type::ByName(name), noComponents);
274 std::vector<Type>& baseTypes) {
276 if (type.IsClass() || type.IsStruct()) {
278 int nBase = type.BaseSize();
279 for (
int i = 0;
i < nBase; ++
i) {
282 if (base.IsPublic()) {
284 Type baseType = type.BaseAt(
i).ToType();
285 if (
bool(baseType)) {
287 while (baseType.IsTypedef() ==
true) {
288 baseType = baseType.ToType();
295 baseTypes.push_back(baseType);
326 Type const& dynamicType,
327 std::type_info
const& toType)
329 Object
obj(dynamicType, raw);
330 return obj.CastObject(Type::ByTypeInfo(toType)).Address();
bool if_edm_ref_get_value_type(Reflex::Type const &possible_ref, Reflex::Type &value_type)
void public_base_classes(const Reflex::Type &type, std::vector< Reflex::Type > &baseTypes)
bool is_RefToBaseVector(Reflex::Type const &possible_ref_vector, Reflex::Type &value_type)
bool is_sequence_wrapper(Reflex::Type const &possible_sequence_wrapper, Reflex::Type &found_sequence_value_type)
bool is_PtrVector(Reflex::Type const &possible_ref_vector, Reflex::Type &value_type)
bool value_type_of(Reflex::Type const &t, Reflex::Type &found_type)
void const * reflex_pointer_adjust(void *raw, Reflex::Type const &dynamicType, std::type_info const &toType)
Container::value_type value_type
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
tuple obj
Example code starts here #.
StringSet & missingTypes()
bool if_edm_ptr_get_value_type(Reflex::Type const &possible_ref, Reflex::Type &value_type)
bool wrapper_type_of(Reflex::Type const &possible_wrapper, Reflex::Type &found_wrapped_type)
std::set< std::string > StringSet
void checkDictionaries(std::string const &name, bool noComponents=false)
bool find_nested_type_named(std::string const &nested_type, Reflex::Type const &type_to_search, Reflex::Type &found_type)
bool if_edm_refToBase_get_value_type(Reflex::Type const &possible_ref, Reflex::Type &value_type)
bool search_all(ForwardSequence const &s, Datum const &d)
bool is_RefVector(Reflex::Type const &possible_ref_vector, Reflex::Type &value_type)
Type get_final_type(Type t)