From 3a01a933afa3da49bcbeb9cb0d6e9481b6a00ad5 Mon Sep 17 00:00:00 2001 From: abv Date: Mon, 12 May 2014 16:08:36 +0400 Subject: [PATCH] 0024240: Separation of header files for QANCollection into hxx and cxx Files in QANCollection tests reorganized to avoid placing code in header files --- src/QANCollection/FILES | 20 +- src/QANCollection/QANCollection.cdl | 17 +- src/QANCollection/QANCollection.cxx | 9 +- src/QANCollection/QANCollection2.cxx | 239 ---- src/QANCollection/QANCollection3.cxx | 215 --- src/QANCollection/QANCollectionTest.cxx | 150 --- ...ollection4.cxx => QANCollection_Alloc.cxx} | 2 +- src/QANCollection/QANCollection_Common2.hxx | 187 --- src/QANCollection/QANCollection_Common3.hxx | 185 --- .../QANCollection_FuncArrays.hxx | 92 -- src/QANCollection/QANCollection_FuncLists.hxx | 129 -- src/QANCollection/QANCollection_FuncMaps.hxx | 287 ---- src/QANCollection/QANCollection_FuncTest.hxx | 40 - src/QANCollection/QANCollection_Perf.cxx | 1156 +++++++++++++++++ .../QANCollection_PerfArrays.hxx | 196 --- src/QANCollection/QANCollection_PerfLists.hxx | 188 --- src/QANCollection/QANCollection_PerfMaps.hxx | 516 -------- .../QANCollection_PerfSparseArray.hxx | 82 -- src/QANCollection/QANCollection_PerfTest.hxx | 34 - ...llection1.cxx => QANCollection_Simple.cxx} | 147 ++- src/QANCollection/QANCollection_Test.cxx | 761 +++++++++++ 21 files changed, 2042 insertions(+), 2610 deletions(-) delete mode 100644 src/QANCollection/QANCollection2.cxx delete mode 100644 src/QANCollection/QANCollection3.cxx delete mode 100644 src/QANCollection/QANCollectionTest.cxx rename src/QANCollection/{QANCollection4.cxx => QANCollection_Alloc.cxx} (98%) delete mode 100644 src/QANCollection/QANCollection_Common2.hxx delete mode 100644 src/QANCollection/QANCollection_Common3.hxx delete mode 100644 src/QANCollection/QANCollection_FuncArrays.hxx delete mode 100644 src/QANCollection/QANCollection_FuncLists.hxx delete mode 100644 src/QANCollection/QANCollection_FuncMaps.hxx delete mode 100644 src/QANCollection/QANCollection_FuncTest.hxx create mode 100644 src/QANCollection/QANCollection_Perf.cxx delete mode 100644 src/QANCollection/QANCollection_PerfArrays.hxx delete mode 100644 src/QANCollection/QANCollection_PerfLists.hxx delete mode 100644 src/QANCollection/QANCollection_PerfMaps.hxx delete mode 100644 src/QANCollection/QANCollection_PerfSparseArray.hxx delete mode 100644 src/QANCollection/QANCollection_PerfTest.hxx rename src/QANCollection/{QANCollection1.cxx => QANCollection_Simple.cxx} (52%) create mode 100644 src/QANCollection/QANCollection_Test.cxx diff --git a/src/QANCollection/FILES b/src/QANCollection/FILES index 36e738e076..e3f3d5b255 100755 --- a/src/QANCollection/FILES +++ b/src/QANCollection/FILES @@ -1,22 +1,10 @@ FILES QANCollection.cdl QANCollection.cxx -QANCollection1.cxx -QANCollection2.cxx -QANCollection3.cxx -QANCollection4.cxx +QANCollection_Simple.cxx +QANCollection_Test.cxx +QANCollection_Perf.cxx +QANCollection_Alloc.cxx QANCollection_Stl.cxx QANCollection_Common.cxx QANCollection_Common.hxx -QANCollection_Common2.hxx -QANCollection_Common3.hxx -QANCollection_FuncArrays.hxx -QANCollection_FuncLists.hxx -QANCollection_FuncMaps.hxx -QANCollection_FuncTest.hxx -QANCollection_PerfArrays.hxx -QANCollection_PerfLists.hxx -QANCollection_PerfMaps.hxx -QANCollection_PerfTest.hxx -QANCollectionTest.cxx -QANCollection_PerfSparseArray.hxx diff --git a/src/QANCollection/QANCollection.cdl b/src/QANCollection/QANCollection.cdl index 0d35dc9cad..f2634859cd 100644 --- a/src/QANCollection/QANCollection.cdl +++ b/src/QANCollection/QANCollection.cdl @@ -37,20 +37,11 @@ is MapRealHasher from TColStd, MapIntegerHasher from TColStd); - ---- HashCode (thePnt : Pnt from gp; ---- theUpper : Integer from Standard) ---- returns Integer from Standard; - ---- IsEqual (thePnt1 : Pnt from gp; ---- thePnt2 : Pnt from gp) ---- returns Boolean from Standard; - Commands(DI : in out Interpretor from Draw); - Commands1(DI : in out Interpretor from Draw); - Commands2(DI : in out Interpretor from Draw); - Commands3(DI : in out Interpretor from Draw); - Commands4(DI : in out Interpretor from Draw); + CommandsSimple(DI : in out Interpretor from Draw); + CommandsTest(DI : in out Interpretor from Draw); + CommandsPerf(DI : in out Interpretor from Draw); + CommandsAlloc(DI : in out Interpretor from Draw); CommandsStl(DI : in out Interpretor from Draw); end; diff --git a/src/QANCollection/QANCollection.cxx b/src/QANCollection/QANCollection.cxx index 3a6e3eb992..11eb65dd91 100644 --- a/src/QANCollection/QANCollection.cxx +++ b/src/QANCollection/QANCollection.cxx @@ -17,13 +17,12 @@ #include #include -//#include void QANCollection::Commands (Draw_Interpretor& theCommands) { - QANCollection::Commands1 (theCommands); - QANCollection::Commands2 (theCommands); - QANCollection::Commands3 (theCommands); - QANCollection::Commands4 (theCommands); + QANCollection::CommandsSimple (theCommands); + QANCollection::CommandsTest (theCommands); + QANCollection::CommandsPerf (theCommands); + QANCollection::CommandsAlloc (theCommands); QANCollection::CommandsStl (theCommands); } diff --git a/src/QANCollection/QANCollection2.cxx b/src/QANCollection/QANCollection2.cxx deleted file mode 100644 index be5772dcc2..0000000000 --- a/src/QANCollection/QANCollection2.cxx +++ /dev/null @@ -1,239 +0,0 @@ -// Created on: 2004-03-05 -// Created by: Mikhail KUZMITCHEV -// Copyright (c) 2004-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#include - -#include -#include - -#include - -// HashCode and IsEquel must be defined for key types of maps -Standard_Integer HashCode(const gp_Pnt thePnt, int theUpper) -{ - return HashCode(thePnt.X(),theUpper); -} - -Standard_Boolean IsEqual(const gp_Pnt& theP1, const gp_Pnt& theP2) -{ - return theP1.IsEqual(theP2,gp::Resolution()); -} - -#define ItemType gp_Pnt -#define Key1Type gp_Pnt -#define Key2Type Standard_Real - -#include - -IMPLEMENT_HARRAY1(QANCollection_HArray1Func) -IMPLEMENT_HARRAY2(QANCollection_HArray2Func) -IMPLEMENT_HSEQUENCE(QANCollection_HSequenceFunc) - -//======================================================================= -//function : CheckArguments1 -//purpose : -//======================================================================= -Standard_Integer CheckArguments1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv, Standard_Integer& Lower, Standard_Integer& Upper) -{ - if ( argc != 3) { - di << "Usage : " << argv[0] << " Lower Upper" << "\n"; - return 1; - } - Lower = Draw::Atoi(argv[1]); - Upper = Draw::Atoi(argv[2]); - if ( Lower > Upper ) { - di << "Lower > Upper" << "\n"; - return 1; - } - return 0; -} - -//======================================================================= -//function : CheckArguments2 -//purpose : -//======================================================================= -Standard_Integer CheckArguments2(Draw_Interpretor& di, Standard_Integer argc, const char ** argv, Standard_Integer& LowerRow, Standard_Integer& UpperRow, Standard_Integer& LowerCol, Standard_Integer& UpperCol) -{ - if ( argc != 5) { - di << "Usage : " << argv[0] << " LowerRow UpperRow LowerCol UpperCol" << "\n"; - return 1; - } - LowerRow = Draw::Atoi(argv[1]); - UpperRow = Draw::Atoi(argv[2]); - LowerCol = Draw::Atoi(argv[3]); - UpperCol = Draw::Atoi(argv[4]); - if ( LowerRow > UpperRow ) { - di << "LowerRow > UpperRow" << "\n"; - return 1; - } - if ( LowerCol > UpperCol ) { - di << "LowerCol UpperCol> " << "\n"; - return 1; - } - return 0; -} - - -//======================================================================= -//function : QANColTestArray1 -//purpose : -//======================================================================= -static Standard_Integer QANColTestArray1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - Standard_Integer Lower, Upper; - if ( CheckArguments1(di, argc, argv, Lower, Upper) ) { - return 1; - } - QANCollection_Array1Func anArr1(Lower, Upper); - TestArray1(anArr1); - return 0; -} - -//======================================================================= -//function : QANColTestArray2 -//purpose : -//======================================================================= -static Standard_Integer QANColTestArray2(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - Standard_Integer LowerRow, UpperRow, LowerCol, UpperCol; - if ( CheckArguments2(di, argc, argv, LowerRow, UpperRow, LowerCol, UpperCol) ) { - return 1; - } - QANCollection_Array2Func anArr2(LowerRow, UpperRow, LowerCol, UpperCol); - TestArray2(anArr2); - return 0; -} - -//======================================================================= -//function : QANColTestMap -//purpose : -//======================================================================= -static Standard_Integer QANColTestMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - if ( argc != 1) { - di << "Usage : " << argv[0] << "\n"; - return 1; - } - QANCollection_MapFunc aMap; - TestMap(aMap); - return 0; -} - -//======================================================================= -//function : QANColTestDataMap -//purpose : -//======================================================================= -static Standard_Integer QANColTestDataMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - if ( argc != 1) { - di << "Usage : " << argv[0] << "\n"; - return 1; - } - QANCollection_DataMapFunc aDataMap; - TestDataMap(aDataMap); - return 0; -} - -//======================================================================= -//function : QANColTestDoubleMap -//purpose : -//======================================================================= -static Standard_Integer QANColTestDoubleMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - if ( argc != 1) { - di << "Usage : " << argv[0] << "\n"; - return 1; - } - QANCollection_DoubleMapFunc aDoubleMap; - TestDoubleMap(aDoubleMap); - return 0; -} - -//======================================================================= -//function : QANColTestIndexedMap -//purpose : -//======================================================================= -static Standard_Integer QANColTestIndexedMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - if ( argc != 1) { - di << "Usage : " << argv[0] << "\n"; - return 1; - } - QANCollection_IndexedMapFunc aIndexedMap; - TestIndexedMap(aIndexedMap); - return 0; -} - -//======================================================================= -//function : QANColTestIndexedDataMap -//purpose : -//======================================================================= -static Standard_Integer QANColTestIndexedDataMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - if ( argc != 1) { - di << "Usage : " << argv[0] << "\n"; - return 1; - } - QANCollection_IDMapFunc aIDMap; - TestIndexedDataMap(aIDMap); - return 0; -} - -//======================================================================= -//function : QANColTestList -//purpose : -//======================================================================= -static Standard_Integer QANColTestList(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - if ( argc != 1) { - di << "Usage : " << argv[0] << "\n"; - return 1; - } - QANCollection_ListFunc aList; - TestList(aList); - return 0; -} - -//======================================================================= -//function : QANColTestSequence -//purpose : -//======================================================================= -static Standard_Integer QANColTestSequence(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - if ( argc != 1) { - di << "Usage : " << argv[0] << "\n"; - return 1; - } - QANCollection_SequenceFunc aSeq; - TestSequence(aSeq); - return 0; -} - -void QANCollection::Commands2(Draw_Interpretor& theCommands) { - const char *group = "QANCollection"; - - // from agvCollTest/src/CollectionEXE/FuncTestEXE.cxx - theCommands.Add("QANColTestArray1", "QANColTestArray1", __FILE__, QANColTestArray1, group); - theCommands.Add("QANColTestArray2", "QANColTestArray2", __FILE__, QANColTestArray2, group); - theCommands.Add("QANColTestMap", "QANColTestMap", __FILE__, QANColTestMap, group); - theCommands.Add("QANColTestDataMap", "QANColTestDataMap", __FILE__, QANColTestDataMap, group); - theCommands.Add("QANColTestDoubleMap", "QANColTestDoubleMap", __FILE__, QANColTestDoubleMap, group); - theCommands.Add("QANColTestIndexedMap", "QANColTestIndexedMap", __FILE__, QANColTestIndexedMap, group); - theCommands.Add("QANColTestIndexedDataMap", "QANColTestIndexedDataMap", __FILE__, QANColTestIndexedDataMap, group); - theCommands.Add("QANColTestList", "QANColTestList", __FILE__, QANColTestList, group); - theCommands.Add("QANColTestSequence", "QANColTestSequence", __FILE__, QANColTestSequence, group); - - return; -} diff --git a/src/QANCollection/QANCollection3.cxx b/src/QANCollection/QANCollection3.cxx deleted file mode 100644 index 9cc51f9825..0000000000 --- a/src/QANCollection/QANCollection3.cxx +++ /dev/null @@ -1,215 +0,0 @@ -// Created on: 2004-03-05 -// Created by: Mikhail KUZMITCHEV -// Copyright (c) 2004-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#include - -#include -#include - -#define ItemType gp_Pnt -#define Key1Type Standard_Real -#define Key2Type Standard_Integer - -#include - -#include - -IMPLEMENT_HARRAY1(QANCollection_HArray1Perf) -IMPLEMENT_HARRAY2(QANCollection_HArray2Perf) -IMPLEMENT_HSEQUENCE(QANCollection_HSequencePerf) - -//======================================================================= -//function : CheckArguments -//purpose : -//======================================================================= -Standard_Integer CheckArguments(Draw_Interpretor& di, Standard_Integer argc, const char ** argv, Standard_Integer& Repeat, Standard_Integer& Size) -{ - if ( argc != 3) { - di << "Usage : " << argv[0] << " Repeat Size" << "\n"; - return 1; - } - Repeat = Draw::Atoi(argv[1]); - Size = Draw::Atoi(argv[2]); - if ( Repeat < 1 ) { - di << "Repeat > 0" << "\n"; - return 1; - } - if ( Size < 1 ) { - di << "Size > 0" << "\n"; - return 1; - } - return 0; -} - - -//======================================================================= -//function : QANColPerfArray1 -//purpose : -//======================================================================= -static Standard_Integer QANColPerfArray1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - Standard_Integer Repeat, Size; - if ( CheckArguments(di, argc, argv, Repeat, Size) ) { - return 1; - } - CompArray1(Repeat,Size); - return 0; -} - -//======================================================================= -//function : QANColPerfArray2 -//purpose : -//======================================================================= -static Standard_Integer QANColPerfArray2(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - Standard_Integer Repeat, Size; - if ( CheckArguments(di, argc, argv, Repeat, Size) ) { - return 1; - } - CompArray2(Repeat,Size); - return 0; -} - -//======================================================================= -//function : QANColPerfList -//purpose : -//======================================================================= -static Standard_Integer QANColPerfList(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - Standard_Integer Repeat, Size; - if ( CheckArguments(di, argc, argv, Repeat, Size) ) { - return 1; - } - CompList(Repeat,Size); - return 0; -} - -//======================================================================= -//function : QANColPerfSequence -//purpose : -//======================================================================= -static Standard_Integer QANColPerfSequence(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - Standard_Integer Repeat, Size; - if ( CheckArguments(di, argc, argv, Repeat, Size) ) { - return 1; - } - CompSequence(Repeat,Size); - return 0; -} - -//======================================================================= -//function : QANColPerfMap -//purpose : -//======================================================================= -static Standard_Integer QANColPerfMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - Standard_Integer Repeat, Size; - if ( CheckArguments(di, argc, argv, Repeat, Size) ) { - return 1; - } - CompMap(Repeat,Size); - return 0; -} - -//======================================================================= -//function : QANColPerfDataMap -//purpose : -//======================================================================= -static Standard_Integer QANColPerfDataMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - Standard_Integer Repeat, Size; - if ( CheckArguments(di, argc, argv, Repeat, Size) ) { - return 1; - } - CompDataMap(Repeat,Size); - return 0; -} - -//======================================================================= -//function : QANColPerfDoubleMap -//purpose : -//======================================================================= -static Standard_Integer QANColPerfDoubleMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - Standard_Integer Repeat, Size; - if ( CheckArguments(di, argc, argv, Repeat, Size) ) { - return 1; - } - CompDoubleMap(Repeat,Size); - return 0; -} - -//======================================================================= -//function : QANColPerfIndexedMap -//purpose : -//======================================================================= -static Standard_Integer QANColPerfIndexedMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - Standard_Integer Repeat, Size; - if ( CheckArguments(di, argc, argv, Repeat, Size) ) { - return 1; - } - CompIndexedMap(Repeat,Size); - return 0; -} - -//======================================================================= -//function : QANColPerfIndexedDataMap -//purpose : -//======================================================================= -static Standard_Integer QANColPerfIndexedDataMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - Standard_Integer Repeat, Size; - if ( CheckArguments(di, argc, argv, Repeat, Size) ) { - return 1; - } - CompIndexedDataMap(Repeat,Size); - return 0; -} - -//======================================================================= -//function : QANColCheckSparseArray -//purpose : -//======================================================================= -static Standard_Integer QANColCheckSparseArray(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) -{ - Standard_Integer Repeat, Size; - if ( CheckArguments(di, argc, argv, Repeat, Size) ) { - return 1; - } - CompSparseArray(Repeat,Size); - return 0; -} - -void QANCollection::Commands3(Draw_Interpretor& theCommands) { - const char *group = "QANCollection"; - - // from agvCollTest/src/CollectionEXE/PerfTestEXE.cxx - theCommands.Add("QANColPerfArray1", "QANColPerfArray1 Repeat Size", __FILE__, QANColPerfArray1, group); - theCommands.Add("QANColPerfArray2", "QANColPerfArray2 Repeat Size", __FILE__, QANColPerfArray2, group); - theCommands.Add("QANColPerfList", "QANColPerfList Repeat Size", __FILE__, QANColPerfList, group); - theCommands.Add("QANColPerfSequence", "QANColPerfSequence Repeat Size", __FILE__, QANColPerfSequence, group); - theCommands.Add("QANColPerfMap", "QANColPerfMap Repeat Size", __FILE__, QANColPerfMap, group); - theCommands.Add("QANColPerfDataMap", "QANColPerfDataMap Repeat Size", __FILE__, QANColPerfDataMap, group); - theCommands.Add("QANColPerfDoubleMap", "QANColPerfDoubleMap Repeat Size", __FILE__, QANColPerfDoubleMap, group); - theCommands.Add("QANColPerfIndexedMap", "QANColPerfIndexedMap Repeat Size", __FILE__, QANColPerfIndexedMap, group); - theCommands.Add("QANColPerfIndexedDataMap", "QANColPerfIndexedDataMap Repeat Size", __FILE__, QANColPerfIndexedDataMap, group); - - theCommands.Add("QANColCheckSparseArray", "QANColCheckSparseArray Repeat Size", __FILE__, QANColCheckSparseArray, group); - - return; -} - diff --git a/src/QANCollection/QANCollectionTest.cxx b/src/QANCollection/QANCollectionTest.cxx deleted file mode 100644 index 855e17559d..0000000000 --- a/src/QANCollection/QANCollectionTest.cxx +++ /dev/null @@ -1,150 +0,0 @@ -// Created on: 2002-04-16 -// Created by: Alexander GRIGORIEV -// Copyright (c) 2002-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#include -#include - -#define USE_MACROS -#ifdef USE_MACROS -#include -#include -DEFINE_BASECOLLECTION (MyBaseCollPnt, gp_Pnt) -DEFINE_ARRAY1 (MyArray1, MyBaseCollPnt, gp_Pnt) -DEFINE_SEQUENCE (MySequence, MyBaseCollPnt, gp_Pnt) -#else -#include -#include -typedef NCollection_Array1 MyArray1; -typedef NCollection_Sequence MySequence; -typedef NCollection_BaseCollection MyBaseCollPnt; -#endif - -#define PERF_ENABLE_METERS -#include - -extern Handle(NCollection_BaseAllocator) getAlloc (const int i); - -const Standard_Integer REPEAT = 100; - -void createArray (TColgp_Array1OfPnt& anArrPnt) -{ - OSD_PerfMeter aPerfMeter("Create array"); - - for (Standard_Integer j = 0; j < 2*REPEAT; j++) { - PERF_START_METER("Create array") - for (Standard_Integer i = anArrPnt.Lower(); i <= anArrPnt.Upper(); i++) - anArrPnt(i).SetCoord ((double)i, (double)(i+1), (double)(i+2)); - PERF_STOP_METER("Create array") - } -} - -void createArray (MyArray1& anArrPnt) -{ - for (Standard_Integer j = 0; j < 2*REPEAT; j++) { - PERF_START_METER("Create array") - for (Standard_Integer i = anArrPnt.Lower(); i <= anArrPnt.Upper(); i++) - anArrPnt(i).SetCoord ((double)i, (double)(i+1), (double)(i+2)); - PERF_STOP_METER("Create array") - } -} - -void assignArray (TColgp_Array1OfPnt& aDest, const TColgp_Array1OfPnt& aSrc) -{ - for (Standard_Integer i = 0; i < 2*REPEAT; i++) { - PERF_START_METER("Assign array to array") - aDest = aSrc; - PERF_STOP_METER("Assign array to array") - } -} - -void assignCollection (MyBaseCollPnt& aDest, - const MyBaseCollPnt& aSrc, - const char * MeterName) -{ - for (Standard_Integer i = 0; i < REPEAT; i++) { - perf_start_meter (MeterName); -// if (getAlloc(1).IsNull() == Standard_False) -// if (getAlloc(1)->IsKind(STANDARD_TYPE(NCollection_IncAllocator))) -// Handle(NCollection_IncAllocator)::DownCast(getAlloc(1)) -> Clean(); - aDest.Assign(aSrc); - perf_stop_meter (MeterName); - } -} - -void assignArray (MyArray1& aDest, - const MyArray1& aSrc) -{ - for (Standard_Integer i = 0; i < 2*REPEAT; i++) { - PERF_START_METER("Assign array to array") - aDest = aSrc; - PERF_STOP_METER("Assign array to array") - } -} - -void createSequence (TColgp_SequenceOfPnt& aSeq) -{ - for (Standard_Integer j = 0; j < REPEAT; j++) { - PERF_START_METER("Clear sequence") - aSeq.Clear(); - PERF_STOP_METER("Clear sequence") - PERF_START_METER("Create sequence") - for (Standard_Integer i = 0; i < 100000; i++) - aSeq.Append (gp_Pnt((double)i, (double)(i+1), (double)(i+2))); - PERF_STOP_METER("Create sequence") - } -} - -void createSequence (MySequence& aSeq) -{ - for (Standard_Integer j = 0; j < REPEAT; j++) { - PERF_START_METER("Clear sequence") - aSeq.Clear(); -// if (getAlloc(0).IsNull() == Standard_False) -// if (getAlloc(0)->IsKind(STANDARD_TYPE(NCollection_IncAllocator))) -// Handle(NCollection_IncAllocator)::DownCast(getAlloc(0)) -> Clean(); - PERF_STOP_METER("Clear sequence") - PERF_START_METER("Create sequence") - for (Standard_Integer i = 0; i < 100000; i++) - aSeq.Append (gp_Pnt((double)i, (double)(i+1), (double)(i+2))); - PERF_STOP_METER("Create sequence") - } -} - -void assignSequence (TColgp_SequenceOfPnt& aDest, - const TColgp_SequenceOfPnt& aSrc) -{ - for (Standard_Integer i = 0; i < REPEAT; i++) { - PERF_START_METER("Assign sequence to sequence") - aDest = aSrc; - PERF_STOP_METER("Assign sequence to sequence") - } -} - -void assignSequence (MySequence& aDest, const MySequence& aSrc) -{ - for (Standard_Integer i = 0; i < REPEAT; i++) { - PERF_START_METER("Assign sequence to sequence") -// if (getAlloc(1).IsNull() == Standard_False) -// if (getAlloc(1)->IsKind(STANDARD_TYPE(NCollection_IncAllocator))) -// Handle(NCollection_IncAllocator)::DownCast(getAlloc(1)) -> Clean(); - aDest = aSrc; - PERF_STOP_METER("Assign sequence to sequence") - } -} - -void printAllMeters () -{ - PERF_PRINT_ALL -} diff --git a/src/QANCollection/QANCollection4.cxx b/src/QANCollection/QANCollection_Alloc.cxx similarity index 98% rename from src/QANCollection/QANCollection4.cxx rename to src/QANCollection/QANCollection_Alloc.cxx index e112d72882..13ab7f28b2 100644 --- a/src/QANCollection/QANCollection4.cxx +++ b/src/QANCollection/QANCollection_Alloc.cxx @@ -120,7 +120,7 @@ static Standard_Integer QANColStdAllocator2(Draw_Interpretor& di, Standard_Integ return 0; } -void QANCollection::Commands4(Draw_Interpretor& theCommands) { +void QANCollection::CommandsAlloc(Draw_Interpretor& theCommands) { const char *group = "QANCollection"; theCommands.Add("QANColStdAllocator1", "QANColStdAllocator1", __FILE__, QANColStdAllocator1, group); diff --git a/src/QANCollection/QANCollection_Common2.hxx b/src/QANCollection/QANCollection_Common2.hxx deleted file mode 100644 index 13ef67d9bb..0000000000 --- a/src/QANCollection/QANCollection_Common2.hxx +++ /dev/null @@ -1,187 +0,0 @@ -// Created on: 2002-05-15 -// Created by: Alexander KARTOMIN (akm) -// Copyright (c) 2002-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef QANCollection_Common2_HeaderFile -#define QANCollection_Common2_HeaderFile - -#include -#include - -#include - -// ===================== INSTANTIATIONS =========== -// ===================== The Types must be defined before this line =========== -// These are: TheItemType, TheKey1Type, TheKey2Type -// So must be defined ::HashCode and ::IsEqual too - -#if defined(ItemType) && defined(Key1Type) && defined(Key2Type) - -#include -////////////////////////////////DEFINE_BASECOLLECTION(QANCollection_BaseCol,ItemType) -////////////////////////////////DEFINE_BASECOLLECTION(QANCollection_Key1BaseCol,Key1Type) -////////////////////////////////DEFINE_BASECOLLECTION(QANCollection_Key2BaseCol,Key2Type) -DEFINE_BASECOLLECTION(QANCollection_BaseColFunc,ItemType) -DEFINE_BASECOLLECTION(QANCollection_Key1BaseColFunc,Key1Type) -DEFINE_BASECOLLECTION(QANCollection_Key2BaseColFunc,Key2Type) - -#include -#include -////////////////////////////////DEFINE_ARRAY1(QANCollection_Array1,QANCollection_BaseCol,ItemType) -////////////////////////////////DEFINE_HARRAY1(QANCollection_HArray1,QANCollection_Array1) -DEFINE_ARRAY1(QANCollection_Array1Func,QANCollection_BaseColFunc,ItemType) -DEFINE_HARRAY1(QANCollection_HArray1Func,QANCollection_Array1Func) - -#include -#include -////////////////////////////////DEFINE_ARRAY2(QANCollection_Array2,QANCollection_BaseCol,ItemType) -////////////////////////////////DEFINE_HARRAY2(QANCollection_HArray2,QANCollection_Array2) -DEFINE_ARRAY2(QANCollection_Array2Func,QANCollection_BaseColFunc,ItemType) -DEFINE_HARRAY2(QANCollection_HArray2Func,QANCollection_Array2Func) - -#include -#include -#include -#include -#include -////////////////////////////////DEFINE_MAP(QANCollection_Map,QANCollection_Key1BaseCol,Key1Type) -////////////////////////////////DEFINE_DATAMAP(QANCollection_DataMap,QANCollection_BaseCol,Key1Type,ItemType) -////////////////////////////////DEFINE_DOUBLEMAP(QANCollection_DoubleMap,QANCollection_Key2BaseCol,Key1Type,Key2Type) -////////////////////////////////DEFINE_INDEXEDMAP(QANCollection_IndexedMap,QANCollection_Key1BaseCol,Key1Type) -////////////////////////////////DEFINE_INDEXEDDATAMAP(QANCollection_IDMap,QANCollection_BaseCol,Key1Type,ItemType) -DEFINE_MAP(QANCollection_MapFunc,QANCollection_Key1BaseColFunc,Key1Type) -DEFINE_DATAMAP(QANCollection_DataMapFunc,QANCollection_BaseColFunc,Key1Type,ItemType) -DEFINE_DOUBLEMAP(QANCollection_DoubleMapFunc,QANCollection_Key2BaseColFunc,Key1Type,Key2Type) -DEFINE_INDEXEDMAP(QANCollection_IndexedMapFunc,QANCollection_Key1BaseColFunc,Key1Type) -DEFINE_INDEXEDDATAMAP(QANCollection_IDMapFunc,QANCollection_BaseColFunc,Key1Type,ItemType) - -#include -////////////////////////////////DEFINE_LIST(QANCollection_List,QANCollection_BaseCol,ItemType) -DEFINE_LIST(QANCollection_ListFunc,QANCollection_BaseColFunc,ItemType) - -#include -#include -////////////////////////////////DEFINE_SEQUENCE(QANCollection_Sequence,QANCollection_BaseCol,ItemType) -////////////////////////////////DEFINE_HSEQUENCE(QANCollection_HSequence,QANCollection_Sequence) -DEFINE_SEQUENCE(QANCollection_SequenceFunc,QANCollection_BaseColFunc,ItemType) -DEFINE_HSEQUENCE(QANCollection_HSequenceFunc,QANCollection_SequenceFunc) - - -// ===================== Type independent methods ============================= -////////////////////////////////void printCollection (QANCollection_BaseCol& aColl, -void printCollection (QANCollection_BaseColFunc& aColl, - const char * str) -{ - printf ("%s:\n",str); - Standard_Integer iSize = aColl.Size(); - ////////////////////////////////QANCollection_BaseCol::Iterator& anIter = aColl.CreateIterator(); - QANCollection_BaseColFunc::Iterator& anIter = aColl.CreateIterator(); - if (!anIter.More()) - { - if (iSize==0) - printf (" \n"); - else - printf ("Error : empty collection has size==%d",iSize); - } - else - { - printf (" Size==%d\n",iSize); - for (; anIter.More(); anIter.Next()) - PrintItem(anIter.Value()); - } -} - -////////////////////////////////void printCollection (QANCollection_Key1BaseCol& aColl, -#if 0 -void printCollection (QANCollection_Key1BaseColFunc& aColl, - const char * str) -{ - printf ("%s:\n",str); - Standard_Integer iSize = aColl.Size(); - ////////////////////////////////QANCollection_Key1BaseCol::Iterator& anIter = aColl.CreateIterator(); - QANCollection_Key1BaseColFunc::Iterator& anIter = aColl.CreateIterator(); - if (!anIter.More()) - { - if (iSize==0) - printf (" \n"); - else - printf ("Error : empty collection has size==%d",iSize); - } - else - { - printf (" Size==%d\n",iSize); - for (; anIter.More(); anIter.Next()) - PrintItem(anIter.Value()); - } -} -#endif - -////////////////////////////////void printCollection (QANCollection_Key2BaseCol& aColl, -void printCollection (QANCollection_Key2BaseColFunc& aColl, - const char * str) -{ - printf ("%s:\n",str); - Standard_Integer iSize = aColl.Size(); - ////////////////////////////////QANCollection_Key2BaseCol::Iterator& anIter = aColl.CreateIterator(); - QANCollection_Key2BaseColFunc::Iterator& anIter = aColl.CreateIterator(); - if (!anIter.More()) - { - if (iSize==0) - printf (" \n"); - else - printf ("Error : empty collection has size==%d",iSize); - } - else - { - printf (" Size==%d\n",iSize); - for (; anIter.More(); anIter.Next()) - PrintItem(anIter.Value()); - } -} - -////////////////////////////////void AssignCollection (QANCollection_BaseCol& aCollSrc, -//////////////////////////////// QANCollection_BaseCol& aCollDst) -void AssignCollection (QANCollection_BaseColFunc& aCollSrc, - QANCollection_BaseColFunc& aCollDst) -{ - printCollection (aCollSrc,"Source collection"); - aCollDst.Assign(aCollSrc); - printCollection (aCollDst,"Target collection"); -} - -////////////////////////////////void AssignCollection (QANCollection_Key1BaseCol& aCollSrc, -//////////////////////////////// QANCollection_Key1BaseCol& aCollDst) -#if 0 -void AssignCollection (QANCollection_Key1BaseColFunc& aCollSrc, - QANCollection_Key1BaseColFunc& aCollDst) -{ - printCollection (aCollSrc,"Source collection"); - aCollDst.Assign(aCollSrc); - printCollection (aCollDst,"Target collection"); -} -#endif - -////////////////////////////////void AssignCollection (QANCollection_Key2BaseCol& aCollSrc, -//////////////////////////////// QANCollection_Key2BaseCol& aCollDst) -void AssignCollection (QANCollection_Key2BaseColFunc& aCollSrc, - QANCollection_Key2BaseColFunc& aCollDst) -{ - printCollection (aCollSrc,"Source collection"); - aCollDst.Assign(aCollSrc); - printCollection (aCollDst,"Target collection"); -} - -#endif - -#endif diff --git a/src/QANCollection/QANCollection_Common3.hxx b/src/QANCollection/QANCollection_Common3.hxx deleted file mode 100644 index 7a33601e46..0000000000 --- a/src/QANCollection/QANCollection_Common3.hxx +++ /dev/null @@ -1,185 +0,0 @@ -// Created on: 2002-05-15 -// Created by: Alexander KARTOMIN (akm) -// Copyright (c) 2002-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef QANCollection_Common3_HeaderFile -#define QANCollection_Common3_HeaderFile - -#include -#include - -#include - -// ===================== INSTANTIATIONS =========== -// ===================== The Types must be defined before this line =========== -// These are: TheItemType, TheKey1Type, TheKey2Type -// So must be defined ::HashCode and ::IsEqual too - -#if defined(ItemType) && defined(Key1Type) && defined(Key2Type) - -#include -////////////////////////////////DEFINE_BASECOLLECTION(QANCollection_BaseCol,ItemType) -////////////////////////////////DEFINE_BASECOLLECTION(QANCollection_Key1BaseCol,Key1Type) -////////////////////////////////DEFINE_BASECOLLECTION(QANCollection_Key2BaseCol,Key2Type) -DEFINE_BASECOLLECTION(QANCollection_BaseColPerf,ItemType) -DEFINE_BASECOLLECTION(QANCollection_Key1BaseColPerf,Key1Type) -DEFINE_BASECOLLECTION(QANCollection_Key2BaseColPerf,Key2Type) - -#include -#include -////////////////////////////////DEFINE_ARRAY1(QANCollection_Array1,QANCollection_BaseCol,ItemType) -////////////////////////////////DEFINE_HARRAY1(QANCollection_HArray1,QANCollection_Array1) -DEFINE_ARRAY1(QANCollection_Array1Perf,QANCollection_BaseColPerf,ItemType) -DEFINE_HARRAY1(QANCollection_HArray1Perf,QANCollection_Array1Perf) - -#include -#include -////////////////////////////////DEFINE_ARRAY2(QANCollection_Array2,QANCollection_BaseCol,ItemType) -////////////////////////////////DEFINE_HARRAY2(QANCollection_HArray2,QANCollection_Array2) -DEFINE_ARRAY2(QANCollection_Array2Perf,QANCollection_BaseColPerf,ItemType) -DEFINE_HARRAY2(QANCollection_HArray2Perf,QANCollection_Array2Perf) - -#include -#include -#include -#include -#include -////////////////////////////////DEFINE_MAP(QANCollection_Map,QANCollection_Key1BaseCol,Key1Type) -////////////////////////////////DEFINE_DATAMAP(QANCollection_DataMap,QANCollection_BaseCol,Key1Type,ItemType) -////////////////////////////////DEFINE_DOUBLEMAP(QANCollection_DoubleMap,QANCollection_Key2BaseCol,Key1Type,Key2Type) -////////////////////////////////DEFINE_INDEXEDMAP(QANCollection_IndexedMap,QANCollection_Key1BaseCol,Key1Type) -////////////////////////////////DEFINE_INDEXEDDATAMAP(QANCollection_IDMap,QANCollection_BaseCol,Key1Type,ItemType) -DEFINE_MAP(QANCollection_MapPerf,QANCollection_Key1BaseColPerf,Key1Type) -DEFINE_DATAMAP(QANCollection_DataMapPerf,QANCollection_BaseColPerf,Key1Type,ItemType) -DEFINE_DOUBLEMAP(QANCollection_DoubleMapPerf,QANCollection_Key2BaseColPerf,Key1Type,Key2Type) -DEFINE_INDEXEDMAP(QANCollection_IndexedMapPerf,QANCollection_Key1BaseColPerf,Key1Type) -DEFINE_INDEXEDDATAMAP(QANCollection_IDMapPerf,QANCollection_BaseColPerf,Key1Type,ItemType) - -#include -////////////////////////////////DEFINE_LIST(QANCollection_List,QANCollection_BaseCol,ItemType) -DEFINE_LIST(QANCollection_ListPerf,QANCollection_BaseColPerf,ItemType) - -#include -#include -////////////////////////////////DEFINE_SEQUENCE(QANCollection_Sequence,QANCollection_BaseCol,ItemType) -////////////////////////////////DEFINE_HSEQUENCE(QANCollection_HSequence,QANCollection_Sequence) -DEFINE_SEQUENCE(QANCollection_SequencePerf,QANCollection_BaseColPerf,ItemType) -DEFINE_HSEQUENCE(QANCollection_HSequencePerf,QANCollection_SequencePerf) - - -// ===================== Type independent methods ============================= -////////////////////////////////void printCollection (QANCollection_BaseCol& aColl, -#if 0 -void printCollection (QANCollection_BaseColPerf& aColl, - const char * str) -{ - printf ("%s:\n",str); - Standard_Integer iSize = aColl.Size(); - ////////////////////////////////QANCollection_BaseCol::Iterator& anIter = aColl.CreateIterator(); - QANCollection_BaseColPerf::Iterator& anIter = aColl.CreateIterator(); - if (!anIter.More()) - { - if (iSize==0) - printf (" \n"); - else - printf ("Error : empty collection has size==%d",iSize); - } - else - { - printf (" Size==%d\n",iSize); - for (; anIter.More(); anIter.Next()) - PrintItem(anIter.Value()); - } -} - -////////////////////////////////void printCollection (QANCollection_Key1BaseCol& aColl, -void printCollection (QANCollection_Key1BaseColPerf& aColl, - const char * str) -{ - printf ("%s:\n",str); - Standard_Integer iSize = aColl.Size(); - ////////////////////////////////QANCollection_Key1BaseCol::Iterator& anIter = aColl.CreateIterator(); - QANCollection_Key1BaseColPerf::Iterator& anIter = aColl.CreateIterator(); - if (!anIter.More()) - { - if (iSize==0) - printf (" \n"); - else - printf ("Error : empty collection has size==%d",iSize); - } - else - { - printf (" Size==%d\n",iSize); - for (; anIter.More(); anIter.Next()) - PrintItem(anIter.Value()); - } -} - -////////////////////////////////void printCollection (QANCollection_Key2BaseCol& aColl, -void printCollection (QANCollection_Key2BaseColPerf& aColl, - const char * str) -{ - printf ("%s:\n",str); - Standard_Integer iSize = aColl.Size(); - ////////////////////////////////QANCollection_Key2BaseCol::Iterator& anIter = aColl.CreateIterator(); - QANCollection_Key2BaseColPerf::Iterator& anIter = aColl.CreateIterator(); - if (!anIter.More()) - { - if (iSize==0) - printf (" \n"); - else - printf ("Error : empty collection has size==%d",iSize); - } - else - { - printf (" Size==%d\n",iSize); - for (; anIter.More(); anIter.Next()) - PrintItem(anIter.Value()); - } -} - -////////////////////////////////void AssignCollection (QANCollection_BaseCol& aCollSrc, -//////////////////////////////// QANCollection_BaseCol& aCollDst) -void AssignCollection (QANCollection_BaseColPerf& aCollSrc, - QANCollection_BaseColPerf& aCollDst) -{ - printCollection (aCollSrc,"Source collection"); - aCollDst.Assign(aCollSrc); - printCollection (aCollDst,"Target collection"); -} - -////////////////////////////////void AssignCollection (QANCollection_Key1BaseCol& aCollSrc, -//////////////////////////////// QANCollection_Key1BaseCol& aCollDst) -void AssignCollection (QANCollection_Key1BaseColPerf& aCollSrc, - QANCollection_Key1BaseColPerf& aCollDst) -{ - printCollection (aCollSrc,"Source collection"); - aCollDst.Assign(aCollSrc); - printCollection (aCollDst,"Target collection"); -} - -////////////////////////////////void AssignCollection (QANCollection_Key2BaseCol& aCollSrc, -//////////////////////////////// QANCollection_Key2BaseCol& aCollDst) -void AssignCollection (QANCollection_Key2BaseColPerf& aCollSrc, - QANCollection_Key2BaseColPerf& aCollDst) -{ - printCollection (aCollSrc,"Source collection"); - aCollDst.Assign(aCollSrc); - printCollection (aCollDst,"Target collection"); -} -#endif - -#endif - -#endif diff --git a/src/QANCollection/QANCollection_FuncArrays.hxx b/src/QANCollection/QANCollection_FuncArrays.hxx deleted file mode 100644 index f1f6dfd149..0000000000 --- a/src/QANCollection/QANCollection_FuncArrays.hxx +++ /dev/null @@ -1,92 +0,0 @@ -// Created on: 2002-04-30 -// Created by: Alexander KARTOMIN (akm) -// Copyright (c) 2002-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef QANCollection_FuncArrays_HeaderFile -#define QANCollection_FuncArrays_HeaderFile - -// ===================== Test methods of Array1 type ========================== -////////////////////////////////void TestArray1 (QANCollection_Array1& theA1) -void TestArray1 (QANCollection_Array1Func& theA1) -{ - // Bounds - Standard_Integer iLow=theA1.Lower(); - Standard_Integer iUpp=theA1.Upper(); - Standard_Integer i; - - printf ("Info: testing Array1(%d,%d), %s\n", - iLow, iUpp, (theA1.IsDeletable()?"deletable":"frozen")); - // C-array constructor, Length, Init - ItemType anItem; - Random(anItem); - theA1.Init (anItem); - ItemType * rBlock = new ItemType[theA1.Length()]; - ////////////////////////////////QANCollection_Array1 aCArr(*rBlock, iLow-100, iUpp-100); - QANCollection_Array1Func aCArr(*rBlock, iLow-100, iUpp-100); - printf (" created the same sized preallocated array (%d,%d), %s\n", - aCArr.Lower(),aCArr.Upper(),(aCArr.IsDeletable()?"deletable":"frozen")); - // *Value, operator() - for (i=iLow+1; iChangeArray1(), theA1); -} - -// ===================== Test methods of Array2 type ========================== -////////////////////////////////void TestArray2 (QANCollection_Array2& theA2) -void TestArray2 (QANCollection_Array2Func& theA2) -{ - // Bounds - Standard_Integer iLR=theA2.LowerRow(), iLC=theA2.LowerCol(); - Standard_Integer iUR=theA2.UpperRow(), iUC=theA2.UpperCol(); - Standard_Integer i,j; - - printf ("Info: testing Array2 (%d,%d)(%d,%d), %s\n", - iLR, iUR, iLC, iUC, (theA2.IsDeletable()?"deletable":"frozen")); - // C-array constructor, Length, Init, RowLength, ColLength - ItemType anItem; - Random(anItem); - theA2.Init (anItem); - ItemType * rBlock = new ItemType[theA2.Length()]; - ////////////////////////////////QANCollection_Array2 aCArr(*rBlock, iLR-100, iUR-100, iLC, iUC); - QANCollection_Array2Func aCArr(*rBlock, iLR-100, iUR-100, iLC, iUC); - printf (" created the same sized preallocated array (%d*%d), %s\n", - aCArr.RowLength(), aCArr.ColLength(), - (aCArr.IsDeletable()?"deletable":"frozen")); - // *Value, operator() - for (i=iLR+1; iChangeArray2(), theA2); -} - -#endif diff --git a/src/QANCollection/QANCollection_FuncLists.hxx b/src/QANCollection/QANCollection_FuncLists.hxx deleted file mode 100644 index b7e69409e4..0000000000 --- a/src/QANCollection/QANCollection_FuncLists.hxx +++ /dev/null @@ -1,129 +0,0 @@ -// Created on: 2002-04-30 -// Created by: Alexander KARTOMIN (akm) -// Copyright (c) 2002-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef QANCollection_FuncLists_HeaderFile -#define QANCollection_FuncLists_HeaderFile - -// ===================== Test methods of List type ========================== -////////////////////////////////void TestList (QANCollection_List& theL) -void TestList (QANCollection_ListFunc& theL) -{ - // Extent - Standard_Integer iExt=theL.Extent(); - Standard_Integer i; - - printf ("Info: testing List(%d)\n", iExt); - // Append(2), Prepend(2), InsertBefore(2), InsertAfter(2), - // Remove, RemoveFirst, First, Last - ItemType anItem; - ////////////////////////////////QANCollection_List aL, aL1; - QANCollection_ListFunc aL, aL1; - for (i=0; i<4; i++) - { - Random (anItem); - aL.Append (anItem); // #1 - aL.Append (aL1); // #2 - Random (anItem); - aL1.Prepend (anItem); // #3 - aL1.Prepend (aL); // #4 - ////////////////////////////////QANCollection_List::Iterator anI(theL); - QANCollection_ListFunc::Iterator anI(theL); - if (anI.More()) - { - Random (anItem); - theL.InsertBefore (anItem, anI); // #5 - theL.InsertBefore (aL1, anI); // #6 - Random (anItem); - theL.InsertAfter (anItem, anI); // #7 - theL.InsertAfter (aL, anI); // #8 - theL.Remove (anI); // #9 - if (theL.Extent() > 0) - theL.RemoveFirst(); // #10 - } - else - { - theL.Prepend (anItem); - PrintItem(theL.First()); - PrintItem(theL.Last()); - } - } - // Copy constructor + operator= - ////////////////////////////////aL = QANCollection_List(theL); - aL = QANCollection_ListFunc(theL); - - // Assign - AssignCollection (theL, aL); - - // Clear - aL.Clear(); -} - -// ===================== Test methods of Sequence type ======================== -////////////////////////////////void TestSequence (QANCollection_Sequence& theS) -void TestSequence (QANCollection_SequenceFunc& theS) -{ - Standard_Integer i; - - printf ("Info: testing Sequence\n"); - // Append(2) - ItemType anItem; - ////////////////////////////////QANCollection_Sequence aS, aS1; - QANCollection_SequenceFunc aS, aS1; - // Append(2), Prepend(2), InsertBefore(2), InsertAfter(2), - // Remove, RemoveFirst, First, Last - for (i=0; i<4; i++) - { - Random (anItem); - aS.Append (anItem); // #1 - aS.Append (aS1); // #2 - Random (anItem); - aS1.Prepend (anItem); // #3 - aS1.Prepend (aS); // #4 - if (theS.Length() > 0) - { - Random (anItem); - theS.InsertBefore (1, anItem); // #5 - theS.InsertBefore (2, aS1); // #6 - Random (anItem); - theS.InsertAfter (1, anItem); // #7 - theS.InsertAfter (2, aS); // #8 - theS.Remove (1); // #9 - if (theS.Length() > 0) - theS.Remove(1); // #10 - } - else - { - theS.Prepend (anItem); - PrintItem(theS.First()); - PrintItem(theS.Last()); - } - } - - // () - PrintItem(theS(1)); - - // Handle, Split - ////////////////////////////////Handle(QANCollection_HSequence) aHS = new QANCollection_HSequence(aS1); - Handle(QANCollection_HSequenceFunc) aHS = new QANCollection_HSequenceFunc(aS1); - theS.Split (3, aHS->ChangeSequence()); - - // Assign - AssignCollection (theS, aS); - - // Clear - aS.Clear(); -} - -#endif diff --git a/src/QANCollection/QANCollection_FuncMaps.hxx b/src/QANCollection/QANCollection_FuncMaps.hxx deleted file mode 100644 index 247963c084..0000000000 --- a/src/QANCollection/QANCollection_FuncMaps.hxx +++ /dev/null @@ -1,287 +0,0 @@ -// Created on: 2002-04-30 -// Created by: Alexander KARTOMIN (akm) -// Copyright (c) 2002-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef QANCollection_FuncMaps_HeaderFile -#define QANCollection_FuncMaps_HeaderFile - -// ===================== Test methods of Map type ============================= -////////////////////////////////void TestMap (QANCollection_Map& theM) -void TestMap (QANCollection_MapFunc& theM) -{ - // Extent - Standard_Integer iExt=theM.Extent(); - Standard_Integer i; - - printf ("Info: testing Map(l=%d)\n", iExt); - theM.Statistics(cout); - // Resize - theM.ReSize(8); - theM.Statistics(cout); - cout.flush(); - // Constructor - ////////////////////////////////QANCollection_Map aM; - QANCollection_MapFunc aM; - // Add - Key1Type aKey; - for (i=0; i<8; i++) - { - Random (aKey); - aM.Add (aKey); - } - // Contains, Remove - if (!aM.Contains(aKey)) - { - printf("Error : map says that it does not contain its key "); - PrintItem(aKey); - } - else - { - aM.Remove(aKey); - printf(" successfully removed item, l=%d\n", aM.Size()); - } - // Copy constructor (including operator=) - ////////////////////////////////QANCollection_Map aM2 = QANCollection_Map(aM); - QANCollection_MapFunc aM2 = QANCollection_MapFunc(aM); - // Assign - AssignCollection (aM2,theM); - - // Clear - aM.Clear(); -} - -// ===================== Test methods of DataMap type ========================= -////////////////////////////////void TestDataMap (QANCollection_DataMap& theM) -void TestDataMap (QANCollection_DataMapFunc& theM) -{ - // Extent - Standard_Integer iExt=theM.Extent(); - Standard_Integer i; - - printf ("Info: testing DataMap(l=%d)\n", iExt); - theM.Statistics(cout); - // Resize - theM.ReSize(8); - theM.Statistics(cout); - cout.flush(); - // Constructor - ////////////////////////////////QANCollection_DataMap aM; - QANCollection_DataMapFunc aM; - // Bind, Find, ChangeFind, () - Key1Type aKey; - ItemType anItem; - for (i=0; i<8; i++) - { - Random (aKey); - Random (anItem); - aM.Bind (aKey, anItem); - PrintItem(aM.Find(aKey)); - Random(aM(aKey)); - } - // IsBound, UnBind - if (!aM.IsBound(aKey)) - { - printf("Error : map says that it does not contain its key "); - PrintItem(aKey); - } - else - { - aM.UnBind(aKey); - printf(" successfully unbound the key, l=%d\n", aM.Size()); - } - // Copy constructor (including operator=) - ////////////////////////////////theM = QANCollection_DataMap(aM); - theM = QANCollection_DataMapFunc(aM); - // Assign - prohibited - // AssignCollection (aM2,theM); - printCollection (theM, "DataMap:"); - - // Clear - aM.Clear(); -} - - -// ===================== Test methods of DoubleMap type ======================= -////////////////////////////////void TestDoubleMap (QANCollection_DoubleMap& theM) -void TestDoubleMap (QANCollection_DoubleMapFunc& theM) -{ - // Extent - Standard_Integer iExt=theM.Extent(); - Standard_Integer i; - - printf ("Info: testing DoubleMap(l=%d)\n", iExt); - theM.Statistics(cout); - // Resize - theM.ReSize(8); - theM.Statistics(cout); - cout.flush(); - // Constructor - ////////////////////////////////QANCollection_DoubleMap aM; - QANCollection_DoubleMapFunc aM; - // Bind, Find?, - Key1Type aKey1; - Key2Type aKey2; - for (i=0; i<8; i++) - { - Random (aKey1); - Random (aKey2); - aM.Bind (aKey1, aKey2); - PrintItem(aM.Find1(aKey1)); - if (!aM.IsBound1(aKey1)) - { - printf("Error : map says that it does not contain its key "); - PrintItem(aKey1); - } - PrintItem(aM.Find2(aKey2)); - if (!aM.IsBound2(aKey2)) - { - printf("Error : map says that it does not contain its key "); - PrintItem(aKey2); - } - } - // AreBound, UnBind - if (!aM.AreBound(aKey1,aKey2)) - { - printf("Error : map says that it does not contain its keys "); - PrintItem(aKey1); - PrintItem(aKey2); - } - else - { - if (aM.UnBind2(aKey2)) - printf(" successfully unbound the key, l=%d\n", aM.Size()); - if (aM.UnBind1(aKey1)) - printf("Error : unbound both keys?!\n"); - } - // Copy constructor (including operator=) - ////////////////////////////////theM = QANCollection_DoubleMap(aM); - theM = QANCollection_DoubleMapFunc(aM); - // Assign - prohibited - // AssignCollection (aM2,theM); - printCollection (theM, "DoubleMap:"); - - // Clear - aM.Clear(); -} - -// ===================== Test methods of IndexedMap type ====================== -////////////////////////////////void TestIndexedMap (QANCollection_IndexedMap& theM) -void TestIndexedMap (QANCollection_IndexedMapFunc& theM) -{ - // Extent - Standard_Integer iExt=theM.Extent(); - Standard_Integer i; - - printf ("Info: testing IndexedMap(l=%d)\n", iExt); - theM.Statistics(cout); - // Resize - theM.ReSize(8); - theM.Statistics(cout); - cout.flush(); - // Constructor - ////////////////////////////////QANCollection_IndexedMap aM; - QANCollection_IndexedMapFunc aM; - // Add, FindKey, FindIndex - Key1Type aKey; - for (i=0; i<8; i++) - { - Random (aKey); - aM.Add (aKey); - Standard_Integer iIndex=aM.FindIndex(aKey); - printf (" added a key, i=%d, k=",iIndex); - PrintItem(aM(iIndex)); - } - // Contains, Remove - if (!aM.Contains(aM.FindKey(aM.FindIndex(aKey)))) - { - printf("Error : map says that it does not contain its key "); - PrintItem(aKey); - } - else - { - aM.RemoveLast(); - printf(" successfully removed item, l=%d\n", aM.Size()); - } - // Substitute - Random(aKey); - aM.Substitute(1,aKey); - // Copy constructor (including operator=) - ////////////////////////////////QANCollection_IndexedMap aM2 = QANCollection_IndexedMap(aM); - QANCollection_IndexedMapFunc aM2 = QANCollection_IndexedMapFunc(aM); - // Assign - AssignCollection (aM2,theM); - - // Clear - aM.Clear(); -} - -// ===================== Test methods of IndexedDataMap type ================== -////////////////////////////////void TestIndexedDataMap (QANCollection_IDMap& theM) -void TestIndexedDataMap (QANCollection_IDMapFunc& theM) -{ - // Extent - Standard_Integer iExt=theM.Extent(); - Standard_Integer i; - - printf ("Info: testing IndexedDataMap(l=%d)\n", iExt); - theM.Statistics(cout); - // Resize - theM.ReSize(8); - theM.Statistics(cout); - cout.flush(); - // Constructor - ////////////////////////////////QANCollection_IDMap aM; - QANCollection_IDMapFunc aM; - // Add, FindKey, FindIndex, FindFromIndex, Change..., () - Key1Type aKey; - ItemType anItem; - for (i=0; i<8; i++) - { - Random (aKey); - Random (anItem); - aM.Add (aKey, anItem); - Standard_Integer iIndex=aM.FindIndex(aKey); - printf (" added a key, i=%d, k=",iIndex); - PrintItem(aM.FindKey(iIndex)); - PrintItem(aM(iIndex)); - Random(aM.ChangeFromIndex(iIndex)); - } - // Contains, Remove, FindFromKey - if (!aM.Contains(aM.FindKey(aM.FindIndex(aKey)))) - { - printf("Error : map says that it does not contain its key "); - PrintItem(aKey); - } - else - { - anItem = aM.FindFromKey(aKey); - aM.RemoveLast(); - printf(" successfully removed item, l=%d\n", aM.Size()); - } - // Substitute - Random(aKey); - aM.Substitute (1, aKey, anItem); - // Copy constructor (including operator=) - ////////////////////////////////theM = QANCollection_IDMap(aM); - theM = QANCollection_IDMapFunc(aM); - // Assign - prohibited - // AssignCollection (aM2,theM); - printCollection (theM, "DoubleMap:"); - - // Clear - aM.Clear(); -} - - -#endif diff --git a/src/QANCollection/QANCollection_FuncTest.hxx b/src/QANCollection/QANCollection_FuncTest.hxx deleted file mode 100644 index 781cacceb8..0000000000 --- a/src/QANCollection/QANCollection_FuncTest.hxx +++ /dev/null @@ -1,40 +0,0 @@ -// Created on: 2002-04-30 -// Created by: Alexander KARTOMIN (akm) -// Copyright (c) 2002-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -// Purpose: To test all methods of all NCollection classes - -#ifndef QANCollection_FuncTest_HeaderFile -#define QANCollection_FuncTest_HeaderFile - -#include - -// ===================== Test methods for each type =========================== -// Parameters of funcs below must be empty collections - -// Standard_EXPORT void TestArray1 (QANCollection_Array1& theA1); -// Standard_EXPORT void TestArray2 (QANCollection_Array2& theA2); -#include -// Standard_EXPORT void TestMap (QANCollection_Map& theM ); -// Standard_EXPORT void TestDataMap (QANCollection_DataMap& theDM); -// Standard_EXPORT void TestDblMap (QANCollection_DoubleMap& theBM); -// Standard_EXPORT void TestIndyMap (QANCollection_IndexedMap& theIM); -// Standard_EXPORT void TestInDaMap (QANCollection_IDMap& theNM); -// Standard_EXPORT void TestInDaMap (QANCollection_IDMap& theNM); -#include -// Standard_EXPORT void TestList (QANCollection_List& theLi); -// Standard_EXPORT void TestSequence(QANCollection_Sequence& theSq); -#include - -#endif diff --git a/src/QANCollection/QANCollection_Perf.cxx b/src/QANCollection/QANCollection_Perf.cxx new file mode 100644 index 0000000000..c00d33ce32 --- /dev/null +++ b/src/QANCollection/QANCollection_Perf.cxx @@ -0,0 +1,1156 @@ +// Created on: 2004-03-05 +// Created by: Mikhail KUZMITCHEV +// Copyright (c) 2004-2014 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include + +#include +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include + +#define PERF_ENABLE_METERS +#include + +#define ItemType gp_Pnt +#define Key1Type Standard_Real +#define Key2Type Standard_Integer + +// ===================== INSTANTIATIONS =========== +// ===================== The Types must be defined before this line =========== +// These are: TheItemType, TheKey1Type, TheKey2Type +// So must be defined ::HashCode and ::IsEqual too + +#include +#include +////////////////////////////////DEFINE_ARRAY1(QANCollection_Array1,QANCollection_BaseCol,ItemType) +////////////////////////////////DEFINE_HARRAY1(QANCollection_HArray1,QANCollection_Array1) +DEFINE_ARRAY1(QANCollection_Array1Perf,QANCollection_BaseColPerf,ItemType) +DEFINE_HARRAY1(QANCollection_HArray1Perf,QANCollection_Array1Perf) +IMPLEMENT_HARRAY1(QANCollection_HArray1Perf) + +#include +#include +////////////////////////////////DEFINE_ARRAY2(QANCollection_Array2,QANCollection_BaseCol,ItemType) +////////////////////////////////DEFINE_HARRAY2(QANCollection_HArray2,QANCollection_Array2) +DEFINE_ARRAY2(QANCollection_Array2Perf,QANCollection_BaseColPerf,ItemType) +DEFINE_HARRAY2(QANCollection_HArray2Perf,QANCollection_Array2Perf) +IMPLEMENT_HARRAY2(QANCollection_HArray2Perf) + +#include +#include +#include +#include +#include +////////////////////////////////DEFINE_MAP(QANCollection_Map,QANCollection_Key1BaseCol,Key1Type) +////////////////////////////////DEFINE_DATAMAP(QANCollection_DataMap,QANCollection_BaseCol,Key1Type,ItemType) +////////////////////////////////DEFINE_DOUBLEMAP(QANCollection_DoubleMap,QANCollection_Key2BaseCol,Key1Type,Key2Type) +////////////////////////////////DEFINE_INDEXEDMAP(QANCollection_IndexedMap,QANCollection_Key1BaseCol,Key1Type) +////////////////////////////////DEFINE_INDEXEDDATAMAP(QANCollection_IDMap,QANCollection_BaseCol,Key1Type,ItemType) +DEFINE_MAP(QANCollection_MapPerf,QANCollection_Key1BaseColPerf,Key1Type) +DEFINE_DATAMAP(QANCollection_DataMapPerf,QANCollection_BaseColPerf,Key1Type,ItemType) +DEFINE_DOUBLEMAP(QANCollection_DoubleMapPerf,QANCollection_Key2BaseColPerf,Key1Type,Key2Type) +DEFINE_INDEXEDMAP(QANCollection_IndexedMapPerf,QANCollection_Key1BaseColPerf,Key1Type) +DEFINE_INDEXEDDATAMAP(QANCollection_IDMapPerf,QANCollection_BaseColPerf,Key1Type,ItemType) + +#include +////////////////////////////////DEFINE_LIST(QANCollection_List,QANCollection_BaseCol,ItemType) +DEFINE_LIST(QANCollection_ListPerf,QANCollection_BaseColPerf,ItemType) + +#include +#include +////////////////////////////////DEFINE_SEQUENCE(QANCollection_Sequence,QANCollection_BaseCol,ItemType) +////////////////////////////////DEFINE_HSEQUENCE(QANCollection_HSequence,QANCollection_Sequence) +DEFINE_SEQUENCE(QANCollection_SequencePerf,QANCollection_BaseColPerf,ItemType) +DEFINE_HSEQUENCE(QANCollection_HSequencePerf,QANCollection_SequencePerf) +IMPLEMENT_HSEQUENCE(QANCollection_HSequencePerf) + +// ===================== Test perform of Array1 type ========================== +static void CompArray1 (const Standard_Integer theRep, + const Standard_Integer theSize) +{ + Standard_Integer i,j; + + ////////////////////////////////Perf_Meter aNCrea ("NCollection_Array1 creation",0); + ////////////////////////////////Perf_Meter aTCrea ("TCollection_Array1 creation",0); + ////////////////////////////////Perf_Meter aNFill ("NCollection_Array1 filling",0); + ////////////////////////////////Perf_Meter aTFill ("TCollection_Array1 filling",0); + ////////////////////////////////Perf_Meter aNFind ("NCollection_Array1 finding",0); + ////////////////////////////////Perf_Meter aTFind ("TCollection_Array1 finding",0); + ////////////////////////////////Perf_Meter aNOper ("NCollection_Array1 operator=",0); + ////////////////////////////////Perf_Meter aTOper ("TCollection_Array1 operator=",0); + ////////////////////////////////Perf_Meter aNAssi ("NCollection_Array1 Assign",0); + for (i=0; i a1(theSize),a2(theSize); + + PERF_STOP_METER("NCollection_SparseArray creation") + + PERF_START_METER("NCollection_SparseArray filling") + for( j=0;j 0" << "\n"; + return 1; + } + if ( Size < 1 ) { + di << "Size > 0" << "\n"; + return 1; + } + return 0; +} + + +//======================================================================= +//function : QANColPerfArray1 +//purpose : +//======================================================================= +static Standard_Integer QANColPerfArray1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) +{ + Standard_Integer Repeat, Size; + if ( CheckArguments(di, argc, argv, Repeat, Size) ) { + return 1; + } + CompArray1(Repeat,Size); + return 0; +} + +//======================================================================= +//function : QANColPerfArray2 +//purpose : +//======================================================================= +static Standard_Integer QANColPerfArray2(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) +{ + Standard_Integer Repeat, Size; + if ( CheckArguments(di, argc, argv, Repeat, Size) ) { + return 1; + } + CompArray2(Repeat,Size); + return 0; +} + +//======================================================================= +//function : QANColPerfList +//purpose : +//======================================================================= +static Standard_Integer QANColPerfList(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) +{ + Standard_Integer Repeat, Size; + if ( CheckArguments(di, argc, argv, Repeat, Size) ) { + return 1; + } + CompList(Repeat,Size); + return 0; +} + +//======================================================================= +//function : QANColPerfSequence +//purpose : +//======================================================================= +static Standard_Integer QANColPerfSequence(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) +{ + Standard_Integer Repeat, Size; + if ( CheckArguments(di, argc, argv, Repeat, Size) ) { + return 1; + } + CompSequence(Repeat,Size); + return 0; +} + +//======================================================================= +//function : QANColPerfMap +//purpose : +//======================================================================= +static Standard_Integer QANColPerfMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) +{ + Standard_Integer Repeat, Size; + if ( CheckArguments(di, argc, argv, Repeat, Size) ) { + return 1; + } + CompMap(Repeat,Size); + return 0; +} + +//======================================================================= +//function : QANColPerfDataMap +//purpose : +//======================================================================= +static Standard_Integer QANColPerfDataMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) +{ + Standard_Integer Repeat, Size; + if ( CheckArguments(di, argc, argv, Repeat, Size) ) { + return 1; + } + CompDataMap(Repeat,Size); + return 0; +} + +//======================================================================= +//function : QANColPerfDoubleMap +//purpose : +//======================================================================= +static Standard_Integer QANColPerfDoubleMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) +{ + Standard_Integer Repeat, Size; + if ( CheckArguments(di, argc, argv, Repeat, Size) ) { + return 1; + } + CompDoubleMap(Repeat,Size); + return 0; +} + +//======================================================================= +//function : QANColPerfIndexedMap +//purpose : +//======================================================================= +static Standard_Integer QANColPerfIndexedMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) +{ + Standard_Integer Repeat, Size; + if ( CheckArguments(di, argc, argv, Repeat, Size) ) { + return 1; + } + CompIndexedMap(Repeat,Size); + return 0; +} + +//======================================================================= +//function : QANColPerfIndexedDataMap +//purpose : +//======================================================================= +static Standard_Integer QANColPerfIndexedDataMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) +{ + Standard_Integer Repeat, Size; + if ( CheckArguments(di, argc, argv, Repeat, Size) ) { + return 1; + } + CompIndexedDataMap(Repeat,Size); + return 0; +} + +//======================================================================= +//function : QANColCheckSparseArray +//purpose : +//======================================================================= +static Standard_Integer QANColCheckSparseArray(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) +{ + Standard_Integer Repeat, Size; + if ( CheckArguments(di, argc, argv, Repeat, Size) ) { + return 1; + } + CompSparseArray(Repeat,Size); + return 0; +} + +void QANCollection::CommandsPerf(Draw_Interpretor& theCommands) { + const char *group = "QANCollection"; + + // from agvCollTest/src/CollectionEXE/PerfTestEXE.cxx + theCommands.Add("QANColPerfArray1", "QANColPerfArray1 Repeat Size", __FILE__, QANColPerfArray1, group); + theCommands.Add("QANColPerfArray2", "QANColPerfArray2 Repeat Size", __FILE__, QANColPerfArray2, group); + theCommands.Add("QANColPerfList", "QANColPerfList Repeat Size", __FILE__, QANColPerfList, group); + theCommands.Add("QANColPerfSequence", "QANColPerfSequence Repeat Size", __FILE__, QANColPerfSequence, group); + theCommands.Add("QANColPerfMap", "QANColPerfMap Repeat Size", __FILE__, QANColPerfMap, group); + theCommands.Add("QANColPerfDataMap", "QANColPerfDataMap Repeat Size", __FILE__, QANColPerfDataMap, group); + theCommands.Add("QANColPerfDoubleMap", "QANColPerfDoubleMap Repeat Size", __FILE__, QANColPerfDoubleMap, group); + theCommands.Add("QANColPerfIndexedMap", "QANColPerfIndexedMap Repeat Size", __FILE__, QANColPerfIndexedMap, group); + theCommands.Add("QANColPerfIndexedDataMap", "QANColPerfIndexedDataMap Repeat Size", __FILE__, QANColPerfIndexedDataMap, group); + + theCommands.Add("QANColCheckSparseArray", "QANColCheckSparseArray Repeat Size", __FILE__, QANColCheckSparseArray, group); + + return; +} + diff --git a/src/QANCollection/QANCollection_PerfArrays.hxx b/src/QANCollection/QANCollection_PerfArrays.hxx deleted file mode 100644 index 7a3212ca2a..0000000000 --- a/src/QANCollection/QANCollection_PerfArrays.hxx +++ /dev/null @@ -1,196 +0,0 @@ -// Created on: 2002-05-15 -// Created by: Alexander KARTOMIN (akm) -// Copyright (c) 2002-2014 OPEN CASCADE SAS -// -// This file is part of Open CASCADE Technology software library. -// -// This library is free software; you can redistribute it and/or modify it under -// the terms of the GNU Lesser General Public License version 2.1 as published -// by the Free Software Foundation, with special exception defined in the file -// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT -// distribution for complete text of the license and disclaimer of any warranty. -// -// Alternatively, this file may be used under the terms of Open CASCADE -// commercial license or contractual agreement. - -#ifndef QANCollection_PerfArrays_HeaderFile -#define QANCollection_PerfArrays_HeaderFile - -#define PERF_ENABLE_METERS -#include -////////////////////////////////#include -#include -#include - -// ===================== Test perform of Array1 type ========================== -void CompArray1 (const Standard_Integer theRep, - const Standard_Integer theSize) -{ - Standard_Integer i,j; - - ////////////////////////////////Perf_Meter aNCrea ("NCollection_Array1 creation",0); - ////////////////////////////////Perf_Meter aTCrea ("TCollection_Array1 creation",0); - ////////////////////////////////Perf_Meter aNFill ("NCollection_Array1 filling",0); - ////////////////////////////////Perf_Meter aTFill ("TCollection_Array1 filling",0); - ////////////////////////////////Perf_Meter aNFind ("NCollection_Array1 finding",0); - ////////////////////////////////Perf_Meter aTFind ("TCollection_Array1 finding",0); - ////////////////////////////////Perf_Meter aNOper ("NCollection_Array1 operator=",0); - ////////////////////////////////Perf_Meter aTOper ("TCollection_Array1 operator=",0); - ////////////////////////////////Perf_Meter aNAssi ("NCollection_Array1 Assign",0); - for (i=0; i -#include -#include -#include -#include - -// ===================== Test perform of Map type ========================== -void CompMap (const Standard_Integer theRep, - const Standard_Integer theSize) -{ - Standard_Integer i,j; - - ////////////////////////////////Perf_Meter aNBind ("NCollection_Map adding",0); - ////////////////////////////////Perf_Meter aTBind ("TCollection_Map adding",0); - ////////////////////////////////Perf_Meter aNOper ("NCollection_Map operator=",0); - ////////////////////////////////Perf_Meter aTOper ("TCollection_Map operator=",0); - ////////////////////////////////Perf_Meter aNFind ("NCollection_Map finding",0); - ////////////////////////////////Perf_Meter aTFind ("TCollection_Map finding",0); - ////////////////////////////////Perf_Meter aNClea ("NCollection_Map clearing",0); - ////////////////////////////////Perf_Meter aTClea ("TCollection_Map clearing",0); - ////////////////////////////////Perf_Meter aNAssi ("NCollection_Map Assign",0); - for (i=0; i -////////////////////////////////#include -#include -#include - -// ===================== Test perform of SparseArray type ========================== -void CompSparseArray (const Standard_Integer theRep, const Standard_Integer theSize) -{ - Standard_Integer i,j; - for (i=0; i a1(theSize),a2(theSize); - - PERF_STOP_METER("NCollection_SparseArray creation") - - PERF_START_METER("NCollection_SparseArray filling") - for( j=0;j -#include - -// ===================== Test methods for each type =========================== -// TCollection classes compared are the containers with -// ValueType - gp_Pnt -// Key1Type - Standard_Real -// Key2Type - Standard_Integer - -#include -#include -#include - -#endif diff --git a/src/QANCollection/QANCollection1.cxx b/src/QANCollection/QANCollection_Simple.cxx similarity index 52% rename from src/QANCollection/QANCollection1.cxx rename to src/QANCollection/QANCollection_Simple.cxx index 639b3db79e..13dfde755c 100644 --- a/src/QANCollection/QANCollection1.cxx +++ b/src/QANCollection/QANCollection_Simple.cxx @@ -21,35 +21,118 @@ #include #include -#define USE_MACROS -#ifdef USE_MACROS -#include -#include -DEFINE_BASECOLLECTION (MyBaseCollPnt, gp_Pnt) -DEFINE_ARRAY1 (MyArray1, MyBaseCollPnt, gp_Pnt) -DEFINE_SEQUENCE (MySequence, MyBaseCollPnt, gp_Pnt) -#else #include #include +#include + typedef NCollection_Array1 MyArray1; typedef NCollection_Sequence MySequence; -typedef NCollection_BaseCollection MyBaseCollPnt; -#endif -void checkArray (const Standard_Boolean); -void checkSequence (const Standard_Boolean, const Standard_Boolean); -void createArray (TColgp_Array1OfPnt&); -void assignArray (TColgp_Array1OfPnt&, const TColgp_Array1OfPnt&); -void createSequence (TColgp_SequenceOfPnt&); -void assignSequence (TColgp_SequenceOfPnt&, const TColgp_SequenceOfPnt&); - -void createArray (MyArray1&); -void assignArray (MyArray1&, const MyArray1&); -void createSequence (MySequence&); -void assignSequence (MySequence&, const MySequence&); -void assignCollection (MyBaseCollPnt&, const MyBaseCollPnt&, const char *); -void printAllMeters (); - -void checkArray (const Standard_Boolean isNewColl) + +const Standard_Integer REPEAT = 100; + +void printAllMeters () +{ + PERF_PRINT_ALL +} + +static void createArray (TColgp_Array1OfPnt& anArrPnt) +{ + OSD_PerfMeter aPerfMeter("Create array"); + + for (Standard_Integer j = 0; j < 2*REPEAT; j++) { + PERF_START_METER("Create array") + for (Standard_Integer i = anArrPnt.Lower(); i <= anArrPnt.Upper(); i++) + anArrPnt(i).SetCoord ((double)i, (double)(i+1), (double)(i+2)); + PERF_STOP_METER("Create array") + } +} + +static void createSequence (TColgp_SequenceOfPnt& aSeq) +{ + for (Standard_Integer j = 0; j < REPEAT; j++) { + PERF_START_METER("Clear sequence") + aSeq.Clear(); + PERF_STOP_METER("Clear sequence") + PERF_START_METER("Create sequence") + for (Standard_Integer i = 0; i < 100000; i++) + aSeq.Append (gp_Pnt((double)i, (double)(i+1), (double)(i+2))); + PERF_STOP_METER("Create sequence") + } +} + +static void createSequence (MySequence& aSeq) +{ + for (Standard_Integer j = 0; j < REPEAT; j++) { + PERF_START_METER("Clear sequence") + aSeq.Clear(); + PERF_STOP_METER("Clear sequence") + PERF_START_METER("Create sequence") + for (Standard_Integer i = 0; i < 100000; i++) + aSeq.Append (gp_Pnt((double)i, (double)(i+1), (double)(i+2))); + PERF_STOP_METER("Create sequence") + } +} + +static void assignSequence (TColgp_SequenceOfPnt& aDest, + const TColgp_SequenceOfPnt& aSrc) +{ + for (Standard_Integer i = 0; i < REPEAT; i++) { + PERF_START_METER("Assign sequence to sequence") + aDest = aSrc; + PERF_STOP_METER("Assign sequence to sequence") + } +} + +static void assignSequence (MySequence& aDest, const MySequence& aSrc) +{ + for (Standard_Integer i = 0; i < REPEAT; i++) { + PERF_START_METER("Assign sequence to sequence") + aDest = aSrc; + PERF_STOP_METER("Assign sequence to sequence") + } +} + +static void createArray (MyArray1& anArrPnt) +{ + for (Standard_Integer j = 0; j < 2*REPEAT; j++) { + PERF_START_METER("Create array") + for (Standard_Integer i = anArrPnt.Lower(); i <= anArrPnt.Upper(); i++) + anArrPnt(i).SetCoord ((double)i, (double)(i+1), (double)(i+2)); + PERF_STOP_METER("Create array") + } +} + +static void assignArray (TColgp_Array1OfPnt& aDest, const TColgp_Array1OfPnt& aSrc) +{ + for (Standard_Integer i = 0; i < 2*REPEAT; i++) { + PERF_START_METER("Assign array to array") + aDest = aSrc; + PERF_STOP_METER("Assign array to array") + } +} + +template +void assignCollection (MyBaseCollPnt& aDest, + const MyBaseCollPnt& aSrc, + const char * MeterName) +{ + for (Standard_Integer i = 0; i < REPEAT; i++) { + perf_start_meter (MeterName); + aDest.Assign(aSrc); + perf_stop_meter (MeterName); + } +} + +static void assignArray (MyArray1& aDest, const MyArray1& aSrc) +{ + for (Standard_Integer i = 0; i < 2*REPEAT; i++) { + PERF_START_METER("Assign array to array") + aDest = aSrc; + PERF_STOP_METER("Assign array to array") + } +} + +static void checkArray (const Standard_Boolean isNewColl) { if (isNewColl) { MyArray1 anArrPnt (1, 100000), anArrPnt1 (1, 100000); @@ -64,17 +147,11 @@ void checkArray (const Standard_Boolean isNewColl) printAllMeters (); } -static Handle(NCollection_BaseAllocator) anAlloc[2]; - -Handle(NCollection_BaseAllocator) getAlloc (const int i) -{ - return i == 0 ? anAlloc[0]: anAlloc[1]; -} - -void checkSequence (const Standard_Boolean isNewColl, - const Standard_Boolean isIncr) +static void checkSequence (const Standard_Boolean isNewColl, + const Standard_Boolean isIncr) { if (isNewColl) { + Handle(NCollection_BaseAllocator) anAlloc[2]; if (isIncr) { anAlloc[0] = new NCollection_IncAllocator; anAlloc[1] = new NCollection_IncAllocator; @@ -134,7 +211,7 @@ static Standard_Integer QANColCheckSequence(Draw_Interpretor& di, Standard_Integ return 0; } -void QANCollection::Commands1(Draw_Interpretor& theCommands) { +void QANCollection::CommandsSimple(Draw_Interpretor& theCommands) { const char *group = "QANCollection"; // from agvCollTest/src/AgvColEXE/TestEXE.cxx diff --git a/src/QANCollection/QANCollection_Test.cxx b/src/QANCollection/QANCollection_Test.cxx new file mode 100644 index 0000000000..3277937074 --- /dev/null +++ b/src/QANCollection/QANCollection_Test.cxx @@ -0,0 +1,761 @@ +// Created on: 2004-03-05 +// Created by: Mikhail KUZMITCHEV +// Copyright (c) 2004-2014 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include +#include + +#include +#include + +#include + +#define ItemType gp_Pnt +#define Key1Type Standard_Real +#define Key2Type Standard_Integer + +#include +#include +////////////////////////////////DEFINE_ARRAY1(QANCollection_Array1,QANCollection_BaseCol,ItemType) +////////////////////////////////DEFINE_HARRAY1(QANCollection_HArray1,QANCollection_Array1) +DEFINE_ARRAY1(QANCollection_Array1Func,QANCollection_BaseColFunc,ItemType) +DEFINE_HARRAY1(QANCollection_HArray1Func,QANCollection_Array1Func) +IMPLEMENT_HARRAY1(QANCollection_HArray1Func) + +#include +#include +////////////////////////////////DEFINE_ARRAY2(QANCollection_Array2,QANCollection_BaseCol,ItemType) +////////////////////////////////DEFINE_HARRAY2(QANCollection_HArray2,QANCollection_Array2) +DEFINE_ARRAY2(QANCollection_Array2Func,QANCollection_BaseColFunc,ItemType) +DEFINE_HARRAY2(QANCollection_HArray2Func,QANCollection_Array2Func) +IMPLEMENT_HARRAY2(QANCollection_HArray2Func) + +#include +#include +#include +#include +#include +////////////////////////////////DEFINE_MAP(QANCollection_Map,QANCollection_Key1BaseCol,Key1Type) +////////////////////////////////DEFINE_DATAMAP(QANCollection_DataMap,QANCollection_BaseCol,Key1Type,ItemType) +////////////////////////////////DEFINE_DOUBLEMAP(QANCollection_DoubleMap,QANCollection_Key2BaseCol,Key1Type,Key2Type) +////////////////////////////////DEFINE_INDEXEDMAP(QANCollection_IndexedMap,QANCollection_Key1BaseCol,Key1Type) +////////////////////////////////DEFINE_INDEXEDDATAMAP(QANCollection_IDMap,QANCollection_BaseCol,Key1Type,ItemType) +DEFINE_MAP(QANCollection_MapFunc,QANCollection_Key1BaseColFunc,Key1Type) +DEFINE_DATAMAP(QANCollection_DataMapFunc,QANCollection_BaseColFunc,Key1Type,ItemType) +DEFINE_DOUBLEMAP(QANCollection_DoubleMapFunc,QANCollection_Key2BaseColFunc,Key1Type,Key2Type) +DEFINE_INDEXEDMAP(QANCollection_IndexedMapFunc,QANCollection_Key1BaseColFunc,Key1Type) +DEFINE_INDEXEDDATAMAP(QANCollection_IDMapFunc,QANCollection_BaseColFunc,Key1Type,ItemType) + +#include +////////////////////////////////DEFINE_LIST(QANCollection_List,QANCollection_BaseCol,ItemType) +DEFINE_LIST(QANCollection_ListFunc,QANCollection_BaseColFunc,ItemType) + +#include +#include +////////////////////////////////DEFINE_SEQUENCE(QANCollection_Sequence,QANCollection_BaseCol,ItemType) +////////////////////////////////DEFINE_HSEQUENCE(QANCollection_HSequence,QANCollection_Sequence) +DEFINE_SEQUENCE(QANCollection_SequenceFunc,QANCollection_BaseColFunc,ItemType) +DEFINE_HSEQUENCE(QANCollection_HSequenceFunc,QANCollection_SequenceFunc) +IMPLEMENT_HSEQUENCE(QANCollection_HSequenceFunc) + +// HashCode and IsEquel must be defined for key types of maps +Standard_Integer HashCode(const gp_Pnt thePnt, int theUpper) +{ + return HashCode(thePnt.X(),theUpper); +} + +Standard_Boolean IsEqual(const gp_Pnt& theP1, const gp_Pnt& theP2) +{ + return theP1.IsEqual(theP2,gp::Resolution()); +} + +////////////////////////////////void printCollection (QANCollection_Key1BaseCol& aColl, +template +void printCollection (Coll& aColl, const char * str) +{ + printf ("%s:\n",str); + Standard_Integer iSize = aColl.Size(); + ////////////////////////////////QANCollection_Key1BaseCol::Iterator& anIter = aColl.CreateIterator(); + typename Coll::Iterator anIter (aColl); + if (!anIter.More()) + { + if (iSize==0) + printf (" \n"); + else + printf ("Error : empty collection has size==%d",iSize); + } + else + { + printf (" Size==%d\n",iSize); + for (; anIter.More(); anIter.Next()) + PrintItem(anIter.Value()); + } +} + +////////////////////////////////void AssignCollection (QANCollection_BaseCol& aCollSrc, +//////////////////////////////// QANCollection_BaseCol& aCollDst) +template +void AssignCollection (Coll& aCollSrc, Coll& aCollDst) +{ + printCollection (aCollSrc,"Source collection"); + aCollDst.Assign(aCollSrc); + printCollection (aCollDst,"Target collection"); +} + +// ===================== Test methods of Array1 type ========================== +////////////////////////////////void TestArray1 (QANCollection_Array1& theA1) +static void TestArray1 (QANCollection_Array1Func& theA1) +{ + // Bounds + Standard_Integer iLow=theA1.Lower(); + Standard_Integer iUpp=theA1.Upper(); + Standard_Integer i; + + printf ("Info: testing Array1(%d,%d), %s\n", + iLow, iUpp, (theA1.IsDeletable()?"deletable":"frozen")); + // C-array constructor, Length, Init + ItemType anItem; + Random(anItem); + theA1.Init (anItem); + ItemType * rBlock = new ItemType[theA1.Length()]; + ////////////////////////////////QANCollection_Array1 aCArr(*rBlock, iLow-100, iUpp-100); + QANCollection_Array1Func aCArr(*rBlock, iLow-100, iUpp-100); + printf (" created the same sized preallocated array (%d,%d), %s\n", + aCArr.Lower(),aCArr.Upper(),(aCArr.IsDeletable()?"deletable":"frozen")); + // *Value, operator() + for (i=iLow+1; iChangeArray1(), theA1); +} + +// ===================== Test methods of Array2 type ========================== +////////////////////////////////void TestArray2 (QANCollection_Array2& theA2) +static void TestArray2 (QANCollection_Array2Func& theA2) +{ + // Bounds + Standard_Integer iLR=theA2.LowerRow(), iLC=theA2.LowerCol(); + Standard_Integer iUR=theA2.UpperRow(), iUC=theA2.UpperCol(); + Standard_Integer i,j; + + printf ("Info: testing Array2 (%d,%d)(%d,%d), %s\n", + iLR, iUR, iLC, iUC, (theA2.IsDeletable()?"deletable":"frozen")); + // C-array constructor, Length, Init, RowLength, ColLength + ItemType anItem; + Random(anItem); + theA2.Init (anItem); + ItemType * rBlock = new ItemType[theA2.Length()]; + ////////////////////////////////QANCollection_Array2 aCArr(*rBlock, iLR-100, iUR-100, iLC, iUC); + QANCollection_Array2Func aCArr(*rBlock, iLR-100, iUR-100, iLC, iUC); + printf (" created the same sized preallocated array (%d*%d), %s\n", + aCArr.RowLength(), aCArr.ColLength(), + (aCArr.IsDeletable()?"deletable":"frozen")); + // *Value, operator() + for (i=iLR+1; iChangeArray2(), theA2); +} + +// ===================== Test methods of List type ========================== +////////////////////////////////void TestList (QANCollection_List& theL) +static void TestList (QANCollection_ListFunc& theL) +{ + // Extent + Standard_Integer iExt=theL.Extent(); + Standard_Integer i; + + printf ("Info: testing List(%d)\n", iExt); + // Append(2), Prepend(2), InsertBefore(2), InsertAfter(2), + // Remove, RemoveFirst, First, Last + ItemType anItem; + ////////////////////////////////QANCollection_List aL, aL1; + QANCollection_ListFunc aL, aL1; + for (i=0; i<4; i++) + { + Random (anItem); + aL.Append (anItem); // #1 + aL.Append (aL1); // #2 + Random (anItem); + aL1.Prepend (anItem); // #3 + aL1.Prepend (aL); // #4 + ////////////////////////////////QANCollection_List::Iterator anI(theL); + QANCollection_ListFunc::Iterator anI(theL); + if (anI.More()) + { + Random (anItem); + theL.InsertBefore (anItem, anI); // #5 + theL.InsertBefore (aL1, anI); // #6 + Random (anItem); + theL.InsertAfter (anItem, anI); // #7 + theL.InsertAfter (aL, anI); // #8 + theL.Remove (anI); // #9 + if (theL.Extent() > 0) + theL.RemoveFirst(); // #10 + } + else + { + theL.Prepend (anItem); + PrintItem(theL.First()); + PrintItem(theL.Last()); + } + } + // Copy constructor + operator= + ////////////////////////////////aL = QANCollection_List(theL); + aL = QANCollection_ListFunc(theL); + + // Assign + AssignCollection (theL, aL); + + // Clear + aL.Clear(); +} + +// ===================== Test methods of Sequence type ======================== +////////////////////////////////void TestSequence (QANCollection_Sequence& theS) +static void TestSequence (QANCollection_SequenceFunc& theS) +{ + Standard_Integer i; + + printf ("Info: testing Sequence\n"); + // Append(2) + ItemType anItem; + ////////////////////////////////QANCollection_Sequence aS, aS1; + QANCollection_SequenceFunc aS, aS1; + // Append(2), Prepend(2), InsertBefore(2), InsertAfter(2), + // Remove, RemoveFirst, First, Last + for (i=0; i<4; i++) + { + Random (anItem); + aS.Append (anItem); // #1 + aS.Append (aS1); // #2 + Random (anItem); + aS1.Prepend (anItem); // #3 + aS1.Prepend (aS); // #4 + if (theS.Length() > 0) + { + Random (anItem); + theS.InsertBefore (1, anItem); // #5 + theS.InsertBefore (2, aS1); // #6 + Random (anItem); + theS.InsertAfter (1, anItem); // #7 + theS.InsertAfter (2, aS); // #8 + theS.Remove (1); // #9 + if (theS.Length() > 0) + theS.Remove(1); // #10 + } + else + { + theS.Prepend (anItem); + PrintItem(theS.First()); + PrintItem(theS.Last()); + } + } + + // () + PrintItem(theS(1)); + + // Handle, Split + ////////////////////////////////Handle(QANCollection_HSequence) aHS = new QANCollection_HSequence(aS1); + Handle(QANCollection_HSequenceFunc) aHS = new QANCollection_HSequenceFunc(aS1); + theS.Split (3, aHS->ChangeSequence()); + + // Assign + AssignCollection (theS, aS); + + // Clear + aS.Clear(); +} + +// ===================== Test methods of Map type ============================= +////////////////////////////////void TestMap (QANCollection_Map& theM) +static void TestMap (QANCollection_MapFunc& theM) +{ + // Extent + Standard_Integer iExt=theM.Extent(); + Standard_Integer i; + + printf ("Info: testing Map(l=%d)\n", iExt); + theM.Statistics(cout); + // Resize + theM.ReSize(8); + theM.Statistics(cout); + cout.flush(); + // Constructor + ////////////////////////////////QANCollection_Map aM; + QANCollection_MapFunc aM; + // Add + Key1Type aKey; + for (i=0; i<8; i++) + { + Random (aKey); + aM.Add (aKey); + } + // Contains, Remove + if (!aM.Contains(aKey)) + { + printf("Error : map says that it does not contain its key "); + PrintItem(aKey); + } + else + { + aM.Remove(aKey); + printf(" successfully removed item, l=%d\n", aM.Size()); + } + // Copy constructor (including operator=) + ////////////////////////////////QANCollection_Map aM2 = QANCollection_Map(aM); + QANCollection_MapFunc aM2 = QANCollection_MapFunc(aM); + // Assign + AssignCollection (aM2,theM); + + // Clear + aM.Clear(); +} + +// ===================== Test methods of DataMap type ========================= +////////////////////////////////void TestDataMap (QANCollection_DataMap& theM) +static void TestDataMap (QANCollection_DataMapFunc& theM) +{ + // Extent + Standard_Integer iExt=theM.Extent(); + Standard_Integer i; + + printf ("Info: testing DataMap(l=%d)\n", iExt); + theM.Statistics(cout); + // Resize + theM.ReSize(8); + theM.Statistics(cout); + cout.flush(); + // Constructor + ////////////////////////////////QANCollection_DataMap aM; + QANCollection_DataMapFunc aM; + // Bind, Find, ChangeFind, () + Key1Type aKey; + ItemType anItem; + for (i=0; i<8; i++) + { + Random (aKey); + Random (anItem); + aM.Bind (aKey, anItem); + PrintItem(aM.Find(aKey)); + Random(aM(aKey)); + } + // IsBound, UnBind + if (!aM.IsBound(aKey)) + { + printf("Error : map says that it does not contain its key "); + PrintItem(aKey); + } + else + { + aM.UnBind(aKey); + printf(" successfully unbound the key, l=%d\n", aM.Size()); + } + // Copy constructor (including operator=) + ////////////////////////////////theM = QANCollection_DataMap(aM); + theM = QANCollection_DataMapFunc(aM); + // Assign - prohibited + // AssignCollection (aM2,theM); + printCollection (theM, "DataMap:"); + + // Clear + aM.Clear(); +} + + +// ===================== Test methods of DoubleMap type ======================= +////////////////////////////////void TestDoubleMap (QANCollection_DoubleMap& theM) +static void TestDoubleMap (QANCollection_DoubleMapFunc& theM) +{ + // Extent + Standard_Integer iExt=theM.Extent(); + Standard_Integer i; + + printf ("Info: testing DoubleMap(l=%d)\n", iExt); + theM.Statistics(cout); + // Resize + theM.ReSize(8); + theM.Statistics(cout); + cout.flush(); + // Constructor + ////////////////////////////////QANCollection_DoubleMap aM; + QANCollection_DoubleMapFunc aM; + // Bind, Find?, + Key1Type aKey1; + Key2Type aKey2; + for (i=0; i<8; i++) + { + Random (aKey1); + Random (aKey2); + aM.Bind (aKey1, aKey2); + PrintItem(aM.Find1(aKey1)); + if (!aM.IsBound1(aKey1)) + { + printf("Error : map says that it does not contain its key "); + PrintItem(aKey1); + } + PrintItem(aM.Find2(aKey2)); + if (!aM.IsBound2(aKey2)) + { + printf("Error : map says that it does not contain its key "); + PrintItem(aKey2); + } + } + // AreBound, UnBind + if (!aM.AreBound(aKey1,aKey2)) + { + printf("Error : map says that it does not contain its keys "); + PrintItem(aKey1); + PrintItem(aKey2); + } + else + { + if (aM.UnBind2(aKey2)) + printf(" successfully unbound the key, l=%d\n", aM.Size()); + if (aM.UnBind1(aKey1)) + printf("Error : unbound both keys?!\n"); + } + // Copy constructor (including operator=) + ////////////////////////////////theM = QANCollection_DoubleMap(aM); + theM = QANCollection_DoubleMapFunc(aM); + // Assign - prohibited + // AssignCollection (aM2,theM); + printCollection (theM, "DoubleMap:"); + + // Clear + aM.Clear(); +} + +// ===================== Test methods of IndexedMap type ====================== +////////////////////////////////void TestIndexedMap (QANCollection_IndexedMap& theM) +static void TestIndexedMap (QANCollection_IndexedMapFunc& theM) +{ + // Extent + Standard_Integer iExt=theM.Extent(); + Standard_Integer i; + + printf ("Info: testing IndexedMap(l=%d)\n", iExt); + theM.Statistics(cout); + // Resize + theM.ReSize(8); + theM.Statistics(cout); + cout.flush(); + // Constructor + ////////////////////////////////QANCollection_IndexedMap aM; + QANCollection_IndexedMapFunc aM; + // Add, FindKey, FindIndex + Key1Type aKey; + for (i=0; i<8; i++) + { + Random (aKey); + aM.Add (aKey); + Standard_Integer iIndex=aM.FindIndex(aKey); + printf (" added a key, i=%d, k=",iIndex); + PrintItem(aM(iIndex)); + } + // Contains, Remove + if (!aM.Contains(aM.FindKey(aM.FindIndex(aKey)))) + { + printf("Error : map says that it does not contain its key "); + PrintItem(aKey); + } + else + { + aM.RemoveLast(); + printf(" successfully removed item, l=%d\n", aM.Size()); + } + // Substitute + Random(aKey); + aM.Substitute(1,aKey); + // Copy constructor (including operator=) + ////////////////////////////////QANCollection_IndexedMap aM2 = QANCollection_IndexedMap(aM); + QANCollection_IndexedMapFunc aM2 = QANCollection_IndexedMapFunc(aM); + // Assign + AssignCollection (aM2,theM); + + // Clear + aM.Clear(); +} + +// ===================== Test methods of IndexedDataMap type ================== +////////////////////////////////void TestIndexedDataMap (QANCollection_IDMap& theM) +static void TestIndexedDataMap (QANCollection_IDMapFunc& theM) +{ + // Extent + Standard_Integer iExt=theM.Extent(); + Standard_Integer i; + + printf ("Info: testing IndexedDataMap(l=%d)\n", iExt); + theM.Statistics(cout); + // Resize + theM.ReSize(8); + theM.Statistics(cout); + cout.flush(); + // Constructor + ////////////////////////////////QANCollection_IDMap aM; + QANCollection_IDMapFunc aM; + // Add, FindKey, FindIndex, FindFromIndex, Change..., () + Key1Type aKey; + ItemType anItem; + for (i=0; i<8; i++) + { + Random (aKey); + Random (anItem); + aM.Add (aKey, anItem); + Standard_Integer iIndex=aM.FindIndex(aKey); + printf (" added a key, i=%d, k=",iIndex); + PrintItem(aM.FindKey(iIndex)); + PrintItem(aM(iIndex)); + Random(aM.ChangeFromIndex(iIndex)); + } + // Contains, Remove, FindFromKey + if (!aM.Contains(aM.FindKey(aM.FindIndex(aKey)))) + { + printf("Error : map says that it does not contain its key "); + PrintItem(aKey); + } + else + { + anItem = aM.FindFromKey(aKey); + aM.RemoveLast(); + printf(" successfully removed item, l=%d\n", aM.Size()); + } + // Substitute + Random(aKey); + aM.Substitute (1, aKey, anItem); + // Copy constructor (including operator=) + ////////////////////////////////theM = QANCollection_IDMap(aM); + theM = QANCollection_IDMapFunc(aM); + // Assign - prohibited + // AssignCollection (aM2,theM); + printCollection (theM, "DoubleMap:"); + + // Clear + aM.Clear(); +} + +//======================================================================= +//function : CheckArguments1 +//purpose : +//======================================================================= +Standard_Integer CheckArguments1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv, Standard_Integer& Lower, Standard_Integer& Upper) +{ + if ( argc != 3) { + di << "Usage : " << argv[0] << " Lower Upper" << "\n"; + return 1; + } + Lower = Draw::Atoi(argv[1]); + Upper = Draw::Atoi(argv[2]); + if ( Lower > Upper ) { + di << "Lower > Upper" << "\n"; + return 1; + } + return 0; +} + +//======================================================================= +//function : CheckArguments2 +//purpose : +//======================================================================= +Standard_Integer CheckArguments2(Draw_Interpretor& di, Standard_Integer argc, const char ** argv, Standard_Integer& LowerRow, Standard_Integer& UpperRow, Standard_Integer& LowerCol, Standard_Integer& UpperCol) +{ + if ( argc != 5) { + di << "Usage : " << argv[0] << " LowerRow UpperRow LowerCol UpperCol" << "\n"; + return 1; + } + LowerRow = Draw::Atoi(argv[1]); + UpperRow = Draw::Atoi(argv[2]); + LowerCol = Draw::Atoi(argv[3]); + UpperCol = Draw::Atoi(argv[4]); + if ( LowerRow > UpperRow ) { + di << "LowerRow > UpperRow" << "\n"; + return 1; + } + if ( LowerCol > UpperCol ) { + di << "LowerCol UpperCol> " << "\n"; + return 1; + } + return 0; +} + + +//======================================================================= +//function : QANColTestArray1 +//purpose : +//======================================================================= +static Standard_Integer QANColTestArray1(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) +{ + Standard_Integer Lower, Upper; + if ( CheckArguments1(di, argc, argv, Lower, Upper) ) { + return 1; + } + QANCollection_Array1Func anArr1(Lower, Upper); + TestArray1(anArr1); + return 0; +} + +//======================================================================= +//function : QANColTestArray2 +//purpose : +//======================================================================= +static Standard_Integer QANColTestArray2(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) +{ + Standard_Integer LowerRow, UpperRow, LowerCol, UpperCol; + if ( CheckArguments2(di, argc, argv, LowerRow, UpperRow, LowerCol, UpperCol) ) { + return 1; + } + QANCollection_Array2Func anArr2(LowerRow, UpperRow, LowerCol, UpperCol); + TestArray2(anArr2); + return 0; +} + +//======================================================================= +//function : QANColTestMap +//purpose : +//======================================================================= +static Standard_Integer QANColTestMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) +{ + if ( argc != 1) { + di << "Usage : " << argv[0] << "\n"; + return 1; + } + QANCollection_MapFunc aMap; + TestMap(aMap); + return 0; +} + +//======================================================================= +//function : QANColTestDataMap +//purpose : +//======================================================================= +static Standard_Integer QANColTestDataMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) +{ + if ( argc != 1) { + di << "Usage : " << argv[0] << "\n"; + return 1; + } + QANCollection_DataMapFunc aDataMap; + TestDataMap(aDataMap); + return 0; +} + +//======================================================================= +//function : QANColTestDoubleMap +//purpose : +//======================================================================= +static Standard_Integer QANColTestDoubleMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) +{ + if ( argc != 1) { + di << "Usage : " << argv[0] << "\n"; + return 1; + } + QANCollection_DoubleMapFunc aDoubleMap; + TestDoubleMap(aDoubleMap); + return 0; +} + +//======================================================================= +//function : QANColTestIndexedMap +//purpose : +//======================================================================= +static Standard_Integer QANColTestIndexedMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) +{ + if ( argc != 1) { + di << "Usage : " << argv[0] << "\n"; + return 1; + } + QANCollection_IndexedMapFunc aIndexedMap; + TestIndexedMap(aIndexedMap); + return 0; +} + +//======================================================================= +//function : QANColTestIndexedDataMap +//purpose : +//======================================================================= +static Standard_Integer QANColTestIndexedDataMap(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) +{ + if ( argc != 1) { + di << "Usage : " << argv[0] << "\n"; + return 1; + } + QANCollection_IDMapFunc aIDMap; + TestIndexedDataMap(aIDMap); + return 0; +} + +//======================================================================= +//function : QANColTestList +//purpose : +//======================================================================= +static Standard_Integer QANColTestList(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) +{ + if ( argc != 1) { + di << "Usage : " << argv[0] << "\n"; + return 1; + } + QANCollection_ListFunc aList; + TestList(aList); + return 0; +} + +//======================================================================= +//function : QANColTestSequence +//purpose : +//======================================================================= +static Standard_Integer QANColTestSequence(Draw_Interpretor& di, Standard_Integer argc, const char ** argv) +{ + if ( argc != 1) { + di << "Usage : " << argv[0] << "\n"; + return 1; + } + QANCollection_SequenceFunc aSeq; + TestSequence(aSeq); + return 0; +} + +void QANCollection::CommandsTest(Draw_Interpretor& theCommands) { + const char *group = "QANCollection"; + + // from agvCollTest/src/CollectionEXE/FuncTestEXE.cxx + theCommands.Add("QANColTestArray1", "QANColTestArray1", __FILE__, QANColTestArray1, group); + theCommands.Add("QANColTestArray2", "QANColTestArray2", __FILE__, QANColTestArray2, group); + theCommands.Add("QANColTestMap", "QANColTestMap", __FILE__, QANColTestMap, group); + theCommands.Add("QANColTestDataMap", "QANColTestDataMap", __FILE__, QANColTestDataMap, group); + theCommands.Add("QANColTestDoubleMap", "QANColTestDoubleMap", __FILE__, QANColTestDoubleMap, group); + theCommands.Add("QANColTestIndexedMap", "QANColTestIndexedMap", __FILE__, QANColTestIndexedMap, group); + theCommands.Add("QANColTestIndexedDataMap", "QANColTestIndexedDataMap", __FILE__, QANColTestIndexedDataMap, group); + theCommands.Add("QANColTestList", "QANColTestList", __FILE__, QANColTestList, group); + theCommands.Add("QANColTestSequence", "QANColTestSequence", __FILE__, QANColTestSequence, group); + + return; +} -- 2.20.1