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 109 of file RootType.cxx.

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

◆ TMemberAdapter() [2/4]

TMemberAdapter::TMemberAdapter ( TFunction * func)

Definition at line 122 of file RootType.cxx.

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

◆ TMemberAdapter() [3/4]

TMemberAdapter::TMemberAdapter ( TDataMember * mb)

Definition at line 135 of file RootType.cxx.

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

◆ TMemberAdapter() [4/4]

TMemberAdapter::TMemberAdapter ( TMethodArg * ma)

Definition at line 148 of file RootType.cxx.

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

Member Function Documentation

◆ ATLAS_NOT_THREAD_SAFE() [1/2]

TTypeAdapter DeclaringType TMemberAdapter::ATLAS_NOT_THREAD_SAFE ( ) const

◆ ATLAS_NOT_THREAD_SAFE() [2/2]

TScopeAdapter DeclaringScope TMemberAdapter::ATLAS_NOT_THREAD_SAFE ( ) const

◆ FunctionParameterAt()

TMemberAdapter TMemberAdapter::FunctionParameterAt ( size_t nth)

Definition at line 284 of file RootType.cxx.

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

◆ FunctionParameterDefaultAt()

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

Definition at line 305 of file RootType.cxx.

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

◆ FunctionParameterNameAt()

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

Definition at line 292 of file RootType.cxx.

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

◆ FunctionParameterSize()

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

Definition at line 270 of file RootType.cxx.

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

◆ GetSharedLibs()

const char * TMemberAdapter::GetSharedLibs ( ) const

Definition at line 210 of file RootType.cxx.

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

◆ IsConstant()

Bool_t TMemberAdapter::IsConstant ( ) const

Definition at line 225 of file RootType.cxx.

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

◆ IsConstructor()

Bool_t TMemberAdapter::IsConstructor ( ) const

Definition at line 232 of file RootType.cxx.

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

◆ IsEnum()

Bool_t TMemberAdapter::IsEnum ( ) const

Definition at line 240 of file RootType.cxx.

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

◆ IsPublic()

Bool_t TMemberAdapter::IsPublic ( ) const

Definition at line 247 of file RootType.cxx.

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

◆ IsStatic()

Bool_t TMemberAdapter::IsStatic ( ) const

Definition at line 254 of file RootType.cxx.

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

◆ IsTransient()

Bool_t TMemberAdapter::IsTransient ( ) const

Definition at line 261 of file RootType.cxx.

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

◆ Name()

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

Definition at line 185 of file RootType.cxx.

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

◆ Offset()

size_t TMemberAdapter::Offset ( ) const

Definition at line 217 of file RootType.cxx.

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

◆ 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 141 of file RootType.cxx.

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

◆ operator TFunction *()

TMemberAdapter::operator TFunction * ( ) const

Definition at line 128 of file RootType.cxx.

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

◆ operator TMethod *()

TMemberAdapter::operator TMethod * ( ) const

Definition at line 115 of file RootType.cxx.

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

◆ operator TMethodArg *()

TMemberAdapter::operator TMethodArg * ( ) const

Definition at line 154 of file RootType.cxx.

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

◆ ReturnType()

TReturnTypeAdapter TMemberAdapter::ReturnType ( ) const

Definition at line 327 of file RootType.cxx.

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

◆ TypeOf()

TTypeAdapter TMemberAdapter::TypeOf ( ) const

Definition at line 161 of file RootType.cxx.

162{
163 // get the type of the data member
164 TDataMember* dataMember = (TDataMember*)*this;
165 if ( dataMember ) {
166 // MN: the only way to get the type is through the type name
167 TClass *tc = TClass::GetClass( dataMember->GetTypeName() );
168 if( tc ) {
169 return TTypeAdapter(tc);
170 } else {
171 return TTypeAdapter(dataMember->GetTypeName());
172 }
173 }
174
175 // get type of the function/method
176 TMethod* method = (TMethod*)*this;
177 if ( method )
178 return method->GetClass();
179
180 return TTypeAdapter();
181}
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: