ATLAS Offline Software
Loading...
Searching...
No Matches
TMemberAdapter Class Reference

#include <RootType.h>

Collaboration diagram for TMemberAdapter:

Public Member Functions

 TMemberAdapter (TMethod *meth)
 operator TMethod * () const
 TMemberAdapter (TFunction *func)
 operator TFunction * () const
 TMemberAdapter (TDataMember *mb)
 operator TDataMember * () const
 TMemberAdapter (TMethodArg *ma)
 operator TMethodArg * () const
 operator Bool_t () const
std::string Name (unsigned int mod=0) const
const char * GetSharedLibs () const
size_t Offset () const
Bool_t IsConstant () const
Bool_t IsConstructor () const
Bool_t IsEnum () const
Bool_t IsPublic () const
Bool_t IsStatic () const
Bool_t IsTransient () const
size_t FunctionParameterSize (Bool_t required=false) const
TMemberAdapter FunctionParameterAt (size_t nth)
std::string FunctionParameterNameAt (size_t nth)
std::string FunctionParameterDefaultAt (size_t nth)
TReturnTypeAdapter ReturnType () const
TScopeAdapter DeclaringScope ATLAS_NOT_THREAD_SAFE () const
TTypeAdapter DeclaringType ATLAS_NOT_THREAD_SAFE () const
TTypeAdapter TypeOf () const

Private Attributes

TDictionary * fMember

Detailed Description

Definition at line 60 of file RootType.h.

Constructor & Destructor Documentation

◆ TMemberAdapter() [1/4]

TMemberAdapter::TMemberAdapter ( TMethod * meth)

Definition at line 108 of file RootType.cxx.

108 : fMember( meth )
109{
110 /* empty */
111}
TDictionary * fMember
Definition RootType.h:100

◆ TMemberAdapter() [2/4]

TMemberAdapter::TMemberAdapter ( TFunction * func)

Definition at line 121 of file RootType.cxx.

121 : fMember( func )
122{
123 /* empty */
124}

◆ TMemberAdapter() [3/4]

TMemberAdapter::TMemberAdapter ( TDataMember * mb)

Definition at line 134 of file RootType.cxx.

134 : fMember( mb )
135{
136 /* empty */
137}

◆ TMemberAdapter() [4/4]

TMemberAdapter::TMemberAdapter ( TMethodArg * ma)

Definition at line 147 of file RootType.cxx.

147 : fMember( ma )
148{
149 /* empty */
150}

Member Function Documentation

◆ ATLAS_NOT_THREAD_SAFE() [1/2]

TScopeAdapter DeclaringScope TMemberAdapter::ATLAS_NOT_THREAD_SAFE ( ) const

◆ ATLAS_NOT_THREAD_SAFE() [2/2]

TTypeAdapter DeclaringType TMemberAdapter::ATLAS_NOT_THREAD_SAFE ( ) const

◆ FunctionParameterAt()

TMemberAdapter TMemberAdapter::FunctionParameterAt ( size_t nth)

Definition at line 286 of file RootType.cxx.

287{
288// get the type info of the function parameter at position nth
289 auto func = static_cast<TFunction*>(fMember);
290 return static_cast<TMethodArg*>(func->GetListOfMethodArgs()->At( nth ));
291}

◆ FunctionParameterDefaultAt()

std::string TMemberAdapter::FunctionParameterDefaultAt ( size_t nth)

Definition at line 307 of file RootType.cxx.

308{
309// get the default value, if available, of the function parameter at position nth
310 auto func = static_cast<TFunction*>(fMember);
311 TMethodArg* arg = static_cast<TMethodArg*>(func->GetListOfMethodArgs()->At( nth ));
312 const char* def = arg->GetDefault();
313
314 if ( ! def )
315 return "";
316
317// special case for strings: "some value" -> ""some value"
318 if ( strstr( ResolveTypedef( arg->GetTypeNormalizedName() ).c_str(), "char*" ) ) {
319 std::string sdef = "\"";
320 sdef += def;
321 sdef += "\"";
322 return sdef;
323 }
324
325 return def;
326}
static const std::string ResolveTypedef(const std::string &tname)
Definition RootType.cxx:32

◆ FunctionParameterNameAt()

std::string TMemberAdapter::FunctionParameterNameAt ( size_t nth)

Definition at line 294 of file RootType.cxx.

295{
296// get the formal name, if available, of the function parameter at position nth
297 auto func = static_cast<TFunction*>(fMember);
298 auto meth = static_cast<TMethodArg*>(func->GetListOfMethodArgs()->At( nth ));
299 const char* name = meth->GetName();
300
301 if ( name )
302 return name;
303 return "";
304}

◆ FunctionParameterSize()

size_t TMemberAdapter::FunctionParameterSize ( Bool_t required = false) const

Definition at line 272 of file RootType.cxx.

273{
274// get the total number of parameters that the adapted function/method takes
275 auto func = static_cast<const TFunction*>(fMember);
276 if ( ! func )
277 return 0;
278
279 if ( required == true )
280 return func->GetNargs() - func->GetNargsOpt();
281
282 return func->GetNargs();
283}

◆ GetSharedLibs()

const char * TMemberAdapter::GetSharedLibs ( ) const

Definition at line 212 of file RootType.cxx.

213{
214// return the shared libs corresponding to this classes (should be 'lib'?)
215 return gInterpreter->GetClassSharedLibs( Name().c_str() );
216}
JetDumper::Name Name
Definition JetDumper.cxx:19

◆ IsConstant()

Bool_t TMemberAdapter::IsConstant ( ) const

Definition at line 227 of file RootType.cxx.

228{
229// test if the adapted member is a const method
230 return fMember->Property() & kIsConstMethod;
231}

