diff --git a/reflex/inc/Reflex/internal/ScopeBase.h b/reflex/inc/Reflex/internal/ScopeBase.h index 475a93e6ebd0f2ace26635dc4312d398a64922a2..ccce51049c93da71358da58b85c376777391c215 100644 --- a/reflex/inc/Reflex/internal/ScopeBase.h +++ b/reflex/inc/Reflex/internal/ScopeBase.h @@ -1,4 +1,4 @@ -// @(#)root/reflex:$Name: $:$Id: ScopeBase.h,v 1.10 2006/09/14 14:39:12 roiser Exp $ +// @(#)root/reflex:$Name: $:$Id: ScopeBase.h,v 1.11 2006/10/30 12:51:33 roiser Exp $ // Author: Stefan Roiser 2004 // Copyright CERN, CH-1211 Geneva 23, 2004-2006, All rights reserved. @@ -335,6 +335,19 @@ namespace ROOT { virtual std::string Name( unsigned int mod = 0 ) const; + /** + * SimpleName returns the name of the type as a reference. It provides a + * simplified but faster generation of a type name. Attention currently it + * is not guaranteed that Name() and SimpleName() return the same character + * layout of a name (ie. spacing, commas, etc. ) + * @param pos will indicate where in the returned reference the requested name starts + * @param mod The only 'mod' support is SCOPED + * @return name of type + */ + virtual const std::string & SimpleName( size_t & pos, + unsigned int mod = 0 ) const; + + /** * Properties will return a pointer to the PropertyNth list attached * to this item diff --git a/reflex/inc/Reflex/internal/TypeBase.h b/reflex/inc/Reflex/internal/TypeBase.h index d67cd2b387fcf67060a72219ceebdf64a3b2496d..5a598ff2ffda87e7f6d56fe338a29c0af6031d62 100644 --- a/reflex/inc/Reflex/internal/TypeBase.h +++ b/reflex/inc/Reflex/internal/TypeBase.h @@ -1,4 +1,4 @@ -// @(#)root/reflex:$Name: $:$Id: TypeBase.h,v 1.7 2006/10/30 12:51:33 roiser Exp $ +// @(#)root/reflex:$Name: $:$Id: TypeBase.h,v 1.8 2006/11/24 13:21:14 roiser Exp $ // Author: Stefan Roiser 2004 // Copyright CERN, CH-1211 Geneva 23, 2004-2006, All rights reserved. @@ -428,11 +428,24 @@ namespace ROOT { /** - * Name returns the Name of the At - * @return Name of At + * Name returns the name of the type + * @return name of type */ virtual std::string Name( unsigned int mod = 0 ) const; + + /** + * SimpleName returns the name of the type as a reference. It provides a + * simplified but faster generation of a type name. Attention currently it + * is not guaranteed that Name() and SimpleName() return the same character + * layout of a name (ie. spacing, commas, etc. ) + * @param pos will indicate where in the returned reference the requested name starts + * @param mod The only 'mod' support is SCOPED + * @return name of type + */ + virtual const std::string & SimpleName( size_t & pos, + unsigned int mod = 0 ) const; + /** * FunctionParameterAt returns the nth FunctionParameterAt diff --git a/reflex/src/Class.h b/reflex/src/Class.h index 344844c494c6c0314d0f6e83cbb95d9c74bbc33a..af57905cd490db0db954b2a6d4ab778329052da5 100644 --- a/reflex/src/Class.h +++ b/reflex/src/Class.h @@ -1,4 +1,4 @@ -// @(#)root/reflex:$Name: $:$Id: Class.h,v 1.16 2006/09/05 17:13:15 roiser Exp $ +// @(#)root/reflex:$Name: $:$Id: Class.h,v 1.17 2006/10/30 12:51:33 roiser Exp $ // Author: Stefan Roiser 2004 // Copyright CERN, CH-1211 Geneva 23, 2004-2006, All rights reserved. @@ -332,6 +332,19 @@ namespace ROOT { virtual std::string Name( unsigned int mod = 0 ) const; + /** + * SimpleName returns the name of the type as a reference. It provides a + * simplified but faster generation of a type name. Attention currently it + * is not guaranteed that Name() and SimpleName() return the same character + * layout of a name (ie. spacing, commas, etc. ) + * @param pos will indicate where in the returned reference the requested name starts + * @param mod The only 'mod' support is SCOPED + * @return name of type + */ + virtual const std::string & SimpleName( size_t & pos, + unsigned int mod = 0 ) const; + + /** * PathToBase will return a vector of function pointers to the base class * ( !!! Attention !!! the most derived class comes first ) @@ -938,6 +951,14 @@ inline std::string ROOT::Reflex::Class::Name( unsigned int mod ) const { } +//------------------------------------------------------------------------------- +inline const std::string& ROOT::Reflex::Class::SimpleName( size_t & pos, + unsigned int mod ) const { +//------------------------------------------------------------------------------- + return ScopeBase::SimpleName( pos, mod ); +} + + //------------------------------------------------------------------------------- inline ROOT::Reflex::PropertyList ROOT::Reflex::Class::Properties() const { //------------------------------------------------------------------------------- diff --git a/reflex/src/ClassTemplateInstance.cxx b/reflex/src/ClassTemplateInstance.cxx index a4cd22e57e47bb448e3927f87793a41b1345ad21..1d9a01ceba0a2eb628281fab21059743fdcd5caf 100644 --- a/reflex/src/ClassTemplateInstance.cxx +++ b/reflex/src/ClassTemplateInstance.cxx @@ -1,4 +1,4 @@ -// @(#)root/reflex:$Name: $:$Id: ClassTemplateInstance.cxx,v 1.10 2006/08/11 06:31:59 roiser Exp $ +// @(#)root/reflex:$Name: $:$Id: ClassTemplateInstance.cxx,v 1.11 2006/10/30 12:51:33 roiser Exp $ // Author: Stefan Roiser 2004 // Copyright CERN, CH-1211 Geneva 23, 2004-2006, All rights reserved. @@ -79,6 +79,15 @@ std::string ROOT::Reflex::ClassTemplateInstance::Name( unsigned int mod ) const } +//------------------------------------------------------------------------------- +const std::string& ROOT::Reflex::ClassTemplateInstance::SimpleName( size_t & pos, + unsigned int mod ) const { +//------------------------------------------------------------------------------- +// Return the name of the template class. + return Class::SimpleName( pos, mod ); +} + + //------------------------------------------------------------------------------- ROOT::Reflex::Type ROOT::Reflex::ClassTemplateInstance::TemplateArgumentAt( size_t nth ) const { //------------------------------------------------------------------------------- diff --git a/reflex/src/ClassTemplateInstance.h b/reflex/src/ClassTemplateInstance.h index 2c302d36cc191fd3e35659ab96a998ae827c7666..17116d6bef99fa3ddd97d912ff1d06221d4fde56 100644 --- a/reflex/src/ClassTemplateInstance.h +++ b/reflex/src/ClassTemplateInstance.h @@ -1,4 +1,4 @@ -// @(#)root/reflex:$Name: $:$Id: ClassTemplateInstance.h,v 1.9 2006/09/05 17:13:15 roiser Exp $ +// @(#)root/reflex:$Name: $:$Id: ClassTemplateInstance.h,v 1.10 2006/10/30 12:51:33 roiser Exp $ // Author: Stefan Roiser 2004 // Copyright CERN, CH-1211 Geneva 23, 2004-2006, All rights reserved. @@ -52,6 +52,19 @@ namespace ROOT { std::string Name( unsigned int mod = 0 ) const; + /** + * SimpleName returns the name of the type as a reference. It provides a + * simplified but faster generation of a type name. Attention currently it + * is not guaranteed that Name() and SimpleName() return the same character + * layout of a name (ie. spacing, commas, etc. ) + * @param pos will indicate where in the returned reference the requested name starts + * @param mod The only 'mod' support is SCOPED + * @return name of type + */ + virtual const std::string & SimpleName( size_t & pos, + unsigned int mod = 0 ) const; + + /** * TemplateArgumentAt will return a pointer to the nth template argument * @param nth nth template argument diff --git a/reflex/src/NameLookup.cxx b/reflex/src/NameLookup.cxx index b10410f34a587d86d536865a5d2c899a94296432..40fa0e7572c2eba4f00d7ca3ec1e170d537aff63 100644 --- a/reflex/src/NameLookup.cxx +++ b/reflex/src/NameLookup.cxx @@ -1,4 +1,4 @@ -// @(#)root/reflex:$Name: $:$Id: NameLookup.cxx,v 1.13 2006/10/31 15:23:14 roiser Exp $ +// @(#)root/reflex:$Name: $:$Id: NameLookup.cxx,v 1.14 2006/11/09 08:01:04 roiser Exp $ // Author: Stefan Roiser 2006 // Copyright CERN, CH-1211 Geneva 23, 2004-2006, All rights reserved. @@ -113,35 +113,56 @@ ROOT::Reflex::NameLookup::LookupInScope() { // ns A { using ns B; } ns B {using ns A;} return Dummy::Get< T >(); - for ( Type_Iterator it = fCurrentScope.SubType_Begin(); it != fCurrentScope.SubType_End(); ++it ) { - if ( 0 == fLookupName.compare(fPosNamePart, fPosNamePartLen, (*it).Name() ) ) { - fPartialSuccess = true; - fLookedAtUsingDir.clear(); - FindNextScopePos(); - if (fPosNamePart == std::string::npos) return *it; - if (it->IsTypedef()) fCurrentScope = it->FinalType(); - else fCurrentScope = *it; - return LookupInScope< T >(); + //Type_Iterator subtype_end( fCurrentScope.SubType_End() ); + int len = fCurrentScope.SubTypeSize(); + int i = 0; + for ( Type_Iterator it = fCurrentScope.SubType_Begin(); /* it != subtype_end */ i<len; ++it, ++i ) { + const Type& type = *it; + const TypeBase *base = type.ToTypeBase(); + if ( base ) { + size_t pos; + const std::string &name( base->SimpleName(pos) ); + if (fLookupName[fPosNamePart]==name[pos] && + 0 == fLookupName.compare(fPosNamePart, fPosNamePartLen, name, pos, name.length() ) ) { + fPartialSuccess = true; + fLookedAtUsingDir.clear(); + FindNextScopePos(); + if (fPosNamePart == std::string::npos) return type; + if (it->IsTypedef()) fCurrentScope = it->FinalType(); + else fCurrentScope = type; + return LookupInScope< T >(); + } } } - - for ( Scope_Iterator in = fCurrentScope.SubScope_Begin(); in != fCurrentScope.SubScope_End(); ++in ) { + + Scope_Iterator subscope_end( fCurrentScope.SubScope_End() ); + for ( Scope_Iterator in = fCurrentScope.SubScope_Begin(); in != subscope_end; ++in ) { // only take namespaces into account - classes were checked as part of SubType - if (in->IsNamespace() && - 0 == fLookupName.compare(fPosNamePart, fPosNamePartLen, (*in).Name() ) ) { - fPartialSuccess = true; - fLookedAtUsingDir.clear(); - FindNextScopePos(); - if (fPosNamePart == std::string::npos) return (T) (*in); - fCurrentScope = (Scope) (*in); - return LookupInScope< T >(); + if (in->IsNamespace()){ + const Scope &scope = *in; + const ScopeBase *base = scope.ToScopeBase(); + if (base) { + size_t pos; + const std::string &name( base->SimpleName(pos) ); + + if (fLookupName[fPosNamePart]==name[pos] && + 0 == fLookupName.compare(fPosNamePart, fPosNamePartLen, name, pos, name.length() ) ) { + fPartialSuccess = true; + fLookedAtUsingDir.clear(); + FindNextScopePos(); + if (fPosNamePart == std::string::npos) return (T) (*in); + fCurrentScope = (Scope) (*in); + return LookupInScope< T >(); + } + } } } if (fCurrentScope.UsingDirectiveSize()) { fLookedAtUsingDir.insert(fCurrentScope); Scope storeCurrentScope = fCurrentScope; - for ( Scope_Iterator si = storeCurrentScope.UsingDirective_Begin(); si != storeCurrentScope.UsingDirective_End(); ++si ) { + Scope_Iterator usingscope_end( storeCurrentScope.UsingDirective_End() ); + for ( Scope_Iterator si = storeCurrentScope.UsingDirective_Begin(); si != usingscope_end; ++si ) { fCurrentScope = *si; T t = LookupInScope< T >(); if (fPartialSuccess) return t; @@ -149,8 +170,9 @@ ROOT::Reflex::NameLookup::LookupInScope() { fCurrentScope = storeCurrentScope; } - if (fPosNamePart == 0) // only for "BaseClass...", not for "A::BaseClass..." - for ( Base_Iterator bi = fCurrentScope.Base_Begin(); bi != fCurrentScope.Base_End(); ++bi ) { + if (fPosNamePart == 0) { // only for "BaseClass...", not for "A::BaseClass..." + Base_Iterator base_end( fCurrentScope.Base_End() ); + for ( Base_Iterator bi = fCurrentScope.Base_Begin(); bi != base_end; ++bi ) { if ( 0 == fLookupName.compare(fPosNamePart, fPosNamePartLen, (*bi).Name() ) ) { fPartialSuccess = true; fLookedAtUsingDir.clear(); @@ -160,10 +182,12 @@ ROOT::Reflex::NameLookup::LookupInScope() { return LookupInScope< T >(); } } + } if (fCurrentScope.BaseSize()) { Scope storeCurrentScope = fCurrentScope; - for ( Base_Iterator bi = storeCurrentScope.Base_Begin(); bi != storeCurrentScope.Base_End(); ++bi ) { + Base_Iterator base_end( storeCurrentScope.Base_End() ); + for ( Base_Iterator bi = storeCurrentScope.Base_Begin(); bi != base_end; ++bi ) { fCurrentScope = bi->ToScope(); T t = LookupInScope< T >(); if (fPartialSuccess) return t; diff --git a/reflex/src/ScopeBase.cxx b/reflex/src/ScopeBase.cxx index 18e3c5bf6fa0d33c1f7a883d1ab887696041fc8b..921f48c568ee72d2d775162a163c9a93c342390d 100644 --- a/reflex/src/ScopeBase.cxx +++ b/reflex/src/ScopeBase.cxx @@ -1,4 +1,4 @@ -// @(#)root/reflex:$Name: $:$Id: ScopeBase.cxx,v 1.31 2006/09/14 14:39:12 roiser Exp $ +// @(#)root/reflex:$Name: $:$Id: ScopeBase.cxx,v 1.32 2006/10/30 12:51:33 roiser Exp $ // Author: Stefan Roiser 2004 // Copyright CERN, CH-1211 Geneva 23, 2004-2006, All rights reserved. @@ -430,6 +430,20 @@ std::string ROOT::Reflex::ScopeBase::Name( unsigned int mod ) const { } +//------------------------------------------------------------------------------- +const std::string& ROOT::Reflex::ScopeBase::SimpleName( size_t & pos, + unsigned int mod ) const { +//------------------------------------------------------------------------------- + // Return name of this scope. + if ( 0 != ( mod & ( SCOPED | S ))) { + pos = 0; + return fScopeName->Name(); + } + pos = fBasePosition; + return fScopeName->Name(); +} + + //------------------------------------------------------------------------------- ROOT::Reflex::PropertyList ROOT::Reflex::ScopeBase::Properties() const { //------------------------------------------------------------------------------- diff --git a/reflex/src/Type.cxx b/reflex/src/Type.cxx index 82ffe27d1e44759faaa75f5584b035dc9501cbbc..8f8de7ce54919945ecc399d2da6059b44e745660 100644 --- a/reflex/src/Type.cxx +++ b/reflex/src/Type.cxx @@ -1,4 +1,4 @@ -// @(#)root/reflex:$Name: $:$Id: Type.cxx,v 1.22 2006/10/26 17:49:22 axel Exp $ +// @(#)root/reflex:$Name: $:$Id: Type.cxx,v 1.23 2006/10/30 12:51:33 roiser Exp $ // Author: Stefan Roiser 2004 // Copyright CERN, CH-1211 Geneva 23, 2004-2006, All rights reserved. @@ -264,6 +264,12 @@ ROOT::Reflex::MemberTemplate ROOT::Reflex::Type::MemberTemplateAt( size_t nth ) std::string ROOT::Reflex::Type::Name( unsigned int mod ) const { //------------------------------------------------------------------------------- // Return the name of the type (qualified and scoped if requested) + + if (( mod & ( QUALIFIED | Q ))==0 && (* this) ) { + // most common case + return fTypeName->fTypeBase->Name( mod ); + } + std::string s = ""; std::string cv = ""; diff --git a/reflex/src/TypeBase.cxx b/reflex/src/TypeBase.cxx index 0ee8f1616c55af8ee03d6073fe4232082064e648..74855bb4ea97202f7402ae46b7d052c1568bb60c 100644 --- a/reflex/src/TypeBase.cxx +++ b/reflex/src/TypeBase.cxx @@ -1,4 +1,4 @@ -// @(#)root/reflex:$Name: $:$Id: TypeBase.cxx,v 1.28 2006/10/31 16:46:37 roiser Exp $ +// @(#)root/reflex:$Name: $:$Id: TypeBase.cxx,v 1.29 2006/11/24 13:21:14 roiser Exp $ // Author: Stefan Roiser 2004 // Copyright CERN, CH-1211 Geneva 23, 2004-2006, All rights reserved. @@ -337,6 +337,20 @@ std::string ROOT::Reflex::TypeBase::Name( unsigned int mod ) const { } +//------------------------------------------------------------------------------- +const std::string & ROOT::Reflex::TypeBase::SimpleName( size_t & pos, + unsigned int mod ) const { +//------------------------------------------------------------------------------- +// Return the name of the type. + if ( 0 != ( mod & ( SCOPED | S ))) { + pos = 0; + return fTypeName->Name(); + } + pos = fBasePosition; + return fTypeName->Name(); +} + + //------------------------------------------------------------------------------- ROOT::Reflex::Type ROOT::Reflex::TypeBase::FunctionParameterAt( size_t /* nth */ ) const { //------------------------------------------------------------------------------- diff --git a/reflex/src/Typedef.h b/reflex/src/Typedef.h index 8ecd7bf1062fd9b61ab5cb6d197c5ad9b62c9e45..169ad004af91061ec82ae3cea79cd591b7148586 100644 --- a/reflex/src/Typedef.h +++ b/reflex/src/Typedef.h @@ -1,4 +1,4 @@ -// @(#)root/reflex:$Name: $:$Id: Typedef.h,v 1.16 2006/10/30 12:51:33 roiser Exp $ +// @(#)root/reflex:$Name: $:$Id: Typedef.h,v 1.17 2006/11/24 13:21:14 roiser Exp $ // Author: Stefan Roiser 2004 // Copyright CERN, CH-1211 Geneva 23, 2004-2006, All rights reserved. @@ -248,6 +248,19 @@ namespace ROOT { virtual std::string Name( unsigned int mod = 0 ) const; + /** + * SimpleName returns the name of the type as a reference. It provides a + * simplified but faster generation of a type name. Attention currently it + * is not guaranteed that Name() and SimpleName() return the same character + * layout of a name (ie. spacing, commas, etc. ) + * @param pos will indicate where in the returned reference the requested name starts + * @param mod The only 'mod' support is SCOPED + * @return name of type + */ + virtual const std::string & SimpleName( size_t & pos, + unsigned int mod = 0 ) const; + + virtual Type_Iterator FunctionParameter_Begin() const; virtual Type_Iterator FunctionParameter_End() const; virtual Reverse_Type_Iterator FunctionParameter_RBegin() const; @@ -749,6 +762,14 @@ inline std::string ROOT::Reflex::Typedef::Name( unsigned int mod ) const { } +//------------------------------------------------------------------------------- +inline const std::string& ROOT::Reflex::Typedef::SimpleName( size_t & pos, + unsigned int mod ) const { +//------------------------------------------------------------------------------- + return TypeBase::SimpleName( pos, mod ); +} + + //------------------------------------------------------------------------------- inline ROOT::Reflex::Scope ROOT::Reflex::Typedef::SubScopeAt( size_t nth ) const { //-------------------------------------------------------------------------------