1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-08-14 13:30:48 +03:00

Coding - Apply .clang-format formatting #286

Update empty method guards to new style with regex (see PR).
Used clang-format 18.1.8.
New actions to validate code formatting is added.
Update .clang-format with disabling of include sorting.
  It is temporary changes, then include will be sorted.
Apply formatting for /src and /tools folder.
The files with .hxx,.cxx,.lxx,.h,.pxx,.hpp,*.cpp extensions.
This commit is contained in:
dpasukhi
2025-01-25 20:15:22 +00:00
parent dbba6f1289
commit a5a7b3185b
14005 changed files with 1273539 additions and 1195567 deletions

View File

@@ -16,11 +16,11 @@
#include <QANCollection.hxx>
#include <Draw_Interpretor.hxx>
void QANCollection::Commands (Draw_Interpretor& theCommands)
void QANCollection::Commands(Draw_Interpretor& theCommands)
{
QANCollection::CommandsTest (theCommands);
QANCollection::CommandsPerf (theCommands);
QANCollection::CommandsAlloc (theCommands);
QANCollection::CommandsTest(theCommands);
QANCollection::CommandsPerf(theCommands);
QANCollection::CommandsAlloc(theCommands);
QANCollection::CommandsHandle(theCommands);
QANCollection::CommandsStl (theCommands);
QANCollection::CommandsStl(theCommands);
}

View File

@@ -22,33 +22,22 @@
#include <Draw_Interpretor.hxx>
class QANCollection
class QANCollection
{
public:
DEFINE_STANDARD_ALLOC
Standard_EXPORT static void Commands (Draw_Interpretor& DI);
Standard_EXPORT static void CommandsTest (Draw_Interpretor& DI);
Standard_EXPORT static void CommandsPerf (Draw_Interpretor& DI);
Standard_EXPORT static void CommandsAlloc (Draw_Interpretor& DI);
Standard_EXPORT static void CommandsStl (Draw_Interpretor& DI);
Standard_EXPORT static void Commands(Draw_Interpretor& DI);
Standard_EXPORT static void CommandsHandle (Draw_Interpretor& DI);
Standard_EXPORT static void CommandsTest(Draw_Interpretor& DI);
Standard_EXPORT static void CommandsPerf(Draw_Interpretor& DI);
Standard_EXPORT static void CommandsAlloc(Draw_Interpretor& DI);
Standard_EXPORT static void CommandsStl(Draw_Interpretor& DI);
Standard_EXPORT static void CommandsHandle(Draw_Interpretor& DI);
};
#endif // _QANCollection_HeaderFile

View File