◆ IsConstructor()

Bool_t TMemberAdapter::IsConstructor ( ) const

Definition at line 234 of file RootType.cxx.

235{
236// test if the adapted member is a const method
237 auto func = static_cast<const TFunction*>(fMember);
238 return func ? (func->ExtraProperty() & kIsConstructor) : kFALSE;
239}

◆ IsEnum()

Bool_t TMemberAdapter::IsEnum ( ) const

Definition at line 242 of file RootType.cxx.

243{
244// test if the adapted member is of an enum type
245 return fMember->Property() & kIsEnum;
246}

◆ IsPublic()

Bool_t TMemberAdapter::IsPublic ( ) const

Definition at line 249 of file RootType.cxx.

250{
251// test if the adapted member represents an public (data) member
252 return fMember->Property() & kIsPublic;
253}

◆ IsStatic()

Bool_t TMemberAdapter::IsStatic ( ) const

Definition at line 256 of file RootType.cxx.

257{
258// test if the adapted member represents a class (data) member
259 return fMember->Property() & kIsStatic;
260}

◆ IsTransient()

Bool_t TMemberAdapter::IsTransient ( ) const

Definition at line 263 of file RootType.cxx.

264{
265// test if the adapted member represents transient data
266 TDataMember* dm = (TDataMember*)*this;
267 return dm ? ! dm->IsPersistent() : kTRUE;
268}

◆ Name()

std::string TMemberAdapter::Name ( unsigned int mod = 0) const

Definition at line 187 of file RootType.cxx.

188{
189// return name of the type described by fMember
190 TMethodArg* arg = (TMethodArg*)*this;
191
192 if ( arg ) {
193
194 std::string name = arg->GetTypeNormalizedName();
195 if ( mod & Reflex::FINAL )
196 name = ResolveTypedef( name );
197
198 if ( ! ( mod & Reflex::QUALIFIED ) )
199 name = UnqualifiedTypeName( name );
200
201 return name;
202
203 } else if ( mod & Reflex::FINAL )
204 return ResolveTypedef( fMember->GetName() );
205
206 if ( fMember )
207 return fMember->GetName();
208 return "<unknown>"; // happens for classes w/o dictionary
209}
static const std::string UnqualifiedTypeName(const std::string &name)
Definition RootType.cxx:55
@ FINAL
Definition RootType.h:25
@ QUALIFIED
Definition RootType.h:26

◆ Offset()

size_t TMemberAdapter::Offset ( ) const

Definition at line 219 of file RootType.cxx.

220{
221// relative offset (instance data) or global pointer (static/global data
222 TDataMember* dm = (TDataMember*)*this;
223 return dm ? dm->GetOffsetCint() : 0;
224}

◆ operator Bool_t()

TMemberAdapter::operator Bool_t ( ) const
inline

Definition at line 74 of file RootType.h.

74{ return fMember != 0; }

◆ operator TDataMember *()

TMemberAdapter::operator TDataMember * ( ) const

Definition at line 140 of file RootType.cxx.

141{
142// cast the adapter to a TDataMember* being adapted, returns 0 on failure
143 return dynamic_cast< TDataMember* >( const_cast< TDictionary* >( fMember ) );
144}

◆ operator TFunction *()

TMemberAdapter::operator TFunction * ( ) const

Definition at line 127 of file RootType.cxx.

128{
129// cast the adapter to a TFunction* being adapted, returns 0 on failure
130 return dynamic_cast< TFunction* >( const_cast< TDictionary* >( fMember ) );
131}

◆ operator TMethod *()

TMemberAdapter::operator TMethod * ( ) const

Definition at line 114 of file RootType.cxx.

115{
116// cast the adapter to a TMethod* being adapted, returns 0 on failure
117 return dynamic_cast< TMethod* >( const_cast< TDictionary* >( fMember ) );
118}

◆ operator TMethodArg *()

TMemberAdapter::operator TMethodArg * ( ) const

Definition at line 153 of file RootType.cxx.

154{
155// cast the adapter to a TMethodArg* being adapted, returns 0 on failure
156 return dynamic_cast< TMethodArg* >( const_cast< TDictionary* >( fMember ) );
157}

◆ ReturnType()

TReturnTypeAdapter TMemberAdapter::ReturnType ( ) const

Definition at line 329 of file RootType.cxx.

330{
331// get the return type of the wrapped function/method
332 auto func = static_cast<const TFunction*>(fMember);
333 return TReturnTypeAdapter( func->GetReturnTypeNormalizedName() );
334}

◆ TypeOf()

TTypeAdapter TMemberAdapter::TypeOf ( ) const

Definition at line 160 of file RootType.cxx.

161{
162 // get the type of the data member
163 TDataMember* dataMember = (TDataMember*)*this;
164 if ( dataMember ) {
165 // MN: the only way to get the type is through the type name
166 TClass *tc = TClass::GetClass( dataMember->GetTypeName() );
167 //cout << "--- TMemberAdapter name=" << Name() << endl;
168 if( tc ) {
169 //cout << " type = " << tc->GetName() << endl;
170 return TTypeAdapter(tc);
171 } else {
172 //cout << " typename = " << dataMember->GetTypeName() << endl;
173 return TTypeAdapter(dataMember->GetTypeName());
174 }
175 }
176
177 // get type of the function/method
178 TMethod* method = (TMethod*)*this;
179 if ( method )
180 return method->GetClass();
181
182 return TTypeAdapter();
183}
static Double_t tc
TScopeAdapter TTypeAdapter
Definition RootType.h:34

Member Data Documentation

◆ fMember

TDictionary* TMemberAdapter::fMember
private

Definition at line 100 of file RootType.h.


The documentation for this class was generated from the following files: