Archived issue #0013596
Using C++ Namespace with Handle types
Description
Currently it is impossible to define a Handle type inside a namespace.
The cause of the problem are the type declarations inside macros (file
Standard_DefineHandle.hxx):
class Standard_Transient;
class Standard_Persistent;
class Handle_Standard_Type;
class Handle_##C2;
These statements declare classes in the same namespace where the Handle class is
created, which is wrong.
The problem can be solved by avoiding the above declarations in the bodies of
macros, in file Standard_DefineHandle.hxx.
The cause of the problem are the type declarations inside macros (file
Standard_DefineHandle.hxx):
class Standard_Transient;
class Standard_Persistent;
class Handle_Standard_Type;
class Handle_##C2;
These statements declare classes in the same namespace where the Handle class is
created, which is wrong.
The problem can be solved by avoiding the above declarations in the bodies of
macros, in file Standard_DefineHandle.hxx.
Additional information
Documentation remark, added by Author 2007-02-15 12:32:01:
New features:
none
Improvements:
With this improvement it is possible to declare transient classes in namespaces:
========== in *.H ====================
#include <Standard_DefineHandle.hxx>
namespace Foo
{
class Bar : public Standard_Transient
{
...
public:
DEFINE_STANDARD_RTTI (Bar)
}; // end of class Bar
// Definition of HANDLE object using Standard_DefineHandle.hxx
DEFINE_STANDARD_HANDLE (Bar, Standard_Transient )
} // end of namespace Foo
========== in *.CPP ====================
namespace Foo {
IMPLEMENT_STANDARD_HANDLE (Bar, Standard_Transient)
IMPLEMENT_STANDARD_RTTIEXT(Bar, Standard_Transient)
}
...
Foo::Handle_Bar anObject = new Foo::Bar();
using namespace Foo;
Handle(Bar) aCopyObject = anObject;
Changes:
none
Modified entities:
Standard
New features:
none
Improvements:
With this improvement it is possible to declare transient classes in namespaces:
========== in *.H ====================
#include <Standard_DefineHandle.hxx>
namespace Foo
{
class Bar : public Standard_Transient
{
...
public:
DEFINE_STANDARD_RTTI (Bar)
}; // end of class Bar
// Definition of HANDLE object using Standard_DefineHandle.hxx
DEFINE_STANDARD_HANDLE (Bar, Standard_Transient )
} // end of namespace Foo
========== in *.CPP ====================
namespace Foo {
IMPLEMENT_STANDARD_HANDLE (Bar, Standard_Transient)
IMPLEMENT_STANDARD_RTTIEXT(Bar, Standard_Transient)
}
...
Foo::Handle_Bar anObject = new Foo::Bar();
using namespace Foo;
Handle(Bar) aCopyObject = anObject;
Changes:
none
Modified entities:
Standard
Public activity
No public notes
Participants are labeled by their role within this record.