@@ -23,108 +23,134 @@
#include <list>
#include <vector>
//=======================================================================
//function : QANColStdAllocator1
//purpose :
//=======================================================================
static Standard_Integer QANColStdAllocator1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
//=================================================================================================
static Standard_Integer QANColStdAllocator1(Draw_Interpretor& di,
Standard_Integer argc,
const char** argv)
{
if ( argc != 1) {
if (argc != 1)
{
di << "Usage : " << argv[0] << "\n";
return 1;
}
//type definitions
typedef Handle(Standard_Transient) elem_type;
// type definitions
typedef Handle(Standard_Transient) elem_type;
typedef NCollection_OccAllocator<elem_type> allocator_type;
Standard_STATIC_ASSERT (sizeof (allocator_type::value_type) == sizeof (elem_type));
Standard_STATIC_ASSERT (sizeof (allocator_type::pointer) == sizeof (void*));
Standard_STATIC_ASSERT (sizeof (allocator_type::const_pointer) == sizeof (void*));
Standard_STATIC_ASSERT(sizeof(allocator_type::value_type) == sizeof(elem_type));
Standard_STATIC_ASSERT(sizeof(allocator_type::pointer) == sizeof(void*));
Standard_STATIC_ASSERT(sizeof(allocator_type::const_pointer) == sizeof(void*));
elem_type aDummy;
elem_type aDummy;
allocator_type::reference aRef = aDummy;
(void)aRef; // avoid compiler warning on unused
allocator_type::const_reference aConstRef = aDummy;
(void)aConstRef; // avoid compiler warning on unused
Standard_STATIC_ASSERT (sizeof (allocator_type::size_type) == sizeof (size_t));
Standard_STATIC_ASSERT (sizeof (allocator_type::difference_type) == sizeof (ptrdiff_t));
Standard_STATIC_ASSERT(sizeof(allocator_type::size_type) == sizeof(size_t));
Standard_STATIC_ASSERT(sizeof(allocator_type::difference_type) == sizeof(ptrdiff_t));
typedef int other_elem_type;
Standard_STATIC_ASSERT (sizeof (allocator_type::rebind<other_elem_type>::other::value_type) == sizeof (other_elem_type));
Standard_STATIC_ASSERT(sizeof(allocator_type::rebind<other_elem_type>::other::value_type)
== sizeof(other_elem_type));
return 0;
}
//=======================================================================
//function : QANColStdAllocator2
//purpose :
//=======================================================================
static Standard_Integer QANColStdAllocator2(Draw_Interpretor& di, Standard_Integer argc, const char ** argv)
//=================================================================================================
static Standard_Integer QANColStdAllocator2(Draw_Interpretor& di,
Standard_Integer argc,
const char** argv)
{
if ( argc != 1) {
if (argc != 1)
{
di << "Usage : " << argv[0] << "\n";
return 1;
}
//create incremental allocator outside the scope of objects it will manage
// create incremental allocator outside the scope of objects it will manage
Handle(NCollection_IncAllocator) anIncAlloc = new NCollection_IncAllocator();
{
//typed allocator
NCollection_OccAllocator<int> aSAlloc (anIncAlloc);
std::list<int, NCollection_OccAllocator<int> > aL (aSAlloc);
aL.push_back (2);
if ( aL.size() == size_t (1) ) {
// typed allocator
NCollection_OccAllocator<int> aSAlloc(anIncAlloc);
std::list<int, NCollection_OccAllocator<int>> aL(aSAlloc);
aL.push_back(2);
if (aL.size() == size_t(1))
{
di << "Test1 : OK\n";
} else {
}
else
{
di << "Test1 : Error\n";
}
//type cast
NCollection_OccAllocator<char> aCAlloc;
std::vector<int, NCollection_OccAllocator<int> > aV (aCAlloc);
aV.push_back (1);
if ( aV.size() == size_t (1) ) {
// type cast
NCollection_OccAllocator<char> aCAlloc;
std::vector<int, NCollection_OccAllocator<int>> aV(aCAlloc);
aV.push_back(1);
if (aV.size() == size_t(1))
{
di << "Test2 : OK\n";
} else {
}
else
{
di << "Test2 : Error\n";
}
//using void-specialization allocator
NCollection_OccAllocator<void*> aVAlloc;
std::vector<int, NCollection_OccAllocator<int> > aV2 (aVAlloc);
// using void-specialization allocator
NCollection_OccAllocator<void*> aVAlloc;
std::vector<int, NCollection_OccAllocator<int>> aV2(aVAlloc);
aV2.resize (10);
aV2.push_back (-1);
if ( aV2.size() == size_t (11) ) {
aV2.resize(10);
aV2.push_back(-1);
if (aV2.size() == size_t(11))
{
di << "Test3 : OK\n";
} else {
}
else
{
di << "Test3 : Error\n";
}
//equality of allocators
if ( aSAlloc != aCAlloc ) {
// equality of allocators
if (aSAlloc != aCAlloc)
{
di << "Test4 : OK\n";
} else {
}
else
{
di << "Test4 : Error\n";
}
NCollection_OccAllocator<int> anIAlloc (anIncAlloc);
if ( aSAlloc == anIAlloc ) {
NCollection_OccAllocator<int> anIAlloc(anIncAlloc);
if (aSAlloc == anIAlloc)
{
di << "Test5 : OK\n";
} else {
}
else
{
di << "Test5 : Error\n";
}
}
return 0;
}
void QANCollection::CommandsAlloc(Draw_Interpretor& theCommands) {
const char *group = "QANCollection";
void QANCollection::CommandsAlloc(Draw_Interpretor& theCommands)
{
const char* group = "QANCollection";
theCommands.Add("QANColStdAllocator1", "QANColStdAllocator1", __FILE__, QANColStdAllocator1, group);
theCommands.Add("QANColStdAllocator2", "QANColStdAllocator2", __FILE__, QANColStdAllocator2, group);
theCommands.Add("QANColStdAllocator1",
"QANColStdAllocator1",
__FILE__,
QANColStdAllocator1,
group);
theCommands.Add("QANColStdAllocator2",
"QANColStdAllocator2",
__FILE__,
QANColStdAllocator2,
group);
return;
}

View File

@@ -20,37 +20,36 @@
void PrintItem(const gp_Pnt& thePnt)
{
printf (" (%5.1f %5.1f %5.1f)\n", thePnt.X(), thePnt.Y(), thePnt.Z());
printf(" (%5.1f %5.1f %5.1f)\n", thePnt.X(), thePnt.Y(), thePnt.Z());
}
void PrintItem(const Standard_Real theDbl)
{
printf (" (%5.1f)\n", theDbl);
printf(" (%5.1f)\n", theDbl);
}
void Random (Standard_Real& theValue)
void Random(Standard_Real& theValue)
{
static Standard_Real dfV=0.14159265358979323846;
static Standard_Real dfV = 0.14159265358979323846;
dfV *= 37.;
dfV -= Floor(dfV);
theValue = dfV;
//theValue=drand48();
// theValue=drand48();
}
void Random (Standard_Integer& theValue,
const Standard_Integer theMax)
void Random(Standard_Integer& theValue, const Standard_Integer theMax)
{
Standard_Real dfR;
Random(dfR);
theValue = RealToInt(theMax*dfR);
theValue = RealToInt(theMax * dfR);
}
void Random (gp_Pnt& thePnt)
void Random(gp_Pnt& thePnt)
{
// thePnt.SetCoord(drand48(),drand48(),drand48());
Standard_Real dfX, dfY, dfZ;
Random(dfX);
Random(dfY);
Random(dfZ);
thePnt.SetCoord(dfX,dfY,dfZ);
thePnt.SetCoord(dfX, dfY, dfZ);
}

View File

@@ -22,14 +22,13 @@
// To print other type of items define PrintItem for it
Standard_EXPORT void PrintItem(const gp_Pnt& thePnt);
Standard_EXPORT void PrintItem(const gp_Pnt& thePnt);
Standard_EXPORT void PrintItem(const Standard_Real theDbl);
// So do for the pseudo-random generation
Standard_EXPORT void Random (Standard_Real& theValue);
Standard_EXPORT void Random (Standard_Integer& theValue,
const Standard_Integer theMax=RAND_MAX);
Standard_EXPORT void Random (gp_Pnt& thePnt);
Standard_EXPORT void Random(Standard_Real& theValue);
Standard_EXPORT void Random(Standard_Integer& theValue, const Standard_Integer theMax = RAND_MAX);
Standard_EXPORT void Random(gp_Pnt& thePnt);
#endif

View File

@@ -11,7 +11,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef QANCollection_DataMapIteratorOfDataMapOfRealPnt_HeaderFile
#define QANCollection_DataMapIteratorOfDataMapOfRealPnt_HeaderFile

View File

@@ -19,8 +19,8 @@
#include <gp_Pnt.hxx>
#include <NCollection_DataMap.hxx>
typedef NCollection_DataMap<Standard_Real,gp_Pnt> QANCollection_DataMapOfRealPnt;
typedef NCollection_DataMap<Standard_Real,gp_Pnt>::Iterator QANCollection_DataMapIteratorOfDataMapOfRealPnt;
typedef NCollection_DataMap<Standard_Real, gp_Pnt> QANCollection_DataMapOfRealPnt;
typedef NCollection_DataMap<Standard_Real, gp_Pnt>::Iterator
QANCollection_DataMapIteratorOfDataMapOfRealPnt;
#endif

View File

@@ -11,7 +11,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef QANCollection_DoubleMapIteratorOfDoubleMapOfRealInteger_HeaderFile
#define QANCollection_DoubleMapIteratorOfDoubleMapOfRealInteger_HeaderFile

View File

@@ -19,8 +19,8 @@
#include <Standard_Integer.hxx>
#include <NCollection_DoubleMap.hxx>
typedef NCollection_DoubleMap<Standard_Real,Standard_Integer> QANCollection_DoubleMapOfRealInteger;
typedef NCollection_DoubleMap<Standard_Real,Standard_Integer>::Iterator QANCollection_DoubleMapIteratorOfDoubleMapOfRealInteger;
typedef NCollection_DoubleMap<Standard_Real, Standard_Integer> QANCollection_DoubleMapOfRealInteger;
typedef NCollection_DoubleMap<Standard_Real, Standard_Integer>::Iterator
QANCollection_DoubleMapIteratorOfDoubleMapOfRealInteger;
#endif

View File

@@ -36,128 +36,139 @@
// evaluated before calls to stream output functions, to
// prevent side effects from such calls in cases when condition
// may contain references to freed objects in the stack.
#define CHECK(di,ok,what) \
if (ok) di << "Checking " << what << ": OK\n";\
else di << "Checking " << what << ": Error\n"
#define CHECK(di, ok, what) \
if (ok) \
di << "Checking " << what << ": OK\n"; \
else \
di << "Checking " << what << ": Error\n"
//=======================================================================
//function : QAHandleOps
//purpose : Test Handle operations (mostly compile-time checks)
// function : QAHandleOps
// purpose : Test Handle operations (mostly compile-time checks)
//=======================================================================
// set of overloaded functions for checking resolution of arguments
inline void f (const Handle(Geom_Curve)&) {}
inline void func (const Handle(Geom_Curve)&) {}
inline void func (const Handle(Geom_BSplineCurve)&) {}
inline void func (const Handle(Geom_Surface)&) {}
inline void func (const Handle(gp_Pnt)&) {}
inline void func (const Handle(gp_XYZ)&) {}
inline void func (const Handle(gp_Trsf)&) {}
inline void f(const Handle(Geom_Curve)&) {}
static Standard_Integer QAHandleOps (Draw_Interpretor& theDI,
Standard_Integer /*theArgNb*/,
const char** /*theArgVec*/)
inline void func(const Handle(Geom_Curve)&) {}
inline void func(const Handle(Geom_BSplineCurve)&) {}
inline void func(const Handle(Geom_Surface)&) {}
inline void func(const Handle(gp_Pnt)&) {}
inline void func(const Handle(gp_XYZ)&) {}
inline void func(const Handle(gp_Trsf)&) {}
static Standard_Integer QAHandleOps(Draw_Interpretor& theDI,
Standard_Integer /*theArgNb*/,
const char** /*theArgVec*/)
{
// ===============================================================
// Part 1: classes inheriting transient
// ===============================================================
Handle(Geom_Line) aLine = new Geom_Line (gp::Origin(), gp::DZ());
CHECK(theDI, ! aLine.IsNull(), "handle for non-null");
Handle(Geom_Line) aLine = new Geom_Line(gp::Origin(), gp::DZ());
CHECK(theDI, !aLine.IsNull(), "handle for non-null");
const Handle(Geom_Line)& cLine = aLine; // cast to self const ref
const Handle(Geom_Line)& cLine = aLine; // cast to self const ref
const Handle(Geom_Curve)& cCurve = aLine; // cast to base const ref
Geom_Line* pLine = aLine.get();
const Geom_Line* cpLine = aLine.get();
Geom_Line& rLine = *aLine;
const Geom_Line& crLine = *cLine;
Handle(Geom_Curve) aCurve = aLine; // copy from handle to derived type
aCurve = cLine; // assignment to handle of derived type
Handle(Geom_Line) dLine (cpLine); // copy from handle to derived type
Geom_Line* pLine = aLine.get();
const Geom_Line* cpLine = aLine.get();
Geom_Line& rLine = *aLine;
const Geom_Line& crLine = *cLine;
Handle(Geom_Curve) aCurve = aLine; // copy from handle to derived type
aCurve = cLine; // assignment to handle of derived type
Handle(Geom_Line) dLine(cpLine); // copy from handle to derived type
aLine = Handle(Geom_Line)::DownCast (cCurve);
CHECK(theDI, ! aLine.IsNull(), "down cast");
aLine = Handle(Geom_Line)::DownCast(cCurve);
CHECK(theDI, !aLine.IsNull(), "down cast");
// comparison operators
CHECK(theDI, aLine == aLine, "equality of handle to itself");
CHECK(theDI, cLine == cLine, "equality of const handle to itself");
CHECK(theDI, aLine == cLine, "equality of const and non-const handle");
CHECK(theDI, aLine == cCurve, "equality of handle and base handle");
CHECK(theDI, aLine == pLine, "equality of handle and pointer");
CHECK(theDI, pLine == aLine, "equality of pointer and handle");
CHECK(theDI, aLine == cpLine, "equality of handle and const pointer");
CHECK(theDI, cpLine == aLine, "equality of const pointer and handle");
CHECK(theDI, &rLine == aLine, "equality of reference and handle");
CHECK(theDI, &crLine == aLine, "equality of reference and handle");
CHECK(theDI, aLine == pLine, "equality of handle and pointer");
CHECK(theDI, pLine == aLine, "equality of pointer and handle");
CHECK(theDI, aLine == cpLine, "equality of handle and const pointer");
CHECK(theDI, cpLine == aLine, "equality of const pointer and handle");
CHECK(theDI, &rLine == aLine, "equality of reference and handle");
CHECK(theDI, &crLine == aLine, "equality of reference and handle");
CHECK(theDI, aLine, "cast to bool");
Handle(Geom_Line) aLin2;
CHECK(theDI, aLine != aLin2, "inequality of handle to the same type handle");
CHECK(theDI, aLin2 != cLine, "inequality of const and non-const handle");
CHECK(theDI, aLin2 != cCurve, "inequality of handle and base handle");
CHECK(theDI, aLin2 != pLine, "inequality of handle and pointer");
CHECK(theDI, pLine != aLin2, "inequality of pointer and handle");
CHECK(theDI, aLin2 != cpLine, "inequality of handle and const pointer");
CHECK(theDI, cpLine != aLin2, "inequality of const pointer and handle");
CHECK(theDI, aLin2 != pLine, "inequality of handle and pointer");
CHECK(theDI, pLine != aLin2, "inequality of pointer and handle");
CHECK(theDI, aLin2 != cpLine, "inequality of handle and const pointer");
CHECK(theDI, cpLine != aLin2, "inequality of const pointer and handle");
Handle(Geom_Curve) aCur2;
CHECK(theDI, aLine != aCur2, "inequality of handles of different types");
CHECK(theDI, aCur2 != cLine, "inequality of const and non-const handle");
CHECK(theDI, aCur2 != cCurve, "inequality of handle and base handle");
CHECK(theDI, aCur2 != pLine, "inequality of handle and pointer");
CHECK(theDI, pLine != aCur2, "inequality of pointer and handle");
CHECK(theDI, aCur2 != cpLine, "inequality of handle and const pointer");
CHECK(theDI, cpLine != aCur2, "inequality of const pointer and handle");
CHECK(theDI, aCur2 != pLine, "inequality of handle and pointer");
CHECK(theDI, pLine != aCur2, "inequality of pointer and handle");
CHECK(theDI, aCur2 != cpLine, "inequality of handle and const pointer");
CHECK(theDI, cpLine != aCur2, "inequality of const pointer and handle");
// passing handle as reference to base class
f (aLine);
f(aLine);
// passing handle to overloaded function accepting handle to another type
// will fail on VC below 12 and GCC below 4.3 due to ambiguity of overloads
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) || (defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 3)
func (aLine);
func (cLine);
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) \
|| (defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 3)
func(aLine);
func(cLine);
#endif
const Handle(Geom_Curve)& aCurve2 = aLine; // cast to base const ref
CHECK (theDI, !aCurve2.IsNull (), "cast to base class const reference");
CHECK(theDI, !aCurve2.IsNull(), "cast to base class const reference");
Handle(Geom_Line) qLine = cpLine; // constructor from const pointer -- could be made explicit...
// check that compiler keeps temporary object referenced by local variable
const Handle(Geom_Line)& aTmpRef (Handle(Geom_Line)::DownCast (aCurve2));
// note that here and in similar checks below we use comparison of pointers instead
// of checking handle for Null, since such check may fail if temporary object is
// destroyed prematurely and its location is used for other object.
CHECK(theDI, aTmpRef.get() == aCurve2.get(), "local reference of to temporary handle object");
// check undesired but logical situation:
// check that compiler keeps temporary object referenced by local variable
const Handle(Geom_Line)& aTmpRef(Handle(Geom_Line)::DownCast(aCurve2));
// note that here and in similar checks below we use comparison of pointers instead
// of checking handle for Null, since such check may fail if temporary object is
// destroyed prematurely and its location is used for other object.
CHECK(theDI, aTmpRef.get() == aCurve2.get(), "local reference of to temporary handle object");
// check undesired but logical situation:
// compiler does not keep temporary object referenced by local variable of base type;
// here compiler does not recognize that it should keep the temporary object because handle
// classes do not inherit each other and they use hard cast for references to simulate inheritance
#if defined(__GNUC__) && (__GNUC__ > 12)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdangling-reference"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdangling-reference"
#endif
const Handle(Geom_Curve)& aTmpRefBase (Handle(Geom_Line)::DownCast (aCurve2));
CHECK(theDI, aTmpRefBase.get() != aCurve2.get(), "local reference to temporary handle object (base type)");
const Handle(Geom_Curve)& aTmpRefBase(Handle(Geom_Line)::DownCast(aCurve2));
CHECK(theDI,
aTmpRefBase.get() != aCurve2.get(),
"local reference to temporary handle object (base type)");
#if defined(__GNUC__) && (__GNUC__ > 12)
#pragma GCC diagnostic pop
#pragma GCC diagnostic pop
#endif
// check operations with Handle_* classes
Handle(Geom_Line) hLine = aLine;
CHECK(theDI, ! hLine.IsNull(), "hhandle for non-null");
CHECK(theDI, !hLine.IsNull(), "hhandle for non-null");
#include <Standard_WarningsDisable.hxx>
const Handle_Geom_Line& chLine = aLine; // cast to self const ref
const Handle_Geom_Curve& chCurve = aLine; // cast to base const ref
const Handle_Geom_Line& hhLine = hLine; // cast to self const ref
const Handle_Geom_Curve& hhCurve = hLine; // cast to base const ref
Handle_Geom_Curve hCurve = aLine; // copy from handle to derived type
Handle_Geom_Line phLine (aLine.get()); // construct from pointer
const Handle_Geom_Line& chLine = aLine; // cast to self const ref
const Handle_Geom_Curve& chCurve = aLine; // cast to base const ref
const Handle_Geom_Line& hhLine = hLine; // cast to self const ref
const Handle_Geom_Curve& hhCurve = hLine; // cast to base const ref
Handle_Geom_Curve hCurve = aLine; // copy from handle to derived type
Handle_Geom_Line phLine(aLine.get()); // construct from pointer
hLine = Handle_Geom_Line::DownCast (cCurve); // inheritance of downcast
CHECK(theDI, ! hLine.IsNull(), "down cast");
hLine = Handle_Geom_Line::DownCast(cCurve); // inheritance of downcast
CHECK(theDI, !hLine.IsNull(), "down cast");
// comparison operators
CHECK(theDI, hLine == hLine, "equality of hhandle to itself");
@@ -169,39 +180,44 @@ static Standard_Integer QAHandleOps (Draw_Interpretor& theDI,
CHECK(theDI, hLine, "cast to bool");
// passing hhandle as reference to base class
f (hLine);
f(hLine);
// passing handle to overloaded function accepting handle to another type
// will fail on VC below 12 and GCC below 4.3 due to ambiguity of overloads
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) || (defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 3)
func (hLine);
func (chLine);
#if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1800) \
|| (defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 3)
func(hLine);
func(chLine);
#endif
Handle_Geom_Line qhLine = cpLine; // constructor from const pointer -- could be made explicit...
// check that compiler keeps temporary object referenced by local variable
#if defined(__GNUC__) && (__GNUC__ > 12)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdangling-reference"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wdangling-reference"
#endif
const Handle_Geom_Line& hTmpRef (Handle(Geom_Line)::DownCast (aCurve2));
CHECK(theDI, hTmpRef.get() == aCurve2.get(), "local reference to temporary object (Handle_)");
const Handle_Geom_Line& hTmpRef(Handle(Geom_Line)::DownCast(aCurve2));
CHECK(theDI, hTmpRef.get() == aCurve2.get(), "local reference to temporary object (Handle_)");
// check lifetime of temporary object referenced by local variable (base type)
const Handle_Geom_Curve& hTmpRefBase (Handle(Geom_Line)::DownCast (aCurve2));
#if defined(__GNUC__) && (__GNUC__ > 11)
#pragma GCC diagnostic pop
const Handle_Geom_Curve& hTmpRefBase(Handle(Geom_Line)::DownCast(aCurve2));
#if defined(__GNUC__) && (__GNUC__ > 11)
#pragma GCC diagnostic pop
#endif
// here we have different behavior for MSVC 2013+ where Handle_ is a class
// (compiler creates temporary object of approprtiate type and keeps it living
// until the reference is valid) and other compilers where Handle_ is
// typedef to handle<> (compiler does not know that the reference that is being
// assigned is pointing to temporary object, due to involved type cast operation)
#if (defined(_MSC_VER) && _MSC_VER >= 1800)
CHECK(theDI, hTmpRefBase.get() == aCurve2.get(), "local reference to temporary handle object (Handle_ to base type)");
#if (defined(_MSC_VER) && _MSC_VER >= 1800)
CHECK(theDI,
hTmpRefBase.get() == aCurve2.get(),
"local reference to temporary handle object (Handle_ to base type)");
#else
CHECK(theDI, hTmpRefBase.get() != aCurve2.get(), "local reference to temporary handle object (Handle_ to base type)");
CHECK(theDI,
hTmpRefBase.get() != aCurve2.get(),
"local reference to temporary handle object (Handle_ to base type)");
#endif
#include <Standard_WarningsRestore.hxx>
Handle(Geom_Surface) aSurf;
@@ -236,77 +252,77 @@ static Standard_Integer QAHandleOps (Draw_Interpretor& theDI,
// ===============================================================
// Part 2: classes not inheriting transient
// ===============================================================
/*
Handle(gp_Pnt) aPnt = new gp_Pnt (gp::Origin());
CHECK(theDI, ! aPnt.IsNull(), "handle for non-null");
/*
Handle(gp_Pnt) aPnt = new gp_Pnt (gp::Origin());
CHECK(theDI, ! aPnt.IsNull(), "handle for non-null");
const Handle(gp_Pnt)& cPnt = aPnt; // cast to self const ref
// const Handle(gp_XYZ)& cXYZ = aPnt; // cast to base const ref
gp_Pnt* pPnt = aPnt.get();
const gp_Pnt* cpPnt = aPnt.get();
gp_Pnt& rPnt = *aPnt;
const gp_Pnt& crPnt = *cPnt;
// Handle(gp_XYZ) aXYZ = aPnt; // copy from handle to derived type
// aXYZ = cPnt; // assignment to handle of derived type
const Handle(gp_Pnt)& cPnt = aPnt; // cast to self const ref
// const Handle(gp_XYZ)& cXYZ = aPnt; // cast to base const ref
gp_Pnt* pPnt = aPnt.get();
const gp_Pnt* cpPnt = aPnt.get();
gp_Pnt& rPnt = *aPnt;
const gp_Pnt& crPnt = *cPnt;
// Handle(gp_XYZ) aXYZ = aPnt; // copy from handle to derived type
// aXYZ = cPnt; // assignment to handle of derived type
// aPnt = Handle(gp_Pnt)::DownCast (cXYZ);
// CHECK(theDI, ! aPnt.IsNull(), "down cast");
// aPnt = Handle(gp_Pnt)::DownCast (cXYZ);
// CHECK(theDI, ! aPnt.IsNull(), "down cast");
// comparison operators
CHECK(theDI, aPnt == aPnt, "equality of handle to itself");
CHECK(theDI, cPnt == cPnt, "equality of const handle to itself");
CHECK(theDI, aPnt == cPnt, "equality of const and non-const handle");
// CHECK(theDI, aPnt == cXYZ, "equality of handle and base handle");
CHECK(theDI, aPnt == pPnt, "equality of handle and pointer");
CHECK(theDI, pPnt == aPnt, "equality of pointer and handle");
CHECK(theDI, aPnt == cpPnt, "equality of handle and const pointer");
CHECK(theDI, cpPnt == aPnt, "equality of const pointer and handle");
CHECK(theDI, &rPnt == aPnt, "equality of reference and handle");
CHECK(theDI, &crPnt == aPnt, "equality of reference and handle");
// comparison operators
CHECK(theDI, aPnt == aPnt, "equality of handle to itself");
CHECK(theDI, cPnt == cPnt, "equality of const handle to itself");
CHECK(theDI, aPnt == cPnt, "equality of const and non-const handle");
// CHECK(theDI, aPnt == cXYZ, "equality of handle and base handle");
CHECK(theDI, aPnt == pPnt, "equality of handle and pointer");
CHECK(theDI, pPnt == aPnt, "equality of pointer and handle");
CHECK(theDI, aPnt == cpPnt, "equality of handle and const pointer");
CHECK(theDI, cpPnt == aPnt, "equality of const pointer and handle");
CHECK(theDI, &rPnt == aPnt, "equality of reference and handle");
CHECK(theDI, &crPnt == aPnt, "equality of reference and handle");
Handle(gp_Pnt) aPnt2;
CHECK(theDI, aPnt != aPnt2, "inequality of handle to the same type handle");
CHECK(theDI, aPnt2 != cPnt, "inequality of const and non-const handle");
// CHECK(theDI, aPnt2 != cXYZ, "inequality of handle and base handle");
CHECK(theDI, aPnt2 != pPnt, "inequality of handle and pointer");
CHECK(theDI, pPnt != aPnt2, "inequality of pointer and handle");
CHECK(theDI, aPnt2 != cpPnt, "inequality of handle and const pointer");
CHECK(theDI, cpPnt != aPnt2, "inequality of const pointer and handle");
Handle(gp_Pnt) aPnt2;
CHECK(theDI, aPnt != aPnt2, "inequality of handle to the same type handle");
CHECK(theDI, aPnt2 != cPnt, "inequality of const and non-const handle");
// CHECK(theDI, aPnt2 != cXYZ, "inequality of handle and base handle");
CHECK(theDI, aPnt2 != pPnt, "inequality of handle and pointer");
CHECK(theDI, pPnt != aPnt2, "inequality of pointer and handle");
CHECK(theDI, aPnt2 != cpPnt, "inequality of handle and const pointer");
CHECK(theDI, cpPnt != aPnt2, "inequality of const pointer and handle");
Handle(gp_XYZ) aXYZ2;
CHECK(theDI, aLine != aPnt2, "inequality of handles of different types");
CHECK(theDI, aXYZ2 != cPnt, "inequality of const and non-const handle");
// CHECK(theDI, aXYZ2 != cXYZ, "inequality of handle and base handle");
// CHECK(theDI, aXYZ2 != pPnt, "inequality of handle and pointer");
// CHECK(theDI, pPnt != aXYZ2, "inequality of pointer and handle");
// CHECK(theDI, aXYZ2 != cpPnt, "inequality of handle and const pointer");
// CHECK(theDI, cpPnt != aXYZ2, "inequality of const pointer and handle");
Handle(gp_XYZ) aXYZ2;
CHECK(theDI, aLine != aPnt2, "inequality of handles of different types");
CHECK(theDI, aXYZ2 != cPnt, "inequality of const and non-const handle");
// CHECK(theDI, aXYZ2 != cXYZ, "inequality of handle and base handle");
// CHECK(theDI, aXYZ2 != pPnt, "inequality of handle and pointer");
// CHECK(theDI, pPnt != aXYZ2, "inequality of pointer and handle");
// CHECK(theDI, aXYZ2 != cpPnt, "inequality of handle and const pointer");
// CHECK(theDI, cpPnt != aXYZ2, "inequality of const pointer and handle");
// passing handle as reference to base class
func (aPnt);
func (cPnt);
*/
// passing handle as reference to base class
func (aPnt);
func (cPnt);
*/
return 0;
}
//=======================================================================
//function : QAHandleBool
//purpose : Test Handle -> bool conversion
// function : QAHandleBool
// purpose : Test Handle -> bool conversion
//=======================================================================
static Standard_Integer QAHandleBool (Draw_Interpretor& theDI,
Standard_Integer /*theArgNb*/,
const char** /*theArgVec*/)
static Standard_Integer QAHandleBool(Draw_Interpretor& theDI,
Standard_Integer /*theArgNb*/,
const char** /*theArgVec*/)
{
Handle(NCollection_BaseAllocator) aPtr = new NCollection_IncAllocator();
Handle(NCollection_IncAllocator) anInc = Handle(NCollection_IncAllocator)::DownCast (aPtr);
CHECK (theDI, ! anInc.IsNull(), "cast to NCollection_IncAllocator");
Handle(NCollection_IncAllocator) anInc = Handle(NCollection_IncAllocator)::DownCast(aPtr);
CHECK(theDI, !anInc.IsNull(), "cast to NCollection_IncAllocator");
Handle(NCollection_BaseAllocator) anAlloc = aPtr;
CHECK (theDI, ! anAlloc.IsNull(), "cast to NCollection_BaseAllocator");
Handle(NCollection_HeapAllocator) aHAlloc = Handle(NCollection_HeapAllocator)::DownCast (aPtr);
CHECK (theDI, aHAlloc.IsNull(), "cast to NCollection_HeapAllocator");
CHECK(theDI, !anAlloc.IsNull(), "cast to NCollection_BaseAllocator");
Handle(NCollection_HeapAllocator) aHAlloc = Handle(NCollection_HeapAllocator)::DownCast(aPtr);
CHECK(theDI, aHAlloc.IsNull(), "cast to NCollection_HeapAllocator");
return 0;
}
@@ -316,63 +332,75 @@ class Transient_Root : public Standard_Transient
{
public:
virtual const char* Name() const { return "Transient_Root"; }
virtual Standard_Transient* CreateParent() const { return new Standard_Transient; }
virtual Standard_Transient* Clone() const { return new Transient_Root; }
DEFINE_STANDARD_RTTI_INLINE(Transient_Root,Standard_Transient)
virtual Standard_Transient* Clone() const { return new Transient_Root; }
DEFINE_STANDARD_RTTI_INLINE(Transient_Root, Standard_Transient)
};
DEFINE_STANDARD_HANDLE(Transient_Root, Standard_Transient)
// Auxiliary macros to create hierarchy of 50 classes
#define QA_DEFINECLASS(theClass, theParent) \
class theClass : public theParent \
{ \
public:\
virtual const char* Name() const Standard_OVERRIDE { return #theClass; } \
virtual Standard_Transient* CreateParent() const Standard_OVERRIDE { return new theParent(); } \
virtual Standard_Transient* Clone() const Standard_OVERRIDE { return new theClass(); } \
DEFINE_STANDARD_RTTI_INLINE(theClass,theParent) \
};\
DEFINE_STANDARD_HANDLE (theClass, theParent)
#define QA_DEFINECLASS(theClass, theParent) \
class theClass : public theParent \
{ \
public: \
virtual const char* Name() const Standard_OVERRIDE \
{ \
return #theClass; \
} \
virtual Standard_Transient* CreateParent() const Standard_OVERRIDE \
{ \
return new theParent(); \
} \
virtual Standard_Transient* Clone() const Standard_OVERRIDE \
{ \
return new theClass(); \
} \
DEFINE_STANDARD_RTTI_INLINE(theClass, theParent) \
}; \
DEFINE_STANDARD_HANDLE(theClass, theParent)
#define QA_NAME(theNum) qaclass ## theNum ## _ ## 50
#define QA_HANDLE_NAME(theNum) Handle(qaclass ## theNum ## _ ## 50)
#define QA_NAME(theNum) qaclass##theNum##_##50
#define QA_HANDLE_NAME(theNum) Handle(qaclass##theNum##_##50)
#define QA_DEFINECLASS10(theParent, theTens) \
QA_DEFINECLASS(QA_NAME(theTens ## 0), theParent) \
QA_DEFINECLASS(QA_NAME(theTens ## 1), QA_NAME(theTens ## 0)) \
QA_DEFINECLASS(QA_NAME(theTens ## 2), QA_NAME(theTens ## 1)) \
QA_DEFINECLASS(QA_NAME(theTens ## 3), QA_NAME(theTens ## 2)) \
QA_DEFINECLASS(QA_NAME(theTens ## 4), QA_NAME(theTens ## 3)) \
QA_DEFINECLASS(QA_NAME(theTens ## 5), QA_NAME(theTens ## 4)) \
QA_DEFINECLASS(QA_NAME(theTens ## 6), QA_NAME(theTens ## 5)) \
QA_DEFINECLASS(QA_NAME(theTens ## 7), QA_NAME(theTens ## 6)) \
QA_DEFINECLASS(QA_NAME(theTens ## 8), QA_NAME(theTens ## 7)) \
QA_DEFINECLASS(QA_NAME(theTens ## 9), QA_NAME(theTens ## 8))
#define QA_DEFINECLASS10(theParent, theTens) \
QA_DEFINECLASS(QA_NAME(theTens##0), theParent) \
QA_DEFINECLASS(QA_NAME(theTens##1), QA_NAME(theTens##0)) \
QA_DEFINECLASS(QA_NAME(theTens##2), QA_NAME(theTens##1)) \
QA_DEFINECLASS(QA_NAME(theTens##3), QA_NAME(theTens##2)) \
QA_DEFINECLASS(QA_NAME(theTens##4), QA_NAME(theTens##3)) \
QA_DEFINECLASS(QA_NAME(theTens##5), QA_NAME(theTens##4)) \
QA_DEFINECLASS(QA_NAME(theTens##6), QA_NAME(theTens##5)) \
QA_DEFINECLASS(QA_NAME(theTens##7), QA_NAME(theTens##6)) \
QA_DEFINECLASS(QA_NAME(theTens##8), QA_NAME(theTens##7)) \
QA_DEFINECLASS(QA_NAME(theTens##9), QA_NAME(theTens##8))
QA_DEFINECLASS10(Transient_Root, 0)
QA_DEFINECLASS10(qaclass09_50, 1)
QA_DEFINECLASS10(qaclass19_50, 2)
QA_DEFINECLASS10(qaclass29_50, 3)
QA_DEFINECLASS10(qaclass39_50, 4)
QA_DEFINECLASS (qaclass50_50, qaclass49_50)
QA_DEFINECLASS10(Transient_Root, 0)
QA_DEFINECLASS10(qaclass09_50, 1)
QA_DEFINECLASS10(qaclass19_50, 2)
QA_DEFINECLASS10(qaclass29_50, 3)
QA_DEFINECLASS10(qaclass39_50, 4)
QA_DEFINECLASS(qaclass50_50, qaclass49_50)
namespace
{
class qaclass50_50ANON : public qaclass49_50
{
};
}
class qaclass50_50ANON : public qaclass49_50
{
};
} // namespace
namespace QaNamespace
{
class qaclass50_50 : public qaclass49_50
{
public:
qaclass50_50() {}
};
}
class qaclass50_50 : public qaclass49_50
{
public:
qaclass50_50() {}
};
} // namespace QaNamespace
namespace {
namespace
{
//! Timer sentry. Prints elapsed time information at destruction time.
class QATimer : public OSD_Timer
{
@@ -390,16 +418,16 @@ public:
public:
//! Main constructor - automatically starts the timer.
QATimer (Draw_Interpretor& theDI,
Standard_CString theTitle,
const TimeFormat theFormat,
const Standard_Integer theNbIters = 1,
const Standard_Boolean theToPrintFormat = Standard_False)
: myDI(&theDI),
myTitle (theTitle),
myFormat (theFormat),
myNbIters (theNbIters),
myToPrintFormat (theToPrintFormat)
QATimer(Draw_Interpretor& theDI,
Standard_CString theTitle,
const TimeFormat theFormat,
const Standard_Integer theNbIters = 1,
const Standard_Boolean theToPrintFormat = Standard_False)
: myDI(&theDI),
myTitle(theTitle),
myFormat(theFormat),
myNbIters(theNbIters),
myToPrintFormat(theToPrintFormat)
{
Start();
}
@@ -415,7 +443,7 @@ public:
switch (myFormat)
{
case Seconds:
(*myDI) << ElapsedTime() / Standard_Real(myNbIters);
(*myDI) << ElapsedTime() / Standard_Real(myNbIters);
if (myToPrintFormat)
{
(*myDI) << " s";
@@ -447,42 +475,43 @@ public:
private:
Draw_Interpretor* myDI;
Standard_CString myTitle; //!< timer description
TimeFormat myFormat; //!< time format
Standard_Integer myNbIters; //!< iterations number
Standard_Boolean myToPrintFormat; //!< add time format
Standard_CString myTitle; //!< timer description
TimeFormat myFormat; //!< time format
Standard_Integer myNbIters; //!< iterations number
Standard_Boolean myToPrintFormat; //!< add time format
};
} // anonymous namespace
//=======================================================================
//function : QAHandleInc
//purpose : Estimate the smart-pointer counter incrementing time
// function : QAHandleInc
// purpose : Estimate the smart-pointer counter incrementing time
//=======================================================================
static Standard_Integer QAHandleInc (Draw_Interpretor& theDI,
Standard_Integer theArgNb,
const char** theArgVec)
static Standard_Integer QAHandleInc(Draw_Interpretor& theDI,
Standard_Integer theArgNb,
const char** theArgVec)
{
if (theArgNb > 2)
{
std::cout << "Error: wrong syntax! See usage:\n";
theDI.PrintHelp (theArgVec[0]);
theDI.PrintHelp(theArgVec[0]);
return 1;
}
const Standard_Integer aNbIters = (theArgNb > 1) ? Draw::Atoi (theArgVec[1]) : 10000000;
const Standard_Integer aNbIters = (theArgNb > 1) ? Draw::Atoi(theArgVec[1]) : 10000000;
if (aNbIters < 1)
{
std::cout << "Error: number of iterations should be positive!\n";
return 1;
}
Handle(Standard_Transient) aHandle = new Standard_Transient();
std::shared_ptr<Standard_Transient> aSharePtr (new Standard_Transient());
theDI << "Time of creating and destroying " << aNbIters << " smart pointers to the same object, per item, ns:";
Handle(Standard_Transient) aHandle = new Standard_Transient();
std::shared_ptr<Standard_Transient> aSharePtr(new Standard_Transient());
theDI << "Time of creating and destroying " << aNbIters
<< " smart pointers to the same object, per item, ns:";
{
{
QATimer aTimer (theDI, "\nOCCT Handle: ", QATimer::ns, aNbIters);
QATimer aTimer(theDI, "\nOCCT Handle: ", QATimer::ns, aNbIters);
{
std::vector<Handle(Standard_Transient)> aHandles (aNbIters);
std::vector<Handle(Standard_Transient)> aHandles(aNbIters);
for (Standard_Integer anIter = 0; anIter < aNbIters; ++anIter)
{
aHandles[anIter] = aHandle;
@@ -490,9 +519,9 @@ static Standard_Integer QAHandleInc (Draw_Interpretor& theDI,
}
}
{
QATimer aTimer (theDI, "\nC++ shared_ptr: ", QATimer::ns, aNbIters);
QATimer aTimer(theDI, "\nC++ shared_ptr: ", QATimer::ns, aNbIters);
{
std::vector< std::shared_ptr<Standard_Transient> > aSharePointers (aNbIters);
std::vector<std::shared_ptr<Standard_Transient>> aSharePointers(aNbIters);
for (Standard_Integer anIter = 0; anIter < aNbIters; ++anIter)
{
aSharePointers[anIter] = aSharePtr;
@@ -503,13 +532,11 @@ static Standard_Integer QAHandleInc (Draw_Interpretor& theDI,
return 0;
}
//=======================================================================
//function : QAHandleKind
//purpose :
//=======================================================================
static Standard_Integer QAHandleKind (Draw_Interpretor& /*theDI*/,
Standard_Integer /*theArgNb*/,
const char** /*theArgVec*/)
//=================================================================================================
static Standard_Integer QAHandleKind(Draw_Interpretor& /*theDI*/,
Standard_Integer /*theArgNb*/,
const char** /*theArgVec*/)
{
Handle(Standard_Type) aType00 = STANDARD_TYPE(qaclass00_50);
Handle(Standard_Type) aType10 = STANDARD_TYPE(qaclass10_50);
@@ -520,91 +547,112 @@ static Standard_Integer QAHandleKind (Draw_Interpretor& /*theDI*/,
Handle(qaclass00_50) aHandle = new qaclass40_50();
#define QA_CHECK(theDesc, theExpr, theValue) \
{\
const bool isTrue = !!(theExpr); \
std::cout << theDesc << (isTrue ? " TRUE " : " FALSE ") << (isTrue == theValue ? " is OK\n" : " is Error\n"); \
}
#define QA_CHECK(theDesc, theExpr, theValue) \
{ \
const bool isTrue = !!(theExpr); \
std::cout << theDesc << (isTrue ? " TRUE " : " FALSE ") \
<< (isTrue == theValue ? " is OK\n" : " is Error\n"); \
}
std::cout << "Check instance of " << aHandle->DynamicType()->Name() << "\n";
for (Handle(Standard_Type) aType = aHandle->DynamicType(); ! aType.IsNull(); aType = aType->Parent())
for (Handle(Standard_Type) aType = aHandle->DynamicType(); !aType.IsNull();
aType = aType->Parent())
{
std::cout << " - " << aType->Name() << "\n";
}
QA_CHECK ("Name == qaclass40_50 : ", TCollection_AsciiString("qaclass40_50") == aHandle->DynamicType()->Name(), true);
QA_CHECK("Name == qaclass40_50 : ",
TCollection_AsciiString("qaclass40_50") == aHandle->DynamicType()->Name(),
true);
QA_CHECK ("IsKind (aType00) : ", aHandle->IsKind (aType00), true);
QA_CHECK ("IsKind (aType10) : ", aHandle->IsKind (aType10), true);
QA_CHECK ("IsKind (aType20) : ", aHandle->IsKind (aType20), true);
QA_CHECK ("IsKind (aType30) : ", aHandle->IsKind (aType30), true);
QA_CHECK ("IsKind (aType40) : ", aHandle->IsKind (aType40), true);
QA_CHECK ("IsKind (aType50) : ", aHandle->IsKind (aType50), false);
QA_CHECK("IsKind (aType00) : ", aHandle->IsKind(aType00), true);
QA_CHECK("IsKind (aType10) : ", aHandle->IsKind(aType10), true);
QA_CHECK("IsKind (aType20) : ", aHandle->IsKind(aType20), true);
QA_CHECK("IsKind (aType30) : ", aHandle->IsKind(aType30), true);
QA_CHECK("IsKind (aType40) : ", aHandle->IsKind(aType40), true);
QA_CHECK("IsKind (aType50) : ", aHandle->IsKind(aType50), false);
QA_CHECK ("IsKind (\"qaclass00_50\"): ", aHandle->IsKind ("qaclass00_50"), true);
QA_CHECK ("IsKind (\"qaclass10_50\"): ", aHandle->IsKind ("qaclass10_50"), true);
QA_CHECK ("IsKind (\"qaclass20_50\"): ", aHandle->IsKind ("qaclass20_50"), true);
QA_CHECK ("IsKind (\"qaclass30_50\"): ", aHandle->IsKind ("qaclass30_50"), true);
QA_CHECK ("IsKind (\"qaclass40_50\"): ", aHandle->IsKind ("qaclass40_50"), true);
QA_CHECK ("IsKind (\"qaclass50_50\"): ", aHandle->IsKind ("qaclass50_50"), false);
QA_CHECK("IsKind (\"qaclass00_50\"): ", aHandle->IsKind("qaclass00_50"), true);
QA_CHECK("IsKind (\"qaclass10_50\"): ", aHandle->IsKind("qaclass10_50"), true);
QA_CHECK("IsKind (\"qaclass20_50\"): ", aHandle->IsKind("qaclass20_50"), true);
QA_CHECK("IsKind (\"qaclass30_50\"): ", aHandle->IsKind("qaclass30_50"), true);
QA_CHECK("IsKind (\"qaclass40_50\"): ", aHandle->IsKind("qaclass40_50"), true);
QA_CHECK("IsKind (\"qaclass50_50\"): ", aHandle->IsKind("qaclass50_50"), false);
QA_CHECK ("IsInstance (aType00) : ", aHandle->IsInstance (aType00), false);
QA_CHECK ("IsInstance (aType10) : ", aHandle->IsInstance (aType10), false);
QA_CHECK ("IsInstance (aType20) : ", aHandle->IsInstance (aType20), false);
QA_CHECK ("IsInstance (aType30) : ", aHandle->IsInstance (aType30), false);
QA_CHECK ("IsInstance (aType40) : ", aHandle->IsInstance (aType40), true);
QA_CHECK ("IsInstance (aType50) : ", aHandle->IsInstance (aType50), false);
QA_CHECK("IsInstance (aType00) : ", aHandle->IsInstance(aType00), false);
QA_CHECK("IsInstance (aType10) : ", aHandle->IsInstance(aType10), false);
QA_CHECK("IsInstance (aType20) : ", aHandle->IsInstance(aType20), false);
QA_CHECK("IsInstance (aType30) : ", aHandle->IsInstance(aType30), false);
QA_CHECK("IsInstance (aType40) : ", aHandle->IsInstance(aType40), true);
QA_CHECK("IsInstance (aType50) : ", aHandle->IsInstance(aType50), false);
#ifdef HAVE_CPP11
std::cout << "\nC++11:\n";
std::type_index aCppType = typeid(*aHandle.operator->());
std::cout << "typeid().name() = '" << typeid(*aHandle.operator->()).name() << "'\n";
#ifdef _MSC_VER
std::type_index aCppType = typeid(*aHandle.operator->());
std::cout << "typeid().name() = '" << typeid(*aHandle.operator->()).name() << "'\n";
#ifdef _MSC_VER
std::cout << "typeid().raw_name()= '" << typeid(*aHandle.operator->()).raw_name() << "'\n";
#endif
#endif
std::cout << "[ANON]typeid().name() = '" << typeid(qaclass50_50ANON).name() << "'\n";
#ifdef _MSC_VER
std::cout << "[ANON]typeid().name() = '" << typeid(qaclass50_50ANON).name() << "'\n";
#ifdef _MSC_VER
std::cout << "[ANON]typeid().raw_name()= '" << typeid(qaclass50_50ANON).raw_name() << "'\n";
#endif
#endif
std::cout << "[NS]typeid().name() = '" << typeid(QaNamespace::qaclass50_50).name() << "'\n";
#ifdef _MSC_VER
std::cout << "[NS]typeid().raw_name()= '" << typeid(QaNamespace::qaclass50_50).raw_name() << "'\n";
#endif
std::cout << "[NS]typeid().name() = '" << typeid(QaNamespace::qaclass50_50).name() << "'\n";
#ifdef _MSC_VER
std::cout << "[NS]typeid().raw_name()= '" << typeid(QaNamespace::qaclass50_50).raw_name()
<< "'\n";
#endif
QA_CHECK ("is typeid (aType00) : ", typeid(*aHandle.operator->()) == typeid(qaclass00_50), false);
QA_CHECK ("is typeid (aType10) : ", typeid(*aHandle.operator->()) == typeid(qaclass10_50), false);
QA_CHECK ("is typeid (aType20) : ", typeid(*aHandle.operator->()) == typeid(qaclass20_50), false);
QA_CHECK ("is typeid (aType30) : ", typeid(*aHandle.operator->()) == typeid(qaclass30_50), false);
QA_CHECK ("is typeid (aType40) : ", typeid(*aHandle.operator->()) == typeid(qaclass40_50), true);
QA_CHECK ("is typeid (aType50) : ", typeid(*aHandle.operator->()) == typeid(qaclass50_50), false);
QA_CHECK("is typeid (aType00) : ",
typeid(*aHandle.operator->()) == typeid(qaclass00_50),
false);
QA_CHECK("is typeid (aType10) : ",
typeid(*aHandle.operator->()) == typeid(qaclass10_50),
false);
QA_CHECK("is typeid (aType20) : ",
typeid(*aHandle.operator->()) == typeid(qaclass20_50),
false);
QA_CHECK("is typeid (aType30) : ",
typeid(*aHandle.operator->()) == typeid(qaclass30_50),
false);
QA_CHECK("is typeid (aType40) : ",
typeid(*aHandle.operator->()) == typeid(qaclass40_50),
true);
QA_CHECK("is typeid (aType50) : ",
typeid(*aHandle.operator->()) == typeid(qaclass50_50),
false);
QA_CHECK ("is type_index (aType00) : ", aCppType == typeid(qaclass00_50), false);
QA_CHECK ("is type_index (aType40) : ", aCppType == typeid(qaclass40_50), true);
QA_CHECK("is type_index (aType00) : ", aCppType == typeid(qaclass00_50), false);
QA_CHECK("is type_index (aType40) : ", aCppType == typeid(qaclass40_50), true);
QA_CHECK ("IsClass(Standard_Transient): ", std::is_class<Standard_Transient>::value == !!STANDARD_TYPE(Standard_Transient)->IsClass(), true);
//QA_CHECK ("IsEnum (Message_Status) : ", std::is_enum<Message_Status>::value == !!STANDARD_TYPE(Message_Status)->IsEnumeration(), true);
QA_CHECK("IsClass(Standard_Transient): ",
std::is_class<Standard_Transient>::value
== !!STANDARD_TYPE(Standard_Transient)->IsClass(),
true);
// QA_CHECK ("IsEnum (Message_Status) : ", std::is_enum<Message_Status>::value ==
// !!STANDARD_TYPE(Message_Status)->IsEnumeration(), true);
#endif
return 0;
}
void QANCollection::CommandsHandle (Draw_Interpretor& theCommands)
void QANCollection::CommandsHandle(Draw_Interpretor& theCommands)
{
const char* THE_GROUP = "QANCollection";
theCommands.Add ("QAHandleBool",
"Test handle boolean operator",
__FILE__, QAHandleBool, THE_GROUP);
theCommands.Add ("QAHandleInc",
"QAHandleInc nbIter=1000000"
"\n\t\t: Test handle increment performance",
__FILE__, QAHandleInc, THE_GROUP);
theCommands.Add ("QAHandleKind",
"Test handle IsKind",
__FILE__, QAHandleKind, THE_GROUP);
theCommands.Add ("QAHandleOps",
"Test handle operations",
__FILE__, QAHandleOps, THE_GROUP);
theCommands.Add("QAHandleBool",
"Test handle boolean operator",
__FILE__,
QAHandleBool,
THE_GROUP);
theCommands.Add("QAHandleInc",
"QAHandleInc nbIter=1000000"
"\n\t\t: Test handle increment performance",
__FILE__,
QAHandleInc,
THE_GROUP);
theCommands.Add("QAHandleKind", "Test handle IsKind", __FILE__, QAHandleKind, THE_GROUP);
theCommands.Add("QAHandleOps", "Test handle operations", __FILE__, QAHandleOps, THE_GROUP);
return;
}

View File

@@ -19,7 +19,6 @@
#include <gp_Pnt.hxx>
#include <NCollection_IndexedDataMap.hxx>
typedef NCollection_IndexedDataMap<Standard_Real,gp_Pnt> QANCollection_IndexedDataMapOfRealPnt;
typedef NCollection_IndexedDataMap<Standard_Real, gp_Pnt> QANCollection_IndexedDataMapOfRealPnt;
#endif

View File

@@ -11,7 +11,6 @@
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
#ifndef QANCollection_ListIteratorOfListOfPnt_HeaderFile
#define QANCollection_ListIteratorOfListOfPnt_HeaderFile

View File

@@ -19,8 +19,7 @@
#include <gp_Pnt.hxx>
#include <NCollection_List.hxx>
typedef NCollection_List<gp_Pnt> QANCollection_ListOfPnt;
typedef NCollection_List<gp_Pnt> QANCollection_ListOfPnt;
typedef NCollection_List<gp_Pnt>::Iterator QANCollection_ListIteratorOfListOfPnt;
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff