From: <den...@us...> - 2010-09-12 14:43:50
|
Revision: 319 http://stdair.svn.sourceforge.net/stdair/?rev=319&view=rev Author: denis_arnaud Date: 2010-09-12 14:43:43 +0000 (Sun, 12 Sep 2010) Log Message: ----------- [Test] Added a test sub-directory for Boost.Intrusive-based architecture. Modified Paths: -------------- trunk/stdair/test/archi_intru/archi.cpp trunk/stdair/test/archi_intru/sources.mk Added Paths: ----------- trunk/stdair/test/archi_intru/FacRelationShipRoot.hpp trunk/stdair/test/archi_intru/FacRelationShipRootAbstract.hpp trunk/stdair/test/archi_intru/FacSupervisor.cpp trunk/stdair/test/archi_intru/FacSupervisor.hpp trunk/stdair/test/archi_intru/RelationShipHolder.hpp Added: trunk/stdair/test/archi_intru/FacRelationShipRoot.hpp =================================================================== --- trunk/stdair/test/archi_intru/FacRelationShipRoot.hpp (rev 0) +++ trunk/stdair/test/archi_intru/FacRelationShipRoot.hpp 2010-09-12 14:43:43 UTC (rev 319) @@ -0,0 +1,75 @@ +#ifndef __INTRUSIVE_FAC_FACRELATIONSHIPHOLDER_HPP +#define __INTRUSIVE_FAC_FACRELATIONSHIPHOLDER_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// Boost.Intrusive +#include <boost/intrusive/list.hpp> +#include <boost/intrusive/set.hpp> +// Local +#include <test/archi_intru/FacSupervisor.hpp> +#include <test/archi_intru/RelationShipHolder.hpp> + +/** Alias for the boost::intrusive namespace. */ +namespace bi = boost::intrusive; + +namespace stdair { + + /** Class holding the list of all the relationship objects of a given type. */ + template <typename FIRST_BOM, typename SECOND_BOM> + class FacRelationShipRoot { + public: + // /////////////////////////////////////////// + /** Type definition for a list of relationship holder objects. */ + typedef bi::list<RelationShipHolder<FIRST_BOM, + SECOND_BOM> > RelationShipHolderList_T; + /** Type definition for a set of relationship holder objects. */ + typedef bi::set<RelationShipHolder<FIRST_BOM, + SECOND_BOM> > RelationShipHolderSet_T; + // /////////////////////////////////////////// + + public: + /** Provide the unique instance. + <br>The singleton is instantiated when first used. + @return FacRelationShipRoot& */ + static FacRelationShipRoot& instance () { + if (_instance == NULL) { + _instance = new FacRelationShipRoot (); + assert (_instance != NULL); + + FacSupervisor::instance().registerFacRelationShipRoot (_instance); + } + return *_instance; + } + + public: + /** Add a child/sibling to the dedicated list of the parent/sibling. */ + static void addToList (FIRST_BOM& ioFirstBom, SECOND_BOM& ioSecondBom) { + instance().addToListImpl (ioFirstBom, ioSecondBom); + } + + /** Add a child/sibling to the dedicated list of the parent/sibling. */ + void addToListImpl (FIRST_BOM& ioFirstBom, SECOND_BOM& ioSecondBom) { + _relationShipHolderList.push_back (ioFirstBom, ioSecondBom); + _relationShipHolderSet.insert (ioFirstBom, ioSecondBom); + } + + private: + /** List of relationship holder objects. */ + RelationShipHolderList_T _relationShipHolderList; + /** Set of relationship holder objects. */ + RelationShipHolderSet_T _relationShipHolderSet; + + private: + /** The unique instance. */ + static FacRelationShipRoot* _instance; + }; + + // //////////////////////////////////////////////////////////////////// + template <typename FIRST_BOM, typename SECOND_BOM> + FacRelationShipRoot<FIRST_BOM, SECOND_BOM>* + FacRelationShipRoot<FIRST_BOM, SECOND_BOM>::_instance = NULL; + +} +#endif // __INTRUSIVE_FAC_FACRELATIONSHIPHOLDER_HPP Added: trunk/stdair/test/archi_intru/FacRelationShipRootAbstract.hpp =================================================================== --- trunk/stdair/test/archi_intru/FacRelationShipRootAbstract.hpp (rev 0) +++ trunk/stdair/test/archi_intru/FacRelationShipRootAbstract.hpp 2010-09-12 14:43:43 UTC (rev 319) @@ -0,0 +1,29 @@ +#ifndef __INTRUSIVE_BOM_RELATIONSHIPABSTRACT_HPP +#define __INTRUSIVE_BOM_RELATIONSHIPABSTRACT_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <iosfwd> +#include <string> +// StdAir +#include <stdair/STDAIR_Types.hpp> + +namespace stdair { + + /** + * @brief Base class for the relation ship objects + */ + class FacRelationShipRootAbstract { + protected: + /** Protected Default Constructor to ensure this class is abtract. */ + FacRelationShipRootAbstract () {} + FacRelationShipRootAbstract (const FacRelationShipRootAbstract&) {} + public: + /** Destructor. */ + virtual ~FacRelationShipRootAbstract() {} + }; + +} +#endif // __INTRUSIVE_BOM_RELATIONSHIPABSTRACT_HPP Added: trunk/stdair/test/archi_intru/FacSupervisor.cpp =================================================================== --- trunk/stdair/test/archi_intru/FacSupervisor.cpp (rev 0) +++ trunk/stdair/test/archi_intru/FacSupervisor.cpp 2010-09-12 14:43:43 UTC (rev 319) @@ -0,0 +1,57 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +// Local +#include <test/archi_intru/FacRelationShipRootAbstract.hpp> +#include <test/archi_intru/FacSupervisor.hpp> + +namespace stdair { + + FacSupervisor* FacSupervisor::_instance = NULL; + + // ////////////////////////////////////////////////////////////////////// + FacSupervisor& FacSupervisor::instance() { + if (_instance == NULL) { + _instance = new FacSupervisor(); + } + + return *_instance; + } + + // ////////////////////////////////////////////////////////////////////// + FacSupervisor::~FacSupervisor() { + cleanFacRelationShipRoots(); + } + + // ////////////////////////////////////////////////////////////////////// + void FacSupervisor:: + registerFacRelationShipRoot (FacRelationShipRootAbstract* ioFacRelationShipRoot_ptr) { + _facRelationShipRootPool.push_back (ioFacRelationShipRoot_ptr); + } + + // ////////////////////////////////////////////////////////////////////// + void FacSupervisor::cleanFacRelationShipRoots() { + for (FacRelationShipRootPool_T::const_iterator itRS = + _facRelationShipRootPool.begin(); + itRS != _facRelationShipRootPool.end(); ++itRS) { + const FacRelationShipRootAbstract* currentFacRelationShipRoot_ptr = *itRS; + assert (currentFacRelationShipRoot_ptr != NULL); + + delete currentFacRelationShipRoot_ptr; currentFacRelationShipRoot_ptr = NULL; + } + + // Empty the pool of relations ships + _facRelationShipRootPool.clear(); + } + + // ////////////////////////////////////////////////////////////////////// + void FacSupervisor::cleanAll () { + // Clean the static instance of the FacSupervisor. + // This in turn will invoke the destructor (~FacSupervisor() method) + // of the static instance. + delete _instance; _instance = NULL; + } + +} Added: trunk/stdair/test/archi_intru/FacSupervisor.hpp =================================================================== --- trunk/stdair/test/archi_intru/FacSupervisor.hpp (rev 0) +++ trunk/stdair/test/archi_intru/FacSupervisor.hpp 2010-09-12 14:43:43 UTC (rev 319) @@ -0,0 +1,57 @@ +#ifndef __INTRUSIVE_SVC_FACSUPERVISOR_HPP +#define __INTRUSIVE_SVC_FACSUPERVISOR_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <list> + +namespace stdair { + + // Forward declarations + class FacRelationShipRootAbstract; + + /** Singleton class to register and clean all Factories. */ + class FacSupervisor { + public: + /** Define the pool (list) of factories. */ + typedef std::list<FacRelationShipRootAbstract*> FacRelationShipRootPool_T; + + /** Provide the unique (static) instance of the FacSupervisor object. + <br>The singleton is instantiated when first used. + @return FacSupervisor& */ + static FacSupervisor& instance(); + + /** Register a newly instantiated concrete relation ship factory. */ + void registerFacRelationShipRoot (FacRelationShipRootAbstract*); + + /** Clean all registered relation ships. */ + void cleanFacRelationShipRoots(); + + /** Clean the static instance. + <br>As the static instance (singleton) is deleted, all the other + registered objects will be deleted in turn. */ + static void cleanAll (); + + /** Destructor. + <br>That destructors is applied on the static instance. It then + deletes in turn all the other registered objects. */ + ~FacSupervisor(); + + + protected: + /** Default Constructor. + <br>This constructor is protected + to ensure the singleton pattern. */ + FacSupervisor () {} + FacSupervisor (const FacSupervisor&) {} + + private: + /** The unique instance.*/ + static FacSupervisor* _instance; + /** List of instantiated relation ships. */ + FacRelationShipRootPool_T _facRelationShipRootPool; + }; +} +#endif // __INTRUSIVE_SVC_FACSUPERVISOR_HPP Added: trunk/stdair/test/archi_intru/RelationShipHolder.hpp =================================================================== --- trunk/stdair/test/archi_intru/RelationShipHolder.hpp (rev 0) +++ trunk/stdair/test/archi_intru/RelationShipHolder.hpp 2010-09-12 14:43:43 UTC (rev 319) @@ -0,0 +1,38 @@ +#ifndef __INTRUSIVE_BOM_RELATIONSHIPHOLDER_HPP +#define __INTRUSIVE_BOM_RELATIONSHIPHOLDER_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// Boost.Intrusive +#include <boost/intrusive/list.hpp> + +/** Alias for the boost::intrusive namespace. */ +namespace bi = boost::intrusive; + +namespace stdair { + + /** Class holding relationship objects between either a parent Bom and its + children or a Bom object and its siblings. */ + template <typename FIRST_BOM, typename SECOND_BOM> + class RelationShipHolder { + public: + // /////////////////////////////////////////// + /** Type definition for a list of either children or siblings. */ + typedef bi::list<SECOND_BOM> SecondBomList_T; + + /** Type definition for a relationship, holding a list of children + or siblings for a given parent/Bom object. + <br>The list has got only two elements. A list is used only because + the pair does not exist (yet?) within boost::intrusive. */ + typedef bi::list<FIRST_BOM, SecondBomList_T> RelationShip_T; + // /////////////////////////////////////////// + + private: + /** Relationship, holding a list of children or siblings for a + given parent/Bom object. */ + RelationShip_T _relationShip; + }; + +} +#endif // __INTRUSIVE_BOM_RELATIONSHIPHOLDER_HPP Modified: trunk/stdair/test/archi_intru/archi.cpp =================================================================== --- trunk/stdair/test/archi_intru/archi.cpp 2010-09-12 13:25:36 UTC (rev 318) +++ trunk/stdair/test/archi_intru/archi.cpp 2010-09-12 14:43:43 UTC (rev 319) @@ -8,6 +8,7 @@ #include <boost/intrusive/list.hpp> // Local #include <test/archi_intru/FlightDate.hpp> +//#include <test/archi_intru/FacRelationShipRoot.hpp> /** Alias for the boost::intrusive namespace. */ namespace bi = boost::intrusive; Modified: trunk/stdair/test/archi_intru/sources.mk =================================================================== --- trunk/stdair/test/archi_intru/sources.mk 2010-09-12 13:25:36 UTC (rev 318) +++ trunk/stdair/test/archi_intru/sources.mk 2010-09-12 14:43:43 UTC (rev 319) @@ -1,8 +1,13 @@ archi_intru_h_sources = \ + $(top_srcdir)/test/archi_intru/FacSupervisor.hpp \ + $(top_srcdir)/test/archi_intru/FacRelationShipRoot.hpp \ + $(top_srcdir)/test/archi_intru/FacRelationShipRootAbstract.hpp \ + $(top_srcdir)/test/archi_intru/RelationShipHolder.hpp \ $(top_srcdir)/test/archi_intru/BomAbstract.hpp \ $(top_srcdir)/test/archi_intru/BomRoot.hpp \ $(top_srcdir)/test/archi_intru/FlightDate.hpp \ $(top_srcdir)/test/archi_intru/LegDate.hpp \ $(top_srcdir)/test/archi_intru/SegmentDate.hpp archi_intru_cc_sources = \ + $(top_srcdir)/test/archi_intru/FacSupervisor.cpp \ $(top_srcdir)/test/archi_intru/archi.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-09-12 16:23:54
|
Revision: 320 http://stdair.svn.sourceforge.net/stdair/?rev=320&view=rev Author: denis_arnaud Date: 2010-09-12 16:23:47 +0000 (Sun, 12 Sep 2010) Log Message: ----------- [Test] Added a test sub-directory for Boost.Intrusive-based architecture. Modified Paths: -------------- trunk/stdair/test/archi_intru/FlightDate.hpp trunk/stdair/test/archi_intru/Makefile.am trunk/stdair/test/archi_intru/archi.cpp trunk/stdair/test/archi_intru/sources.mk Added Paths: ----------- trunk/stdair/test/archi_intru/TestManager.cpp trunk/stdair/test/archi_intru/TestManager.hpp Modified: trunk/stdair/test/archi_intru/FlightDate.hpp =================================================================== --- trunk/stdair/test/archi_intru/FlightDate.hpp 2010-09-12 14:43:43 UTC (rev 319) +++ trunk/stdair/test/archi_intru/FlightDate.hpp 2010-09-12 16:23:47 UTC (rev 320) @@ -53,12 +53,17 @@ /** Get a string describing the key. */ const std::string describeKey() const { return _key; } }; + + // ///////////////// Type definitions ///////////// + /** Standard (STL) list (vector) of BOM FlightDate objects (pointers). */ + typedef std::vector<stdair::FlightDate*> FlightDateVector_T; - /** List of child-type FlightDate objects. */ + /** (Boost.Intrusive) List of child-type FlightDate objects. */ typedef bi::member_hook <FlightDate, bi::list_member_hook<>, &FlightDate::_childListHook> FlightDateListMemberOption; typedef bi::list<FlightDate, FlightDateListMemberOption> FlightDateChildList; + /** (Boost.Intrusive) Set of child-type FlightDate objects. */ typedef bi::member_hook <FlightDate, bi::set_member_hook<>, &FlightDate::_childSetHook> FlightDateSetMemberOption; typedef bi::set<FlightDate, FlightDateSetMemberOption> FlightDateChildSet; Modified: trunk/stdair/test/archi_intru/Makefile.am =================================================================== --- trunk/stdair/test/archi_intru/Makefile.am 2010-09-12 14:43:43 UTC (rev 319) +++ trunk/stdair/test/archi_intru/Makefile.am 2010-09-12 16:23:47 UTC (rev 320) @@ -10,12 +10,22 @@ EXTRA_DIST = ## +## +# Test library +noinst_LTLIBRARIES = libarchiintru.la + +libarchiintru_la_SOURCES = $(archi_intru_h_sources) $(archi_intru_cc_sources) +libarchiintru_la_CXXFLAGS = $(BOOST_CFLAGS) +libarchiintru_la_LDFLAGS = $(BOOST_LIBS) + +## +# Test binary check_PROGRAMS = archi #TESTS = $(check_PROGRAMS) TESTS = XFAIL_TESTS = #IndexBuildingTestSuite -archi_SOURCES = $(archi_intru_h_sources) $(archi_intru_cc_sources) -archi_CXXFLAGS = $(BOOST_CFLAGS) -archi_LDFLAGS = $(BOOST_LIBS) +archi_SOURCES = archi.cpp +archi_CXXFLAGS = archi_LDADD = +archi_LDFLAGS = $(top_builddir)/test/archi_intru/libarchiintru.la Added: trunk/stdair/test/archi_intru/TestManager.cpp =================================================================== Added: trunk/stdair/test/archi_intru/TestManager.hpp =================================================================== --- trunk/stdair/test/archi_intru/TestManager.hpp (rev 0) +++ trunk/stdair/test/archi_intru/TestManager.hpp 2010-09-12 16:23:47 UTC (rev 320) @@ -0,0 +1,172 @@ +#ifndef __LATUS_STDAIR_TST_TESTMANAGER_HPP +#define __LATUS_STDAIR_TST_TESTMANAGER_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <iostream> +#include <sstream> +#include <string> +#include <vector> +// Boost +#include <boost/intrusive/list.hpp> +// Local +#include <test/archi_intru/FlightDate.hpp> +//#include <test/archi_intru/FacRelationShipRoot.hpp> + +/** Alias for the boost::intrusive namespace. */ +namespace bi = boost::intrusive; + +/** Class wrapping test functions. */ +class TestManager { +public: + /** Destructor. */ + ~TestManager() { clean(); } + +public: + /** Fill the standard (STL) vector. */ + void initStandard() { + // Create several FlightDate objects, each one with a different value + for (int idx = 0; idx < 100; ++idx) { + stdair::FlightDate* lFlightDate_ptr = new stdair::FlightDate (idx); + assert (lFlightDate_ptr != NULL); + + _flightDateVector.push_back (lFlightDate_ptr); + } + } + + /** Fill the (Boost) Intrusive list (and set). */ + void initIntrusive() { + // Now insert them in the same order as in vector in the member hook list + for (stdair::FlightDateVector_T::iterator itFlight (_flightDateVector.begin()), + itend (_flightDateVector.end()); itFlight != itend; ++itFlight) { + stdair::FlightDate* lFlightDate_ptr = *itFlight; + assert (lFlightDate_ptr != NULL); + + _flightDateChildList.push_back (*lFlightDate_ptr); + _flightDateChildSet.insert (*lFlightDate_ptr); + } + + // DEBUG + /* + std::cout << "Size of the Boost.Intrusive list of FlightDate objects: " + << lFlightDateChildList.size() << std::endl; + std::cout << "Size of the Boost.Intrusive set of FlightDate objects: " + << lFlightDateChildSet.size() << std::endl; + */ + } + + /** Some memory cleaning. + <br>Note: the FlightDate objects cannot be simply deleted (with the + delete opearator). + <br>See also, for more details: + - http://www.boost.org/doc/libs/1_44_0/doc/html/intrusive/usage.html#intrusive.usage.usage_lifetime + - http://www.boost.org/doc/libs/1_44_0/doc/html/intrusive/erasing_and_disposing.html + <br>First, clear simply all the Boost.Intrusive containers but one. Then, + clear the last Boost.Intrusive container while deleting the corresponding + hooked objects. + */ + void clean() { + _flightDateChildSet.clear(); + _flightDateChildList.clear_and_dispose (delete_disposer<stdair::FlightDate>()); + } + + /** Optimized search functions */ + stdair::FlightDate* getFromSet (const std::string& iKey) { + stdair::FlightDate* oFlightDate_ptr = NULL; + stdair::FlightDateChildSet::iterator itFlight = + _flightDateChildSet.find (iKey, StrExpComp<stdair::FlightDate>()); + if (itFlight == _flightDateChildSet.end()) { + return oFlightDate_ptr; + } + oFlightDate_ptr = &*itFlight; + return oFlightDate_ptr; + } + + /** Test (Boost) Intrusive lists. */ + bool testIntrusiveList() { + bool oTestSuccessfull = true; + + stdair::FlightDateChildList::iterator mit (_flightDateChildList.begin()), + mitend (_flightDateChildList.end()); + stdair::FlightDateVector_T::iterator itFlight (_flightDateVector.begin()), + itend (_flightDateVector.end()); + + // Test the objects inserted in the member hook list + for (itFlight = _flightDateVector.begin(); + itFlight != itend; ++itFlight, ++mit) { + stdair::FlightDate* lFlightDate_ptr = *itFlight; + assert (lFlightDate_ptr != NULL); + + if (&*mit != lFlightDate_ptr) { + oTestSuccessfull = false; + break; + } + } + + return oTestSuccessfull; + } + + /** Test (Boost) Intrusive iterator_to(). */ + bool testIntrusiveIteratorTo() { + bool oTestSuccessfull = true; + + stdair::FlightDateChildList::iterator itChild(_flightDateChildList.begin()); + for (int idx = 0; idx < 100; ++idx, ++itChild) { + stdair::FlightDate* lFlightDate_ptr = _flightDateVector.at(idx); + assert (lFlightDate_ptr != NULL); + + if (_flightDateChildList.iterator_to (*lFlightDate_ptr) != itChild || + stdair::FlightDateChildList::s_iterator_to(*lFlightDate_ptr) != itChild) { + oTestSuccessfull = false; + break; + } + } + + return oTestSuccessfull; + } + + /** Test (Boost) Intrusive sets. */ + bool testIntrusiveSets() { + bool oTestSuccessfull = true; + + stdair::FlightDateChildSet::iterator itChild (_flightDateChildSet.begin()), + itChildEnd (_flightDateChildSet.end()); + for (; itChild != itChildEnd; ++itChild) { + const stdair::FlightDate& lFlightDate = *itChild; + + const std::string& lKey = lFlightDate.getKey(); + stdair::FlightDate* retrievedFlightDate_ptr = getFromSet (lKey); + + // DEBUG + /* + std::cout << "Key = '" << lKey << "', itFD = " + << &lFlightDate << ", retrieved: " << retrievedFlightDate_ptr + << std::endl; + */ + + if (retrievedFlightDate_ptr == NULL || + _flightDateChildSet.iterator_to (lFlightDate) != itChild || + _flightDateChildSet.iterator_to (*retrievedFlightDate_ptr) != itChild || + stdair::FlightDateChildSet::s_iterator_to (lFlightDate) != itChild || + stdair::FlightDateChildSet::s_iterator_to(*retrievedFlightDate_ptr) != itChild) { + oTestSuccessfull = false; + break; + } + } + + return oTestSuccessfull; + } + +public: + // Standard STL container + stdair::FlightDateVector_T _flightDateVector; + + // (Boost) Intrusive container + stdair::FlightDateChildList _flightDateChildList; + stdair::FlightDateChildSet _flightDateChildSet; +}; + +#endif // __LATUS_STDAIR_TST_TESTMANAGER_HPP Modified: trunk/stdair/test/archi_intru/archi.cpp =================================================================== --- trunk/stdair/test/archi_intru/archi.cpp 2010-09-12 14:43:43 UTC (rev 319) +++ trunk/stdair/test/archi_intru/archi.cpp 2010-09-12 16:23:47 UTC (rev 320) @@ -7,26 +7,11 @@ // Boost #include <boost/intrusive/list.hpp> // Local -#include <test/archi_intru/FlightDate.hpp> -//#include <test/archi_intru/FacRelationShipRoot.hpp> +#include <test/archi_intru/TestManager.hpp> /** Alias for the boost::intrusive namespace. */ namespace bi = boost::intrusive; - -// Optimized search functions -stdair::FlightDate* getFromSet(const std::string& iKey, - stdair::FlightDateChildSet& ioFlightDateChildSet) { - stdair::FlightDate* oFlightDate_ptr = NULL; - stdair::FlightDateChildSet::iterator itFlight = - ioFlightDateChildSet.find (iKey, StrExpComp<stdair::FlightDate>()); - if (itFlight == ioFlightDateChildSet.end()) { - return oFlightDate_ptr; - } - oFlightDate_ptr = &*itFlight; - return oFlightDate_ptr; -} - // /////////////////////////// M A I N ///////////////////////// /** Main. <br>Run with the following command: @@ -37,115 +22,21 @@ int main (int argc, char* argv[]) { // - typedef std::vector<stdair::FlightDate*> FlightDateVector_T; - - // Standard STL container - FlightDateVector_T lFlightDateVector; + TestManager lTestManager; - // Create several FlightDate objects, each one with a different value - for (int idx = 0; idx < 100; ++idx) { - stdair::FlightDate* lFlightDate_ptr = new stdair::FlightDate (idx); - assert (lFlightDate_ptr != NULL); - - lFlightDateVector.push_back (lFlightDate_ptr); - } + // Fill the standard (STL) vector + lTestManager.initStandard(); - // (Boost) Intrusive container - stdair::FlightDateChildList lFlightDateChildList; - stdair::FlightDateChildSet lFlightDateChildSet; - - // Now insert them in the same order as in vector in the member hook list - for (FlightDateVector_T::iterator itFlight (lFlightDateVector.begin()), - itend (lFlightDateVector.end()); itFlight != itend; ++itFlight) { - stdair::FlightDate* lFlightDate_ptr = *itFlight; - assert (lFlightDate_ptr != NULL); - - lFlightDateChildList.push_back (*lFlightDate_ptr); - lFlightDateChildSet.insert (*lFlightDate_ptr); - } - - // DEBUG - /* - std::cout << "Size of the Boost.Intrusive list of FlightDate objects: " - << lFlightDateChildList.size() << std::endl; - std::cout << "Size of the Boost.Intrusive set of FlightDate objects: " - << lFlightDateChildSet.size() << std::endl; - */ - + lTestManager.initIntrusive(); + // Now test lists - { - stdair::FlightDateChildList::iterator mit (lFlightDateChildList.begin()), - mitend (lFlightDateChildList.end()); - FlightDateVector_T::iterator itFlight (lFlightDateVector.begin()), - itend (lFlightDateVector.end()); - - // Test the objects inserted in the member hook list - for (itFlight = lFlightDateVector.begin(); - itFlight != itend; ++itFlight, ++mit) { - stdair::FlightDate* lFlightDate_ptr = *itFlight; - assert (lFlightDate_ptr != NULL); - - if (&*mit != lFlightDate_ptr) { - return 1; - } - } - } - + lTestManager.testIntrusiveList(); + // Now, test iterator_to() - { - stdair::FlightDateChildList::iterator itChild(lFlightDateChildList.begin()); - for (int idx = 0; idx < 100; ++idx, ++itChild) { - stdair::FlightDate* lFlightDate_ptr = lFlightDateVector.at(idx); - assert (lFlightDate_ptr != NULL); - - if (lFlightDateChildList.iterator_to (*lFlightDate_ptr) != itChild || - stdair::FlightDateChildList::s_iterator_to(*lFlightDate_ptr) != itChild) { - return 1; - } - } - } - + lTestManager.testIntrusiveIteratorTo(); + // Now, test sets - { - stdair::FlightDateChildSet::iterator itChild (lFlightDateChildSet.begin()), - itChildEnd (lFlightDateChildSet.end()); - for (; itChild != itChildEnd; ++itChild) { - const stdair::FlightDate& lFlightDate = *itChild; - - const std::string& lKey = lFlightDate.getKey(); - stdair::FlightDate* retrievedFlightDate_ptr = - getFromSet (lKey, lFlightDateChildSet); - - // DEBUG - /* - std::cout << "Key = '" << lKey << "', itFD = " - << &lFlightDate << ", retrieved: " << retrievedFlightDate_ptr - << std::endl; - */ - - if (retrievedFlightDate_ptr == NULL || - lFlightDateChildSet.iterator_to (lFlightDate) != itChild || - lFlightDateChildSet.iterator_to (*retrievedFlightDate_ptr) != itChild || - stdair::FlightDateChildSet::s_iterator_to (lFlightDate) != itChild || - stdair::FlightDateChildSet::s_iterator_to(*retrievedFlightDate_ptr) != itChild) { - return 1; - } - } - } + lTestManager.testIntrusiveSets(); - - /** Some memory cleaning. - <br>Note: the FlightDate objects cannot be simply deleted (with the - delete opearator). - <br>See also, for more details: - - http://www.boost.org/doc/libs/1_44_0/doc/html/intrusive/usage.html#intrusive.usage.usage_lifetime - - http://www.boost.org/doc/libs/1_44_0/doc/html/intrusive/erasing_and_disposing.html - <br>First, clear simply all the Boost.Intrusive containers but one. Then, - clear the last Boost.Intrusive container while deleting the corresponding - hooked objects. - */ - lFlightDateChildSet.clear(); - lFlightDateChildList.clear_and_dispose(delete_disposer<stdair::FlightDate>()); - return 0; } Modified: trunk/stdair/test/archi_intru/sources.mk =================================================================== --- trunk/stdair/test/archi_intru/sources.mk 2010-09-12 14:43:43 UTC (rev 319) +++ trunk/stdair/test/archi_intru/sources.mk 2010-09-12 16:23:47 UTC (rev 320) @@ -7,7 +7,8 @@ $(top_srcdir)/test/archi_intru/BomRoot.hpp \ $(top_srcdir)/test/archi_intru/FlightDate.hpp \ $(top_srcdir)/test/archi_intru/LegDate.hpp \ - $(top_srcdir)/test/archi_intru/SegmentDate.hpp + $(top_srcdir)/test/archi_intru/SegmentDate.hpp \ + $(top_srcdir)/test/archi_intru/TestManager.hpp archi_intru_cc_sources = \ $(top_srcdir)/test/archi_intru/FacSupervisor.cpp \ - $(top_srcdir)/test/archi_intru/archi.cpp + $(top_srcdir)/test/archi_intru/TestManager.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-09-12 16:40:37
|
Revision: 321 http://stdair.svn.sourceforge.net/stdair/?rev=321&view=rev Author: denis_arnaud Date: 2010-09-12 16:40:31 +0000 (Sun, 12 Sep 2010) Log Message: ----------- [Test] Added a test sub-directory for Boost.Intrusive-based architecture. Modified Paths: -------------- trunk/stdair/test/archi_intru/FlightDate.hpp trunk/stdair/test/archi_intru/TestManager.cpp trunk/stdair/test/archi_intru/TestManager.hpp trunk/stdair/test/archi_intru/archi.cpp Modified: trunk/stdair/test/archi_intru/FlightDate.hpp =================================================================== --- trunk/stdair/test/archi_intru/FlightDate.hpp 2010-09-12 16:23:47 UTC (rev 320) +++ trunk/stdair/test/archi_intru/FlightDate.hpp 2010-09-12 16:40:31 UTC (rev 321) @@ -5,8 +5,8 @@ // Import section // ////////////////////////////////////////////////////////////////////// // STL -#include <cassert> #include <string> +#include <vector> // Boost.Intrusive #include <boost/intrusive/list.hpp> #include <boost/intrusive/set.hpp> @@ -67,5 +67,6 @@ typedef bi::member_hook <FlightDate, bi::set_member_hook<>, &FlightDate::_childSetHook> FlightDateSetMemberOption; typedef bi::set<FlightDate, FlightDateSetMemberOption> FlightDateChildSet; + } #endif // __INTRUSIVE_BOM_FLIGHTDATE_HPP Modified: trunk/stdair/test/archi_intru/TestManager.cpp =================================================================== --- trunk/stdair/test/archi_intru/TestManager.cpp 2010-09-12 16:23:47 UTC (rev 320) +++ trunk/stdair/test/archi_intru/TestManager.cpp 2010-09-12 16:40:31 UTC (rev 321) @@ -0,0 +1,153 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <iostream> +#include <sstream> +#include <string> +#include <vector> +// Boost +#include <boost/intrusive/list.hpp> +// Local +#include <test/archi_intru/FlightDate.hpp> +#include <test/archi_intru/TestManager.hpp> + +/** Alias for the boost::intrusive namespace. */ +namespace bi = boost::intrusive; + +// ////////////////////////////////////////////////////////////////////// +TestManager::~TestManager() { + clean(); +} + +// ////////////////////////////////////////////////////////////////////// +void TestManager::init() { + initStandard(); + initIntrusive(); +} + +// ////////////////////////////////////////////////////////////////////// +void TestManager::initStandard() { + // Create several FlightDate objects, each one with a different value + for (int idx = 0; idx < 100; ++idx) { + stdair::FlightDate* lFlightDate_ptr = new stdair::FlightDate (idx); + assert (lFlightDate_ptr != NULL); + + _flightDateVector.push_back (lFlightDate_ptr); + } +} + +// ////////////////////////////////////////////////////////////////////// +void TestManager::initIntrusive() { + // Now insert them in the same order as in vector in the member hook list + for (stdair::FlightDateVector_T::iterator itFlight(_flightDateVector.begin()), + itend (_flightDateVector.end()); itFlight != itend; ++itFlight) { + stdair::FlightDate* lFlightDate_ptr = *itFlight; + assert (lFlightDate_ptr != NULL); + + _flightDateChildList.push_back (*lFlightDate_ptr); + _flightDateChildSet.insert (*lFlightDate_ptr); + } + + // DEBUG + /* + std::cout << "Size of the Boost.Intrusive list of FlightDate objects: " + << lFlightDateChildList.size() << std::endl; + std::cout << "Size of the Boost.Intrusive set of FlightDate objects: " + << lFlightDateChildSet.size() << std::endl; + */ +} + +// ////////////////////////////////////////////////////////////////////// +void TestManager::clean() { + _flightDateChildSet.clear(); + _flightDateChildList.clear_and_dispose(delete_disposer<stdair::FlightDate>()); +} + +// ////////////////////////////////////////////////////////////////////// +stdair::FlightDate* TestManager::getFromSet (const std::string& iKey) { + stdair::FlightDate* oFlightDate_ptr = NULL; + stdair::FlightDateChildSet::iterator itFlight = + _flightDateChildSet.find (iKey, StrExpComp<stdair::FlightDate>()); + if (itFlight == _flightDateChildSet.end()) { + return oFlightDate_ptr; + } + oFlightDate_ptr = &*itFlight; + return oFlightDate_ptr; +} + +// ////////////////////////////////////////////////////////////////////// +bool TestManager::testIntrusiveList() { + bool oTestSuccessfull = true; + + stdair::FlightDateChildList::iterator mit (_flightDateChildList.begin()), + mitend (_flightDateChildList.end()); + stdair::FlightDateVector_T::iterator itFlight (_flightDateVector.begin()), + itend (_flightDateVector.end()); + + // Test the objects inserted in the member hook list + for (itFlight = _flightDateVector.begin(); + itFlight != itend; ++itFlight, ++mit) { + stdair::FlightDate* lFlightDate_ptr = *itFlight; + assert (lFlightDate_ptr != NULL); + + if (&*mit != lFlightDate_ptr) { + oTestSuccessfull = false; + break; + } + } + + return oTestSuccessfull; +} + +// ////////////////////////////////////////////////////////////////////// +bool TestManager::testIntrusiveIteratorTo() { + bool oTestSuccessfull = true; + + stdair::FlightDateChildList::iterator itChild(_flightDateChildList.begin()); + for (int idx = 0; idx < 100; ++idx, ++itChild) { + stdair::FlightDate* lFlightDate_ptr = _flightDateVector.at(idx); + assert (lFlightDate_ptr != NULL); + + if (_flightDateChildList.iterator_to (*lFlightDate_ptr) != itChild || + stdair::FlightDateChildList::s_iterator_to(*lFlightDate_ptr)!= itChild){ + oTestSuccessfull = false; + break; + } + } + + return oTestSuccessfull; +} + +// ////////////////////////////////////////////////////////////////////// +bool TestManager::testIntrusiveSets() { + bool oTestSuccessfull = true; + + stdair::FlightDateChildSet::iterator itChild (_flightDateChildSet.begin()), + itChildEnd (_flightDateChildSet.end()); + for (; itChild != itChildEnd; ++itChild) { + const stdair::FlightDate& lFlightDate = *itChild; + + const std::string& lKey = lFlightDate.getKey(); + stdair::FlightDate* retrievedFlightDate_ptr = getFromSet (lKey); + + // DEBUG + /* + std::cout << "Key = '" << lKey << "', itFD = " + << &lFlightDate << ", retrieved: " << retrievedFlightDate_ptr + << std::endl; + */ + + if (retrievedFlightDate_ptr == NULL || + _flightDateChildSet.iterator_to (lFlightDate) != itChild || + _flightDateChildSet.iterator_to (*retrievedFlightDate_ptr) != itChild || + stdair::FlightDateChildSet::s_iterator_to (lFlightDate) != itChild || + stdair::FlightDateChildSet::s_iterator_to(*retrievedFlightDate_ptr) != itChild) { + oTestSuccessfull = false; + break; + } + } + + return oTestSuccessfull; +} Modified: trunk/stdair/test/archi_intru/TestManager.hpp =================================================================== --- trunk/stdair/test/archi_intru/TestManager.hpp 2010-09-12 16:23:47 UTC (rev 320) +++ trunk/stdair/test/archi_intru/TestManager.hpp 2010-09-12 16:40:31 UTC (rev 321) @@ -1,63 +1,31 @@ -#ifndef __LATUS_STDAIR_TST_TESTMANAGER_HPP -#define __LATUS_STDAIR_TST_TESTMANAGER_HPP +#ifndef __INTRUSIVE_TST_TESTMANAGER_HPP +#define __INTRUSIVE_TST_TESTMANAGER_HPP // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// // STL -#include <cassert> -#include <iostream> -#include <sstream> #include <string> -#include <vector> -// Boost -#include <boost/intrusive/list.hpp> // Local #include <test/archi_intru/FlightDate.hpp> -//#include <test/archi_intru/FacRelationShipRoot.hpp> -/** Alias for the boost::intrusive namespace. */ -namespace bi = boost::intrusive; - /** Class wrapping test functions. */ class TestManager { public: /** Destructor. */ - ~TestManager() { clean(); } + ~TestManager(); public: + /** Initialise the internal vector, list and set. */ + void init(); + +private: /** Fill the standard (STL) vector. */ - void initStandard() { - // Create several FlightDate objects, each one with a different value - for (int idx = 0; idx < 100; ++idx) { - stdair::FlightDate* lFlightDate_ptr = new stdair::FlightDate (idx); - assert (lFlightDate_ptr != NULL); - - _flightDateVector.push_back (lFlightDate_ptr); - } - } + void initStandard(); /** Fill the (Boost) Intrusive list (and set). */ - void initIntrusive() { - // Now insert them in the same order as in vector in the member hook list - for (stdair::FlightDateVector_T::iterator itFlight (_flightDateVector.begin()), - itend (_flightDateVector.end()); itFlight != itend; ++itFlight) { - stdair::FlightDate* lFlightDate_ptr = *itFlight; - assert (lFlightDate_ptr != NULL); - - _flightDateChildList.push_back (*lFlightDate_ptr); - _flightDateChildSet.insert (*lFlightDate_ptr); - } - - // DEBUG - /* - std::cout << "Size of the Boost.Intrusive list of FlightDate objects: " - << lFlightDateChildList.size() << std::endl; - std::cout << "Size of the Boost.Intrusive set of FlightDate objects: " - << lFlightDateChildSet.size() << std::endl; - */ - } - + void initIntrusive(); + /** Some memory cleaning. <br>Note: the FlightDate objects cannot be simply deleted (with the delete opearator). @@ -68,99 +36,22 @@ clear the last Boost.Intrusive container while deleting the corresponding hooked objects. */ - void clean() { - _flightDateChildSet.clear(); - _flightDateChildList.clear_and_dispose (delete_disposer<stdair::FlightDate>()); - } - + void clean(); + +public: /** Optimized search functions */ - stdair::FlightDate* getFromSet (const std::string& iKey) { - stdair::FlightDate* oFlightDate_ptr = NULL; - stdair::FlightDateChildSet::iterator itFlight = - _flightDateChildSet.find (iKey, StrExpComp<stdair::FlightDate>()); - if (itFlight == _flightDateChildSet.end()) { - return oFlightDate_ptr; - } - oFlightDate_ptr = &*itFlight; - return oFlightDate_ptr; - } + stdair::FlightDate* getFromSet (const std::string& iKey); /** Test (Boost) Intrusive lists. */ - bool testIntrusiveList() { - bool oTestSuccessfull = true; - - stdair::FlightDateChildList::iterator mit (_flightDateChildList.begin()), - mitend (_flightDateChildList.end()); - stdair::FlightDateVector_T::iterator itFlight (_flightDateVector.begin()), - itend (_flightDateVector.end()); + bool testIntrusiveList(); - // Test the objects inserted in the member hook list - for (itFlight = _flightDateVector.begin(); - itFlight != itend; ++itFlight, ++mit) { - stdair::FlightDate* lFlightDate_ptr = *itFlight; - assert (lFlightDate_ptr != NULL); - - if (&*mit != lFlightDate_ptr) { - oTestSuccessfull = false; - break; - } - } - - return oTestSuccessfull; - } - /** Test (Boost) Intrusive iterator_to(). */ - bool testIntrusiveIteratorTo() { - bool oTestSuccessfull = true; - - stdair::FlightDateChildList::iterator itChild(_flightDateChildList.begin()); - for (int idx = 0; idx < 100; ++idx, ++itChild) { - stdair::FlightDate* lFlightDate_ptr = _flightDateVector.at(idx); - assert (lFlightDate_ptr != NULL); - - if (_flightDateChildList.iterator_to (*lFlightDate_ptr) != itChild || - stdair::FlightDateChildList::s_iterator_to(*lFlightDate_ptr) != itChild) { - oTestSuccessfull = false; - break; - } - } - - return oTestSuccessfull; - } + bool testIntrusiveIteratorTo(); /** Test (Boost) Intrusive sets. */ - bool testIntrusiveSets() { - bool oTestSuccessfull = true; + bool testIntrusiveSets(); - stdair::FlightDateChildSet::iterator itChild (_flightDateChildSet.begin()), - itChildEnd (_flightDateChildSet.end()); - for (; itChild != itChildEnd; ++itChild) { - const stdair::FlightDate& lFlightDate = *itChild; - - const std::string& lKey = lFlightDate.getKey(); - stdair::FlightDate* retrievedFlightDate_ptr = getFromSet (lKey); - - // DEBUG - /* - std::cout << "Key = '" << lKey << "', itFD = " - << &lFlightDate << ", retrieved: " << retrievedFlightDate_ptr - << std::endl; - */ - - if (retrievedFlightDate_ptr == NULL || - _flightDateChildSet.iterator_to (lFlightDate) != itChild || - _flightDateChildSet.iterator_to (*retrievedFlightDate_ptr) != itChild || - stdair::FlightDateChildSet::s_iterator_to (lFlightDate) != itChild || - stdair::FlightDateChildSet::s_iterator_to(*retrievedFlightDate_ptr) != itChild) { - oTestSuccessfull = false; - break; - } - } - - return oTestSuccessfull; - } - -public: +private: // Standard STL container stdair::FlightDateVector_T _flightDateVector; @@ -169,4 +60,4 @@ stdair::FlightDateChildSet _flightDateChildSet; }; -#endif // __LATUS_STDAIR_TST_TESTMANAGER_HPP +#endif // __INTRUSIVE_TST_TESTMANAGER_HPP Modified: trunk/stdair/test/archi_intru/archi.cpp =================================================================== --- trunk/stdair/test/archi_intru/archi.cpp 2010-09-12 16:23:47 UTC (rev 320) +++ trunk/stdair/test/archi_intru/archi.cpp 2010-09-12 16:40:31 UTC (rev 321) @@ -1,17 +1,12 @@ // STL #include <cassert> -#include <iostream> -#include <sstream> -#include <string> -#include <vector> -// Boost -#include <boost/intrusive/list.hpp> +//#include <iostream> +//#include <sstream> +//#include <string> +//#include <vector> // Local #include <test/archi_intru/TestManager.hpp> -/** Alias for the boost::intrusive namespace. */ -namespace bi = boost::intrusive; - // /////////////////////////// M A I N ///////////////////////// /** Main. <br>Run with the following command: @@ -24,10 +19,8 @@ // TestManager lTestManager; - // Fill the standard (STL) vector - lTestManager.initStandard(); - - lTestManager.initIntrusive(); + // Initialise the internal (STL) vector, (Boost.Intrusive) list and set + lTestManager.init(); // Now test lists lTestManager.testIntrusiveList(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-09-12 17:03:40
|
Revision: 322 http://stdair.svn.sourceforge.net/stdair/?rev=322&view=rev Author: denis_arnaud Date: 2010-09-12 17:03:33 +0000 (Sun, 12 Sep 2010) Log Message: ----------- [Test] Added a test sub-directory for Boost.Intrusive-based architecture. Modified Paths: -------------- trunk/stdair/test/archi_intru/archi.cpp trunk/stdair/test/archi_intru/sources.mk Added Paths: ----------- trunk/stdair/test/archi_intru/TestIntrusive.cpp trunk/stdair/test/archi_intru/TestIntrusive.hpp Removed Paths: ------------- trunk/stdair/test/archi_intru/TestManager.cpp trunk/stdair/test/archi_intru/TestManager.hpp Copied: trunk/stdair/test/archi_intru/TestIntrusive.cpp (from rev 321, trunk/stdair/test/archi_intru/TestManager.cpp) =================================================================== --- trunk/stdair/test/archi_intru/TestIntrusive.cpp (rev 0) +++ trunk/stdair/test/archi_intru/TestIntrusive.cpp 2010-09-12 17:03:33 UTC (rev 322) @@ -0,0 +1,175 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <iostream> +#include <sstream> +#include <string> +#include <vector> +// Boost +#include <boost/intrusive/list.hpp> +// Local +#include <test/archi_intru/FlightDate.hpp> +#include <test/archi_intru/TestIntrusive.hpp> + +/** Alias for the boost::intrusive namespace. */ +namespace bi = boost::intrusive; + +// ////////////////////////////////////////////////////////////////////// +TestIntrusive::~TestIntrusive() { + clean(); +} + +// ////////////////////////////////////////////////////////////////////// +void TestIntrusive::init() { + initStandard(); + initIntrusive(); +} + +// ////////////////////////////////////////////////////////////////////// +void TestIntrusive::initStandard() { + // Create several FlightDate objects, each one with a different value + for (int idx = 0; idx < 100; ++idx) { + stdair::FlightDate* lFlightDate_ptr = new stdair::FlightDate (idx); + assert (lFlightDate_ptr != NULL); + + _flightDateVector.push_back (lFlightDate_ptr); + } +} + +// ////////////////////////////////////////////////////////////////////// +void TestIntrusive::initIntrusive() { + // Now insert them in the same order as in vector in the member hook list + for (stdair::FlightDateVector_T::iterator itFlight(_flightDateVector.begin()), + itend (_flightDateVector.end()); itFlight != itend; ++itFlight) { + stdair::FlightDate* lFlightDate_ptr = *itFlight; + assert (lFlightDate_ptr != NULL); + + _flightDateChildList.push_back (*lFlightDate_ptr); + _flightDateChildSet.insert (*lFlightDate_ptr); + } + + // DEBUG + /* + std::cout << "Size of the Boost.Intrusive list of FlightDate objects: " + << lFlightDateChildList.size() << std::endl; + std::cout << "Size of the Boost.Intrusive set of FlightDate objects: " + << lFlightDateChildSet.size() << std::endl; + */ +} + +// ////////////////////////////////////////////////////////////////////// +void TestIntrusive::clean() { + _flightDateChildSet.clear(); + _flightDateChildList.clear_and_dispose(delete_disposer<stdair::FlightDate>()); +} + +// ////////////////////////////////////////////////////////////////////// +stdair::FlightDate* TestIntrusive::getFromSet (const std::string& iKey) { + stdair::FlightDate* oFlightDate_ptr = NULL; + stdair::FlightDateChildSet::iterator itFlight = + _flightDateChildSet.find (iKey, StrExpComp<stdair::FlightDate>()); + if (itFlight == _flightDateChildSet.end()) { + return oFlightDate_ptr; + } + oFlightDate_ptr = &*itFlight; + return oFlightDate_ptr; +} + +// ////////////////////////////////////////////////////////////////////// +bool TestIntrusive::testIntrusiveList() { + bool oTestSuccessfull = true; + + stdair::FlightDateChildList::iterator mit (_flightDateChildList.begin()), + mitend (_flightDateChildList.end()); + stdair::FlightDateVector_T::iterator itFlight (_flightDateVector.begin()), + itend (_flightDateVector.end()); + + // Test the objects inserted in the member hook list + for (itFlight = _flightDateVector.begin(); + itFlight != itend; ++itFlight, ++mit) { + stdair::FlightDate* lFlightDate_ptr = *itFlight; + assert (lFlightDate_ptr != NULL); + + if (&*mit != lFlightDate_ptr) { + oTestSuccessfull = false; + break; + } + } + + return oTestSuccessfull; +} + +// ////////////////////////////////////////////////////////////////////// +bool TestIntrusive::testIntrusiveIteratorTo() { + bool oTestSuccessfull = true; + + stdair::FlightDateChildList::iterator itChild(_flightDateChildList.begin()); + for (int idx = 0; idx < 100; ++idx, ++itChild) { + stdair::FlightDate* lFlightDate_ptr = _flightDateVector.at(idx); + assert (lFlightDate_ptr != NULL); + + if (_flightDateChildList.iterator_to (*lFlightDate_ptr) != itChild || + stdair::FlightDateChildList::s_iterator_to(*lFlightDate_ptr)!= itChild){ + oTestSuccessfull = false; + break; + } + } + + return oTestSuccessfull; +} + +// ////////////////////////////////////////////////////////////////////// +bool TestIntrusive::testIntrusiveSets() { + bool oTestSuccessfull = true; + + stdair::FlightDateChildSet::iterator itChild (_flightDateChildSet.begin()), + itChildEnd (_flightDateChildSet.end()); + for (; itChild != itChildEnd; ++itChild) { + const stdair::FlightDate& lFlightDate = *itChild; + + const std::string& lKey = lFlightDate.getKey(); + stdair::FlightDate* retrievedFlightDate_ptr = getFromSet (lKey); + + // DEBUG + /* + std::cout << "Key = '" << lKey << "', itFD = " + << &lFlightDate << ", retrieved: " << retrievedFlightDate_ptr + << std::endl; + */ + + if (retrievedFlightDate_ptr == NULL || + _flightDateChildSet.iterator_to (lFlightDate) != itChild || + _flightDateChildSet.iterator_to (*retrievedFlightDate_ptr) != itChild || + stdair::FlightDateChildSet::s_iterator_to (lFlightDate) != itChild || + stdair::FlightDateChildSet::s_iterator_to(*retrievedFlightDate_ptr) != itChild) { + oTestSuccessfull = false; + break; + } + } + + return oTestSuccessfull; +} + +// ////////////////////////////////////////////////////////////////////// +bool TestIntrusive::test() { + bool oTestSuccessfull = true; + + // + TestIntrusive lTestIntrusive; + + // Initialise the internal (STL) vector, (Boost.Intrusive) list and set + lTestIntrusive.init(); + + // Now test lists + lTestIntrusive.testIntrusiveList(); + + // Now, test iterator_to() + lTestIntrusive.testIntrusiveIteratorTo(); + + // Now, test sets + lTestIntrusive.testIntrusiveSets(); + + return oTestSuccessfull; +} Copied: trunk/stdair/test/archi_intru/TestIntrusive.hpp (from rev 321, trunk/stdair/test/archi_intru/TestManager.hpp) =================================================================== --- trunk/stdair/test/archi_intru/TestIntrusive.hpp (rev 0) +++ trunk/stdair/test/archi_intru/TestIntrusive.hpp 2010-09-12 17:03:33 UTC (rev 322) @@ -0,0 +1,66 @@ +#ifndef __INTRUSIVE_TST_TESTINTRUSIVE_HPP +#define __INTRUSIVE_TST_TESTINTRUSIVE_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <string> +// Local +#include <test/archi_intru/FlightDate.hpp> + +/** Class wrapping test functions. */ +class TestIntrusive { +public: + /** Destructor. */ + ~TestIntrusive(); + +public: + /** Perform the full test set. */ + static bool test(); + +private: + /** Initialise the internal vector, list and set. */ + void init(); + + /** Fill the standard (STL) vector. */ + void initStandard(); + + /** Fill the (Boost) Intrusive list (and set). */ + void initIntrusive(); + + /** Some memory cleaning. + <br>Note: the FlightDate objects cannot be simply deleted (with the + delete opearator). + <br>See also, for more details: + - http://www.boost.org/doc/libs/1_44_0/doc/html/intrusive/usage.html#intrusive.usage.usage_lifetime + - http://www.boost.org/doc/libs/1_44_0/doc/html/intrusive/erasing_and_disposing.html + <br>First, clear simply all the Boost.Intrusive containers but one. Then, + clear the last Boost.Intrusive container while deleting the corresponding + hooked objects. + */ + void clean(); + +private: + /** Optimized search functions */ + stdair::FlightDate* getFromSet (const std::string& iKey); + + /** Test (Boost) Intrusive lists. */ + bool testIntrusiveList(); + + /** Test (Boost) Intrusive iterator_to(). */ + bool testIntrusiveIteratorTo(); + + /** Test (Boost) Intrusive sets. */ + bool testIntrusiveSets(); + +private: + // Standard STL container + stdair::FlightDateVector_T _flightDateVector; + + // (Boost) Intrusive container + stdair::FlightDateChildList _flightDateChildList; + stdair::FlightDateChildSet _flightDateChildSet; +}; + +#endif // __INTRUSIVE_TST_TESTINTRUSIVE_HPP Deleted: trunk/stdair/test/archi_intru/TestManager.cpp =================================================================== --- trunk/stdair/test/archi_intru/TestManager.cpp 2010-09-12 16:40:31 UTC (rev 321) +++ trunk/stdair/test/archi_intru/TestManager.cpp 2010-09-12 17:03:33 UTC (rev 322) @@ -1,153 +0,0 @@ -// ////////////////////////////////////////////////////////////////////// -// Import section -// ////////////////////////////////////////////////////////////////////// -// STL -#include <cassert> -#include <iostream> -#include <sstream> -#include <string> -#include <vector> -// Boost -#include <boost/intrusive/list.hpp> -// Local -#include <test/archi_intru/FlightDate.hpp> -#include <test/archi_intru/TestManager.hpp> - -/** Alias for the boost::intrusive namespace. */ -namespace bi = boost::intrusive; - -// ////////////////////////////////////////////////////////////////////// -TestManager::~TestManager() { - clean(); -} - -// ////////////////////////////////////////////////////////////////////// -void TestManager::init() { - initStandard(); - initIntrusive(); -} - -// ////////////////////////////////////////////////////////////////////// -void TestManager::initStandard() { - // Create several FlightDate objects, each one with a different value - for (int idx = 0; idx < 100; ++idx) { - stdair::FlightDate* lFlightDate_ptr = new stdair::FlightDate (idx); - assert (lFlightDate_ptr != NULL); - - _flightDateVector.push_back (lFlightDate_ptr); - } -} - -// ////////////////////////////////////////////////////////////////////// -void TestManager::initIntrusive() { - // Now insert them in the same order as in vector in the member hook list - for (stdair::FlightDateVector_T::iterator itFlight(_flightDateVector.begin()), - itend (_flightDateVector.end()); itFlight != itend; ++itFlight) { - stdair::FlightDate* lFlightDate_ptr = *itFlight; - assert (lFlightDate_ptr != NULL); - - _flightDateChildList.push_back (*lFlightDate_ptr); - _flightDateChildSet.insert (*lFlightDate_ptr); - } - - // DEBUG - /* - std::cout << "Size of the Boost.Intrusive list of FlightDate objects: " - << lFlightDateChildList.size() << std::endl; - std::cout << "Size of the Boost.Intrusive set of FlightDate objects: " - << lFlightDateChildSet.size() << std::endl; - */ -} - -// ////////////////////////////////////////////////////////////////////// -void TestManager::clean() { - _flightDateChildSet.clear(); - _flightDateChildList.clear_and_dispose(delete_disposer<stdair::FlightDate>()); -} - -// ////////////////////////////////////////////////////////////////////// -stdair::FlightDate* TestManager::getFromSet (const std::string& iKey) { - stdair::FlightDate* oFlightDate_ptr = NULL; - stdair::FlightDateChildSet::iterator itFlight = - _flightDateChildSet.find (iKey, StrExpComp<stdair::FlightDate>()); - if (itFlight == _flightDateChildSet.end()) { - return oFlightDate_ptr; - } - oFlightDate_ptr = &*itFlight; - return oFlightDate_ptr; -} - -// ////////////////////////////////////////////////////////////////////// -bool TestManager::testIntrusiveList() { - bool oTestSuccessfull = true; - - stdair::FlightDateChildList::iterator mit (_flightDateChildList.begin()), - mitend (_flightDateChildList.end()); - stdair::FlightDateVector_T::iterator itFlight (_flightDateVector.begin()), - itend (_flightDateVector.end()); - - // Test the objects inserted in the member hook list - for (itFlight = _flightDateVector.begin(); - itFlight != itend; ++itFlight, ++mit) { - stdair::FlightDate* lFlightDate_ptr = *itFlight; - assert (lFlightDate_ptr != NULL); - - if (&*mit != lFlightDate_ptr) { - oTestSuccessfull = false; - break; - } - } - - return oTestSuccessfull; -} - -// ////////////////////////////////////////////////////////////////////// -bool TestManager::testIntrusiveIteratorTo() { - bool oTestSuccessfull = true; - - stdair::FlightDateChildList::iterator itChild(_flightDateChildList.begin()); - for (int idx = 0; idx < 100; ++idx, ++itChild) { - stdair::FlightDate* lFlightDate_ptr = _flightDateVector.at(idx); - assert (lFlightDate_ptr != NULL); - - if (_flightDateChildList.iterator_to (*lFlightDate_ptr) != itChild || - stdair::FlightDateChildList::s_iterator_to(*lFlightDate_ptr)!= itChild){ - oTestSuccessfull = false; - break; - } - } - - return oTestSuccessfull; -} - -// ////////////////////////////////////////////////////////////////////// -bool TestManager::testIntrusiveSets() { - bool oTestSuccessfull = true; - - stdair::FlightDateChildSet::iterator itChild (_flightDateChildSet.begin()), - itChildEnd (_flightDateChildSet.end()); - for (; itChild != itChildEnd; ++itChild) { - const stdair::FlightDate& lFlightDate = *itChild; - - const std::string& lKey = lFlightDate.getKey(); - stdair::FlightDate* retrievedFlightDate_ptr = getFromSet (lKey); - - // DEBUG - /* - std::cout << "Key = '" << lKey << "', itFD = " - << &lFlightDate << ", retrieved: " << retrievedFlightDate_ptr - << std::endl; - */ - - if (retrievedFlightDate_ptr == NULL || - _flightDateChildSet.iterator_to (lFlightDate) != itChild || - _flightDateChildSet.iterator_to (*retrievedFlightDate_ptr) != itChild || - stdair::FlightDateChildSet::s_iterator_to (lFlightDate) != itChild || - stdair::FlightDateChildSet::s_iterator_to(*retrievedFlightDate_ptr) != itChild) { - oTestSuccessfull = false; - break; - } - } - - return oTestSuccessfull; -} Deleted: trunk/stdair/test/archi_intru/TestManager.hpp =================================================================== --- trunk/stdair/test/archi_intru/TestManager.hpp 2010-09-12 16:40:31 UTC (rev 321) +++ trunk/stdair/test/archi_intru/TestManager.hpp 2010-09-12 17:03:33 UTC (rev 322) @@ -1,63 +0,0 @@ -#ifndef __INTRUSIVE_TST_TESTMANAGER_HPP -#define __INTRUSIVE_TST_TESTMANAGER_HPP - -// ////////////////////////////////////////////////////////////////////// -// Import section -// ////////////////////////////////////////////////////////////////////// -// STL -#include <string> -// Local -#include <test/archi_intru/FlightDate.hpp> - -/** Class wrapping test functions. */ -class TestManager { -public: - /** Destructor. */ - ~TestManager(); - -public: - /** Initialise the internal vector, list and set. */ - void init(); - -private: - /** Fill the standard (STL) vector. */ - void initStandard(); - - /** Fill the (Boost) Intrusive list (and set). */ - void initIntrusive(); - - /** Some memory cleaning. - <br>Note: the FlightDate objects cannot be simply deleted (with the - delete opearator). - <br>See also, for more details: - - http://www.boost.org/doc/libs/1_44_0/doc/html/intrusive/usage.html#intrusive.usage.usage_lifetime - - http://www.boost.org/doc/libs/1_44_0/doc/html/intrusive/erasing_and_disposing.html - <br>First, clear simply all the Boost.Intrusive containers but one. Then, - clear the last Boost.Intrusive container while deleting the corresponding - hooked objects. - */ - void clean(); - -public: - /** Optimized search functions */ - stdair::FlightDate* getFromSet (const std::string& iKey); - - /** Test (Boost) Intrusive lists. */ - bool testIntrusiveList(); - - /** Test (Boost) Intrusive iterator_to(). */ - bool testIntrusiveIteratorTo(); - - /** Test (Boost) Intrusive sets. */ - bool testIntrusiveSets(); - -private: - // Standard STL container - stdair::FlightDateVector_T _flightDateVector; - - // (Boost) Intrusive container - stdair::FlightDateChildList _flightDateChildList; - stdair::FlightDateChildSet _flightDateChildSet; -}; - -#endif // __INTRUSIVE_TST_TESTMANAGER_HPP Modified: trunk/stdair/test/archi_intru/archi.cpp =================================================================== --- trunk/stdair/test/archi_intru/archi.cpp 2010-09-12 16:40:31 UTC (rev 321) +++ trunk/stdair/test/archi_intru/archi.cpp 2010-09-12 17:03:33 UTC (rev 322) @@ -5,7 +5,9 @@ //#include <string> //#include <vector> // Local -#include <test/archi_intru/TestManager.hpp> +#include <test/archi_intru/TestIntrusive.hpp> +#include <test/archi_intru/BomRoot.hpp> +#include <test/archi_intru/FlightDate.hpp> // /////////////////////////// M A I N ///////////////////////// /** Main. @@ -17,19 +19,7 @@ int main (int argc, char* argv[]) { // - TestManager lTestManager; + TestIntrusive::test(); - // Initialise the internal (STL) vector, (Boost.Intrusive) list and set - lTestManager.init(); - - // Now test lists - lTestManager.testIntrusiveList(); - - // Now, test iterator_to() - lTestManager.testIntrusiveIteratorTo(); - - // Now, test sets - lTestManager.testIntrusiveSets(); - return 0; } Modified: trunk/stdair/test/archi_intru/sources.mk =================================================================== --- trunk/stdair/test/archi_intru/sources.mk 2010-09-12 16:40:31 UTC (rev 321) +++ trunk/stdair/test/archi_intru/sources.mk 2010-09-12 17:03:33 UTC (rev 322) @@ -8,7 +8,7 @@ $(top_srcdir)/test/archi_intru/FlightDate.hpp \ $(top_srcdir)/test/archi_intru/LegDate.hpp \ $(top_srcdir)/test/archi_intru/SegmentDate.hpp \ - $(top_srcdir)/test/archi_intru/TestManager.hpp + $(top_srcdir)/test/archi_intru/TestIntrusive.hpp archi_intru_cc_sources = \ $(top_srcdir)/test/archi_intru/FacSupervisor.cpp \ - $(top_srcdir)/test/archi_intru/TestManager.cpp + $(top_srcdir)/test/archi_intru/TestIntrusive.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-09-12 17:23:14
|
Revision: 323 http://stdair.svn.sourceforge.net/stdair/?rev=323&view=rev Author: denis_arnaud Date: 2010-09-12 17:23:08 +0000 (Sun, 12 Sep 2010) Log Message: ----------- [Test] Added a test sub-directory for Boost.Intrusive-based architecture. Modified Paths: -------------- trunk/stdair/test/archi_intru/archi.cpp trunk/stdair/test/archi_intru/sources.mk Added Paths: ----------- trunk/stdair/test/archi_intru/TestBomUsage.cpp trunk/stdair/test/archi_intru/TestBomUsage.hpp Copied: trunk/stdair/test/archi_intru/TestBomUsage.cpp (from rev 322, trunk/stdair/test/archi_intru/TestIntrusive.cpp) =================================================================== --- trunk/stdair/test/archi_intru/TestBomUsage.cpp (rev 0) +++ trunk/stdair/test/archi_intru/TestBomUsage.cpp 2010-09-12 17:23:08 UTC (rev 323) @@ -0,0 +1,38 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <iostream> +#include <sstream> +#include <string> +#include <vector> +// Boost +#include <boost/intrusive/list.hpp> +// Local +#include <test/archi_intru/FlightDate.hpp> +#include <test/archi_intru/TestBomUsage.hpp> + +/** Alias for the boost::intrusive namespace. */ +namespace bi = boost::intrusive; + +// ////////////////////////////////////////////////////////////////////// +TestBomUsage::~TestBomUsage() { + clean(); +} + +// ////////////////////////////////////////////////////////////////////// +void TestBomUsage::init() { +} + +// ////////////////////////////////////////////////////////////////////// +void TestBomUsage::clean() { +} + +// ////////////////////////////////////////////////////////////////////// +bool TestBomUsage::test() { + bool oTestSuccessfull = true; + + + return oTestSuccessfull; +} Copied: trunk/stdair/test/archi_intru/TestBomUsage.hpp (from rev 322, trunk/stdair/test/archi_intru/TestIntrusive.hpp) =================================================================== --- trunk/stdair/test/archi_intru/TestBomUsage.hpp (rev 0) +++ trunk/stdair/test/archi_intru/TestBomUsage.hpp 2010-09-12 17:23:08 UTC (rev 323) @@ -0,0 +1,32 @@ +#ifndef __INTRUSIVE_TST_TESTBOMUSAGE_HPP +#define __INTRUSIVE_TST_TESTBOMUSAGE_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <string> +// Local +#include <test/archi_intru/FlightDate.hpp> + +/** Class wrapping test functions. */ +class TestBomUsage { +public: + /** Destructor. */ + ~TestBomUsage(); + +public: + /** Perform the full test set. */ + static bool test(); + +private: + /** Initialise. */ + void init(); + + /** Cleaning. */ + void clean(); + +private: +}; + +#endif // __INTRUSIVE_TST_TESTBOMUSAGE_HPP Modified: trunk/stdair/test/archi_intru/archi.cpp =================================================================== --- trunk/stdair/test/archi_intru/archi.cpp 2010-09-12 17:03:33 UTC (rev 322) +++ trunk/stdair/test/archi_intru/archi.cpp 2010-09-12 17:23:08 UTC (rev 323) @@ -6,8 +6,7 @@ //#include <vector> // Local #include <test/archi_intru/TestIntrusive.hpp> -#include <test/archi_intru/BomRoot.hpp> -#include <test/archi_intru/FlightDate.hpp> +#include <test/archi_intru/TestBomUsage.hpp> // /////////////////////////// M A I N ///////////////////////// /** Main. @@ -19,7 +18,15 @@ int main (int argc, char* argv[]) { // - TestIntrusive::test(); + const bool lTestIntrusiveSuccessfull = TestIntrusive::test(); + // + const bool lTestBomUsageSuccessfull = TestBomUsage::test(); + + if (lTestIntrusiveSuccessfull == false + || lTestBomUsageSuccessfull == false) { + return 1; + } + return 0; } Modified: trunk/stdair/test/archi_intru/sources.mk =================================================================== --- trunk/stdair/test/archi_intru/sources.mk 2010-09-12 17:03:33 UTC (rev 322) +++ trunk/stdair/test/archi_intru/sources.mk 2010-09-12 17:23:08 UTC (rev 323) @@ -8,7 +8,9 @@ $(top_srcdir)/test/archi_intru/FlightDate.hpp \ $(top_srcdir)/test/archi_intru/LegDate.hpp \ $(top_srcdir)/test/archi_intru/SegmentDate.hpp \ - $(top_srcdir)/test/archi_intru/TestIntrusive.hpp + $(top_srcdir)/test/archi_intru/TestIntrusive.hpp \ + $(top_srcdir)/test/archi_intru/TestBomUsage.hpp archi_intru_cc_sources = \ $(top_srcdir)/test/archi_intru/FacSupervisor.cpp \ - $(top_srcdir)/test/archi_intru/TestIntrusive.cpp + $(top_srcdir)/test/archi_intru/TestIntrusive.cpp \ + $(top_srcdir)/test/archi_intru/TestBomUsage.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-09-12 19:11:50
|
Revision: 324 http://stdair.svn.sourceforge.net/stdair/?rev=324&view=rev Author: denis_arnaud Date: 2010-09-12 19:11:43 +0000 (Sun, 12 Sep 2010) Log Message: ----------- [Test] Added a test sub-directory for Boost.Intrusive-based architecture. Modified Paths: -------------- trunk/stdair/test/archi_intru/BomAbstract.hpp trunk/stdair/test/archi_intru/BomRoot.hpp trunk/stdair/test/archi_intru/FacRelationShipRoot.hpp trunk/stdair/test/archi_intru/FacRelationShipRootAbstract.hpp trunk/stdair/test/archi_intru/FacSupervisor.cpp trunk/stdair/test/archi_intru/FacSupervisor.hpp trunk/stdair/test/archi_intru/RelationShipHolder.hpp trunk/stdair/test/archi_intru/TestBomUsage.cpp trunk/stdair/test/archi_intru/TestBomUsage.hpp trunk/stdair/test/archi_intru/TestIntrusive.cpp trunk/stdair/test/archi_intru/sources.mk Added Paths: ----------- trunk/stdair/test/archi_intru/FacAbstract.hpp trunk/stdair/test/archi_intru/FacBom.hpp trunk/stdair/test/archi_intru/IntrusiveHelper.hpp trunk/stdair/test/archi_intru/RelationShipHolderAbstract.hpp Modified: trunk/stdair/test/archi_intru/BomAbstract.hpp =================================================================== --- trunk/stdair/test/archi_intru/BomAbstract.hpp 2010-09-12 17:23:08 UTC (rev 323) +++ trunk/stdair/test/archi_intru/BomAbstract.hpp 2010-09-12 19:11:43 UTC (rev 324) @@ -121,36 +121,4 @@ return ioIn; } - -/** The disposer object function. */ -template <typename BOM> -struct delete_disposer { - void operator() (BOM* oBOM_ptr) { - delete oBOM_ptr; oBOM_ptr = NULL; - } -}; - -// These compare (STL strings) keys of BOM objects -template <typename BOM> -struct StrExpComp { - bool operator() (const std::string& iKey, const BOM& iBom) const { - return (iKey < iBom.getKey()); - } - - bool operator() (const BOM& iBom, const std::string& iKey) const { - return (iBom.getKey() < iKey); - } -}; - -template <typename BOM> -struct StrExpEqual { - bool operator() (const std::string& iKey, const BOM& iBom) const { - return (iKey == iBom.getKey()); - } - - bool operator() (const BOM& iBom, const std::string& iKey) const { - return (iBom.getKey() == iKey); - } -}; - #endif // __INTRUSIVE_BOM_BOMABSTRACT_HPP Modified: trunk/stdair/test/archi_intru/BomRoot.hpp =================================================================== --- trunk/stdair/test/archi_intru/BomRoot.hpp 2010-09-12 17:23:08 UTC (rev 323) +++ trunk/stdair/test/archi_intru/BomRoot.hpp 2010-09-12 19:11:43 UTC (rev 324) @@ -7,9 +7,15 @@ // STL #include <cassert> #include <string> -// +// Boost.Intrusive +#include <boost/intrusive/list.hpp> +#include <boost/intrusive/set.hpp> +// Local #include <test/archi_intru/BomAbstract.hpp> +/** Alias for the boost::intrusive namespace. */ +namespace bi = boost::intrusive; + namespace stdair { /** BomRoot. */ @@ -19,6 +25,10 @@ BomRoot (const int idx) : BomAbstract (idx) {} public: + bi::list_member_hook<> _childListHook; + bi::set_member_hook<> _childSetHook; + + public: // /////////// Display support methods ///////// /** Dump a Business Object into an output stream. @param ostream& the output stream. */ Added: trunk/stdair/test/archi_intru/FacAbstract.hpp =================================================================== --- trunk/stdair/test/archi_intru/FacAbstract.hpp (rev 0) +++ trunk/stdair/test/archi_intru/FacAbstract.hpp 2010-09-12 19:11:43 UTC (rev 324) @@ -0,0 +1,22 @@ +#ifndef __INTRUSIVE_FAC_FACABSTRACT_HPP +#define __INTRUSIVE_FAC_FACABSTRACT_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// + +namespace stdair { + + /** Base class for Factory layer. */ + class FacAbstract { + public: + /** Destructor. */ + virtual ~FacAbstract() {} + + protected: + /** Default Constructor. + <br>This constructor is protected to ensure the class is abstract. */ + FacAbstract() {} + }; +} +#endif // __INTRUSIVE_FAC_FACABSTRACT_HPP Added: trunk/stdair/test/archi_intru/FacBom.hpp =================================================================== --- trunk/stdair/test/archi_intru/FacBom.hpp (rev 0) +++ trunk/stdair/test/archi_intru/FacBom.hpp 2010-09-12 19:11:43 UTC (rev 324) @@ -0,0 +1,90 @@ +#ifndef __INTRUSIVE_FAC_FACBOM_HPP +#define __INTRUSIVE_FAC_FACBOM_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <string> +// StdAir +#include <test/archi_intru/FacAbstract.hpp> +#include <test/archi_intru/FacSupervisor.hpp> + +namespace stdair { + + /** Class for handling the memory related to BOM objects. */ + template <typename BOM> + class FacBom : public FacAbstract { + // Internal type definitions. + typedef std::list<BOM*> BomPool_T; + + public: + // ///////////// Business methods. //////////// + /** Provide the unique instance. + <br>The singleton is instantiated when first used. + @return FacBom& */ + static FacBom& instance() { + if (_instance == NULL) { + _instance = new FacBom (); + assert (_instance != NULL); + + FacSupervisor::instance().registerFacBom (_instance); + } + return *_instance; + } + + /** Create a BOM object for a given key. */ + BOM& create (const std::string& iKey) { + BOM* oBom_ptr = new BOM (iKey); + assert (oBom_ptr != NULL); + _pool.push_back (oBom_ptr); + return *oBom_ptr; + } + + /** Create a BOM object for a given key. */ + BOM& create (const int& idx) { + BOM* oBom_ptr = new BOM (idx); + assert (oBom_ptr != NULL); + _pool.push_back (oBom_ptr); + return *oBom_ptr; + } + + protected: + /** Default Constructor. + <br>This constructor is protected to ensure the class is . */ + FacBom() {} + + public: + /** Destructor. */ + ~FacBom() { clean(); } + + /** Destroyed all the object instantiated by this factory. */ + void clean() { + // Destroy all the objects + for (typename BomPool_T::iterator itBom = _pool.begin(); + itBom != _pool.end(); ++itBom) { + BOM* currentBom_ptr = *itBom; + assert (currentBom_ptr != NULL); + delete currentBom_ptr; currentBom_ptr = NULL; + } + + // Empty the pool. + _pool.clear(); + + // Reset the static instance. + _instance = NULL; + } + + private: + /** The unique instance.*/ + static FacBom* _instance; + /** List of instantiated Business Objects*/ + BomPool_T _pool; + }; + + // //////////////////////////////////////////////////////////////////// + template <typename BOM> FacBom<BOM>* FacBom<BOM>::_instance = NULL; + +} +#endif // __INTRUSIVE_FAC_FACBOM_HPP Modified: trunk/stdair/test/archi_intru/FacRelationShipRoot.hpp =================================================================== --- trunk/stdair/test/archi_intru/FacRelationShipRoot.hpp 2010-09-12 17:23:08 UTC (rev 323) +++ trunk/stdair/test/archi_intru/FacRelationShipRoot.hpp 2010-09-12 19:11:43 UTC (rev 324) @@ -9,6 +9,7 @@ #include <boost/intrusive/set.hpp> // Local #include <test/archi_intru/FacSupervisor.hpp> +#include <test/archi_intru/FacRelationShipRootAbstract.hpp> #include <test/archi_intru/RelationShipHolder.hpp> /** Alias for the boost::intrusive namespace. */ @@ -18,15 +19,24 @@ /** Class holding the list of all the relationship objects of a given type. */ template <typename FIRST_BOM, typename SECOND_BOM> - class FacRelationShipRoot { + class FacRelationShipRoot : public FacRelationShipRootAbstract { public: // /////////////////////////////////////////// + /** Type definition for the specific relationship. */ + typedef RelationShipHolder<FIRST_BOM, SECOND_BOM> RelationShipHolder_T; + /** Type definition for a list of relationship holder objects. */ - typedef bi::list<RelationShipHolder<FIRST_BOM, - SECOND_BOM> > RelationShipHolderList_T; + typedef bi::member_hook <RelationShipHolder_T, + bi::list_member_hook<>, + &RelationShipHolder_T::_childListHook> RSHolderListMemberOption; + typedef bi::list<RelationShipHolder_T, + RSHolderListMemberOption> RelationShipHolderList_T; /** Type definition for a set of relationship holder objects. */ - typedef bi::set<RelationShipHolder<FIRST_BOM, - SECOND_BOM> > RelationShipHolderSet_T; + typedef bi::member_hook <RelationShipHolder_T, + bi::set_member_hook<>, + &RelationShipHolder_T::_childSetHook> RSHolderSetMemberOption; + typedef bi::set<RelationShipHolder_T, + RSHolderSetMemberOption> RelationShipHolderSet_T; // /////////////////////////////////////////// public: @@ -51,8 +61,10 @@ /** Add a child/sibling to the dedicated list of the parent/sibling. */ void addToListImpl (FIRST_BOM& ioFirstBom, SECOND_BOM& ioSecondBom) { - _relationShipHolderList.push_back (ioFirstBom, ioSecondBom); - _relationShipHolderSet.insert (ioFirstBom, ioSecondBom); + RelationShipHolder_T* lRS_ptr = new RelationShipHolder_T (ioFirstBom, + ioSecondBom); + _relationShipHolderList.push_back (*lRS_ptr); + _relationShipHolderSet.insert (*lRS_ptr); } private: Modified: trunk/stdair/test/archi_intru/FacRelationShipRootAbstract.hpp =================================================================== --- trunk/stdair/test/archi_intru/FacRelationShipRootAbstract.hpp 2010-09-12 17:23:08 UTC (rev 323) +++ trunk/stdair/test/archi_intru/FacRelationShipRootAbstract.hpp 2010-09-12 19:11:43 UTC (rev 324) @@ -1,5 +1,5 @@ -#ifndef __INTRUSIVE_BOM_RELATIONSHIPABSTRACT_HPP -#define __INTRUSIVE_BOM_RELATIONSHIPABSTRACT_HPP +#ifndef __INTRUSIVE_BOM_FACRELATIONSHIPROOTABSTRACT_HPP +#define __INTRUSIVE_BOM_FACRELATIONSHIPROOTABSTRACT_HPP // ////////////////////////////////////////////////////////////////////// // Import section @@ -7,8 +7,6 @@ // STL #include <iosfwd> #include <string> -// StdAir -#include <stdair/STDAIR_Types.hpp> namespace stdair { @@ -26,4 +24,4 @@ }; } -#endif // __INTRUSIVE_BOM_RELATIONSHIPABSTRACT_HPP +#endif // __INTRUSIVE_BOM_FACRELATIONSHIPROOTABSTRACT_HPP Modified: trunk/stdair/test/archi_intru/FacSupervisor.cpp =================================================================== --- trunk/stdair/test/archi_intru/FacSupervisor.cpp 2010-09-12 17:23:08 UTC (rev 323) +++ trunk/stdair/test/archi_intru/FacSupervisor.cpp 2010-09-12 19:11:43 UTC (rev 324) @@ -5,6 +5,7 @@ #include <cassert> // Local #include <test/archi_intru/FacRelationShipRootAbstract.hpp> +#include <test/archi_intru/FacAbstract.hpp> #include <test/archi_intru/FacSupervisor.hpp> namespace stdair { @@ -22,16 +23,38 @@ // ////////////////////////////////////////////////////////////////////// FacSupervisor::~FacSupervisor() { + cleanBomLayer(); cleanFacRelationShipRoots(); } // ////////////////////////////////////////////////////////////////////// void FacSupervisor:: + registerFacBom (FacAbstract* ioFac_ptr) { + _facPool.push_back (ioFac_ptr); + } + + // ////////////////////////////////////////////////////////////////////// + void FacSupervisor:: registerFacRelationShipRoot (FacRelationShipRootAbstract* ioFacRelationShipRoot_ptr) { _facRelationShipRootPool.push_back (ioFacRelationShipRoot_ptr); } // ////////////////////////////////////////////////////////////////////// + void FacSupervisor::cleanBomLayer() { + for (FactoryPool_T::const_iterator itFactory = + _facPool.begin(); + itFactory != _facPool.end(); itFactory++) { + const FacAbstract* currentFactory_ptr = *itFactory; + assert (currentFactory_ptr != NULL); + + delete (currentFactory_ptr); currentFactory_ptr = NULL; + } + + // Empty the pool of factories + _facPool.clear(); + } + + // ////////////////////////////////////////////////////////////////////// void FacSupervisor::cleanFacRelationShipRoots() { for (FacRelationShipRootPool_T::const_iterator itRS = _facRelationShipRootPool.begin(); Modified: trunk/stdair/test/archi_intru/FacSupervisor.hpp =================================================================== --- trunk/stdair/test/archi_intru/FacSupervisor.hpp 2010-09-12 17:23:08 UTC (rev 323) +++ trunk/stdair/test/archi_intru/FacSupervisor.hpp 2010-09-12 19:11:43 UTC (rev 324) @@ -10,12 +10,14 @@ namespace stdair { // Forward declarations + class FacAbstract; class FacRelationShipRootAbstract; /** Singleton class to register and clean all Factories. */ class FacSupervisor { public: /** Define the pool (list) of factories. */ + typedef std::list<FacAbstract*> FactoryPool_T; typedef std::list<FacRelationShipRootAbstract*> FacRelationShipRootPool_T; /** Provide the unique (static) instance of the FacSupervisor object. @@ -23,9 +25,21 @@ @return FacSupervisor& */ static FacSupervisor& instance(); + /** Register a newly instantiated concrete factory for the + Bom layer. + <br>When a concrete Factory is firstly instantiated + this factory have to register itself to the FacSupervisor + @param FacBom* The concrete Factory to register. */ + void registerFacBom (FacAbstract*); + /** Register a newly instantiated concrete relation ship factory. */ void registerFacRelationShipRoot (FacRelationShipRootAbstract*); + /** Clean all registered object. + <br>Call the clean method of all the instantiated factories + for the BomStructure layer. */ + void cleanBomLayer(); + /** Clean all registered relation ships. */ void cleanFacRelationShipRoots(); @@ -50,6 +64,8 @@ private: /** The unique instance.*/ static FacSupervisor* _instance; + /** List of instantiated factories for the BOM layer. */ + FactoryPool_T _facPool; /** List of instantiated relation ships. */ FacRelationShipRootPool_T _facRelationShipRootPool; }; Added: trunk/stdair/test/archi_intru/IntrusiveHelper.hpp =================================================================== --- trunk/stdair/test/archi_intru/IntrusiveHelper.hpp (rev 0) +++ trunk/stdair/test/archi_intru/IntrusiveHelper.hpp 2010-09-12 19:11:43 UTC (rev 324) @@ -0,0 +1,44 @@ +#ifndef __INTRUSIVE_BOM_INTRUSIVEHELPER_HPP +#define __INTRUSIVE_BOM_INTRUSIVEHELPER_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <iosfwd> +#include <sstream> +#include <string> + +/** The disposer object function. */ +template <typename NODE> +struct delete_disposer { + void operator() (NODE* oNODE_ptr) { + delete oNODE_ptr; oNODE_ptr = NULL; + } +}; + +// These compare (STL strings) keys of NODE objects +template <typename NODE> +struct StrExpComp { + bool operator() (const std::string& iKey, const NODE& iBom) const { + return (iKey < iBom.getKey()); + } + + bool operator() (const NODE& iBom, const std::string& iKey) const { + return (iBom.getKey() < iKey); + } +}; + +template <typename NODE> +struct StrExpEqual { + bool operator() (const std::string& iKey, const NODE& iBom) const { + return (iKey == iBom.getKey()); + } + + bool operator() (const NODE& iBom, const std::string& iKey) const { + return (iBom.getKey() == iKey); + } +}; + +#endif // __INTRUSIVE_BOM_INTRUSIVEHELPER_HPP Modified: trunk/stdair/test/archi_intru/RelationShipHolder.hpp =================================================================== --- trunk/stdair/test/archi_intru/RelationShipHolder.hpp 2010-09-12 17:23:08 UTC (rev 323) +++ trunk/stdair/test/archi_intru/RelationShipHolder.hpp 2010-09-12 19:11:43 UTC (rev 324) @@ -4,8 +4,10 @@ // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// -// Boost.Intrusive -#include <boost/intrusive/list.hpp> +// STL +#include <string> +// Local +#include <test/archi_intru/RelationShipHolderAbstract.hpp> /** Alias for the boost::intrusive namespace. */ namespace bi = boost::intrusive; @@ -15,23 +17,43 @@ /** Class holding relationship objects between either a parent Bom and its children or a Bom object and its siblings. */ template <typename FIRST_BOM, typename SECOND_BOM> - class RelationShipHolder { + class RelationShipHolder : public RelationShipHolderAbstract { public: // /////////////////////////////////////////// /** Type definition for a list of either children or siblings. */ - typedef bi::list<SECOND_BOM> SecondBomList_T; - - /** Type definition for a relationship, holding a list of children - or siblings for a given parent/Bom object. - <br>The list has got only two elements. A list is used only because - the pair does not exist (yet?) within boost::intrusive. */ - typedef bi::list<FIRST_BOM, SecondBomList_T> RelationShip_T; + typedef bi::member_hook <SECOND_BOM, + bi::list_member_hook<>, + &SECOND_BOM::_childListHook> SecondBomListMemberOption; + typedef bi::list<SECOND_BOM, SecondBomListMemberOption> SecondBomList_T; // /////////////////////////////////////////// + public: + RelationShipHolder (FIRST_BOM& ioFirstBom, SECOND_BOM& ioSecondBom) + : _firstBom (ioFirstBom) { + } + + public: + bi::list_member_hook<> _childListHook; + bi::set_member_hook<> _childSetHook; + + public: + // /////////// Display support methods ///////// + /** Dump a Business Object into an output stream. + @param ostream& the output stream. */ + void toStream (std::ostream& ioOut) const { toString(); } + + /** Read a Business Object from an input stream. + @param istream& the input stream. */ + void fromStream (std::istream& ioIn) {} + + /** Get the serialised version of the Business Object. */ + std::string toString() const { return _key; }; + private: /** Relationship, holding a list of children or siblings for a given parent/Bom object. */ - RelationShip_T _relationShip; + FIRST_BOM& _firstBom; + SecondBomList_T _secondBomList; }; } Copied: trunk/stdair/test/archi_intru/RelationShipHolderAbstract.hpp (from rev 318, trunk/stdair/test/archi_intru/BomAbstract.hpp) =================================================================== --- trunk/stdair/test/archi_intru/RelationShipHolderAbstract.hpp (rev 0) +++ trunk/stdair/test/archi_intru/RelationShipHolderAbstract.hpp 2010-09-12 19:11:43 UTC (rev 324) @@ -0,0 +1,128 @@ +#ifndef __INTRUSIVE_BOM_RELATIONSHIPHOLDERABSTRACT_HPP +#define __INTRUSIVE_BOM_RELATIONSHIPHOLDERABSTRACT_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <iosfwd> +#include <sstream> +#include <string> +// Boost.Intrusive +#include <boost/functional/hash.hpp> + +namespace stdair { + + /** RelationShipHolderAbstract. */ + class RelationShipHolderAbstract { + public: + /** Constructors. */ + RelationShipHolderAbstract (const std::string& iKey) : _key (iKey) {} + RelationShipHolderAbstract (const int idx) { + std::ostringstream oStr; + oStr << idx; + _key = oStr.str(); + } + /** Get the key. */ + const std::string& getKey() const { + return _key; + } + + protected: + /** Default constructors. + <br>They are kept private, so as to forbid their use (only the + public constructors should be used). */ + RelationShipHolderAbstract () {} + RelationShipHolderAbstract (const RelationShipHolderAbstract&) {} + + public: + // Comparison operators + friend bool operator< (const RelationShipHolderAbstract& a, + const RelationShipHolderAbstract& b) { + return a._key < b._key; + } + + friend bool operator> (const RelationShipHolderAbstract& a, + const RelationShipHolderAbstract& b) { + return a._key > b._key; + } + + friend bool operator== (const RelationShipHolderAbstract& a, + const RelationShipHolderAbstract& b) { + return a._key == b._key; + } + + friend bool operator!= (const RelationShipHolderAbstract& a, + const RelationShipHolderAbstract& b) { + return a._key != b._key; + } + + // The hash function + friend std::size_t hash_value (const RelationShipHolderAbstract& iRelationShipHolder) { + return boost::hash<std::string>() (iRelationShipHolder._key); + } + + public: + // /////////// Display support methods ///////// + /** Dump a Business Object into an output stream. + @param ostream& the output stream. */ + virtual void toStream (std::ostream& ioOut) const = 0; + + /** Read a Business Object from an input stream. + @param istream& the input stream. */ + virtual void fromStream (std::istream& ioIn) = 0; + + /** Get the serialised version of the Business Object. */ + virtual std::string toString() const = 0; + + protected: + std::string _key; + }; + +} + +/** + Piece of code given by Nicolai M. Josuttis, Section 13.12.1 "Implementing + Output Operators" (p653) of his book "The C++ Standard Library: A Tutorial + and Reference", published by Addison-Wesley. + */ +template <class charT, class traits> +inline +std::basic_ostream<charT, traits>& +operator<< (std::basic_ostream<charT, traits>& ioOut, + const stdair::RelationShipHolderAbstract& iRelationShipHolder) { + /** + string stream: + - with same format + - without special field width + */ + std::basic_ostringstream<charT,traits> ostr; + ostr.copyfmt (ioOut); + ostr.width (0); + + // Fill string stream + iRelationShipHolder.toStream (ostr); + + // Print string stream + ioOut << ostr.str(); + + return ioOut; +} + +/** + Piece of code given by Nicolai M. Josuttis, Section 13.12.1 "Implementing + Output Operators" (pp655-657) of his book "The C++ Standard Library: + A Tutorial and Reference", published by Addison-Wesley. + */ +template <class charT, class traits> +inline +std::basic_istream<charT, traits>& +operator>> (std::basic_istream<charT, traits>& ioIn, + stdair::RelationShipHolderAbstract& ioRelationShipHolder) { + // Fill RelationShipHolder object with input stream + ioRelationShipHolder.fromStream (ioIn); + return ioIn; +} + +#endif // __INTRUSIVE_BOM_RELATIONSHIPHOLDERABSTRACT_HPP Modified: trunk/stdair/test/archi_intru/TestBomUsage.cpp =================================================================== --- trunk/stdair/test/archi_intru/TestBomUsage.cpp 2010-09-12 17:23:08 UTC (rev 323) +++ trunk/stdair/test/archi_intru/TestBomUsage.cpp 2010-09-12 19:11:43 UTC (rev 324) @@ -10,7 +10,10 @@ // Boost #include <boost/intrusive/list.hpp> // Local +#include <test/archi_intru/BomRoot.hpp> #include <test/archi_intru/FlightDate.hpp> +#include <test/archi_intru/FacBom.hpp> +#include <test/archi_intru/FacRelationShipRoot.hpp> #include <test/archi_intru/TestBomUsage.hpp> /** Alias for the boost::intrusive namespace. */ @@ -30,6 +33,24 @@ } // ////////////////////////////////////////////////////////////////////// +bool TestBomUsage::testBomBuilding() { + bool oTestSuccessfull = true; + + const std::string br0 ("BR"); + stdair::BomRoot& lBomRoot = + stdair::FacBom<stdair::BomRoot>::instance().create (br0); + + const std::string fdba117 ("BA117"); + stdair::FlightDate& lFDBA117 = + stdair::FacBom<stdair::FlightDate>::instance().create (fdba117); + + stdair::FacRelationShipRoot<stdair::BomRoot, + stdair::FlightDate>::addToList(lBomRoot,lFDBA117); + + return oTestSuccessfull; +} + +// ////////////////////////////////////////////////////////////////////// bool TestBomUsage::test() { bool oTestSuccessfull = true; Modified: trunk/stdair/test/archi_intru/TestBomUsage.hpp =================================================================== --- trunk/stdair/test/archi_intru/TestBomUsage.hpp 2010-09-12 17:23:08 UTC (rev 323) +++ trunk/stdair/test/archi_intru/TestBomUsage.hpp 2010-09-12 19:11:43 UTC (rev 324) @@ -18,6 +18,10 @@ public: /** Perform the full test set. */ static bool test(); + +private: + /** Test the building of the BOM tree. */ + bool testBomBuilding(); private: /** Initialise. */ Modified: trunk/stdair/test/archi_intru/TestIntrusive.cpp =================================================================== --- trunk/stdair/test/archi_intru/TestIntrusive.cpp 2010-09-12 17:23:08 UTC (rev 323) +++ trunk/stdair/test/archi_intru/TestIntrusive.cpp 2010-09-12 19:11:43 UTC (rev 324) @@ -10,7 +10,9 @@ // Boost #include <boost/intrusive/list.hpp> // Local +#include <test/archi_intru/FacBom.hpp> #include <test/archi_intru/FlightDate.hpp> +#include <test/archi_intru/IntrusiveHelper.hpp> #include <test/archi_intru/TestIntrusive.hpp> /** Alias for the boost::intrusive namespace. */ @@ -31,10 +33,10 @@ void TestIntrusive::initStandard() { // Create several FlightDate objects, each one with a different value for (int idx = 0; idx < 100; ++idx) { - stdair::FlightDate* lFlightDate_ptr = new stdair::FlightDate (idx); - assert (lFlightDate_ptr != NULL); - - _flightDateVector.push_back (lFlightDate_ptr); + stdair::FlightDate& lFlightDate = + stdair::FacBom<stdair::FlightDate>::instance().create (idx); + + _flightDateVector.push_back (&lFlightDate); } } Modified: trunk/stdair/test/archi_intru/sources.mk =================================================================== --- trunk/stdair/test/archi_intru/sources.mk 2010-09-12 17:23:08 UTC (rev 323) +++ trunk/stdair/test/archi_intru/sources.mk 2010-09-12 19:11:43 UTC (rev 324) @@ -1,7 +1,11 @@ archi_intru_h_sources = \ $(top_srcdir)/test/archi_intru/FacSupervisor.hpp \ + $(top_srcdir)/test/archi_intru/FacAbstract.hpp \ + $(top_srcdir)/test/archi_intru/FacBom.hpp \ $(top_srcdir)/test/archi_intru/FacRelationShipRoot.hpp \ $(top_srcdir)/test/archi_intru/FacRelationShipRootAbstract.hpp \ + $(top_srcdir)/test/archi_intru/IntrusiveHelper.hpp \ + $(top_srcdir)/test/archi_intru/RelationShipHolderAbstract.hpp \ $(top_srcdir)/test/archi_intru/RelationShipHolder.hpp \ $(top_srcdir)/test/archi_intru/BomAbstract.hpp \ $(top_srcdir)/test/archi_intru/BomRoot.hpp \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-09-12 21:58:01
|
Revision: 325 http://stdair.svn.sourceforge.net/stdair/?rev=325&view=rev Author: denis_arnaud Date: 2010-09-12 21:57:55 +0000 (Sun, 12 Sep 2010) Log Message: ----------- [Test] Added a test sub-directory for Boost.Intrusive-based architecture. Modified Paths: -------------- trunk/stdair/test/archi_intru/FacRelationShipRoot.hpp trunk/stdair/test/archi_intru/RelationShipHolder.hpp trunk/stdair/test/archi_intru/TestBomUsage.cpp trunk/stdair/test/archi_intru/TestBomUsage.hpp trunk/stdair/test/archi_intru/TestIntrusive.cpp trunk/stdair/test/archi_intru/sources.mk Added Paths: ----------- trunk/stdair/test/archi_intru/RelationShipHolderSet.hpp Modified: trunk/stdair/test/archi_intru/FacRelationShipRoot.hpp =================================================================== --- trunk/stdair/test/archi_intru/FacRelationShipRoot.hpp 2010-09-12 19:11:43 UTC (rev 324) +++ trunk/stdair/test/archi_intru/FacRelationShipRoot.hpp 2010-09-12 21:57:55 UTC (rev 325) @@ -1,9 +1,11 @@ -#ifndef __INTRUSIVE_FAC_FACRELATIONSHIPHOLDER_HPP -#define __INTRUSIVE_FAC_FACRELATIONSHIPHOLDER_HPP +#ifndef __INTRUSIVE_FAC_FACRELATIONSHIPROOT_HPP +#define __INTRUSIVE_FAC_FACRELATIONSHIPROOT_HPP // ////////////////////////////////////////////////////////////////////// // Import section // ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> // Boost.Intrusive #include <boost/intrusive/list.hpp> #include <boost/intrusive/set.hpp> @@ -11,6 +13,7 @@ #include <test/archi_intru/FacSupervisor.hpp> #include <test/archi_intru/FacRelationShipRootAbstract.hpp> #include <test/archi_intru/RelationShipHolder.hpp> +#include <test/archi_intru/RelationShipHolderSet.hpp> /** Alias for the boost::intrusive namespace. */ namespace bi = boost::intrusive; @@ -22,23 +25,32 @@ class FacRelationShipRoot : public FacRelationShipRootAbstract { public: // /////////////////////////////////////////// - /** Type definition for the specific relationship. */ + /** Type definition for the specific relationship class. */ typedef RelationShipHolder<FIRST_BOM, SECOND_BOM> RelationShipHolder_T; - - /** Type definition for a list of relationship holder objects. */ + /** Type definition for a list of relationship objects. */ + /* typedef bi::member_hook <RelationShipHolder_T, bi::list_member_hook<>, - &RelationShipHolder_T::_childListHook> RSHolderListMemberOption; + &RelationShipHolder_T::_childListHook> RSHListMemberOption; typedef bi::list<RelationShipHolder_T, - RSHolderListMemberOption> RelationShipHolderList_T; - /** Type definition for a set of relationship holder objects. */ + RSHListMemberOption> RelationShipHolderList_T; + */ + /** Type definition for a set of relationship objects. */ + /* typedef bi::member_hook <RelationShipHolder_T, bi::set_member_hook<>, - &RelationShipHolder_T::_childSetHook> RSHolderSetMemberOption; + &RelationShipHolder_T::_childSetHook> RSHSetMemberOption; typedef bi::set<RelationShipHolder_T, - RSHolderSetMemberOption> RelationShipHolderSet_T; + RSHSetMemberOption> RelationShipHolderSet_T; + */ // /////////////////////////////////////////// + // /////////////////////////////////////////// + /** Type definition for the specific relationship holder (set) class. */ + typedef RelationShipHolderSet<FIRST_BOM, + SECOND_BOM> RelationShipHolderHolder_T; + // /////////////////////////////////////////// + public: /** Provide the unique instance. <br>The singleton is instantiated when first used. @@ -52,6 +64,11 @@ } return *_instance; } + + public: + /** Constructor. */ + FacRelationShipRoot() : _relationShipHolderSet () { + } public: /** Add a child/sibling to the dedicated list of the parent/sibling. */ @@ -63,15 +80,28 @@ void addToListImpl (FIRST_BOM& ioFirstBom, SECOND_BOM& ioSecondBom) { RelationShipHolder_T* lRS_ptr = new RelationShipHolder_T (ioFirstBom, ioSecondBom); - _relationShipHolderList.push_back (*lRS_ptr); - _relationShipHolderSet.insert (*lRS_ptr); + _relationShipHolderSet.addToList (*lRS_ptr); } + /** Add a child/sibling to the dedicated list of the parent/sibling. */ + static SECOND_BOM* find (const FIRST_BOM& iFirstBom, + const std::string& iSecondBomKey) { + SECOND_BOM* oSecondBom_ptr = + instance().findImpl (iFirstBom, iSecondBomKey); + return oSecondBom_ptr; + } + + /** Add a child/sibling to the dedicated list of the parent/sibling. */ + SECOND_BOM* findImpl (const FIRST_BOM& iFirstBom, + const std::string& iSecondBomKey) { + SECOND_BOM* oSecondBom_ptr = + _relationShipHolderSet.find (iFirstBom, iSecondBomKey); + return oSecondBom_ptr; + } + private: - /** List of relationship holder objects. */ - RelationShipHolderList_T _relationShipHolderList; /** Set of relationship holder objects. */ - RelationShipHolderSet_T _relationShipHolderSet; + RelationShipHolderHolder_T _relationShipHolderSet; private: /** The unique instance. */ @@ -84,4 +114,4 @@ FacRelationShipRoot<FIRST_BOM, SECOND_BOM>::_instance = NULL; } -#endif // __INTRUSIVE_FAC_FACRELATIONSHIPHOLDER_HPP +#endif // __INTRUSIVE_FAC_FACRELATIONSHIPROOT_HPP Modified: trunk/stdair/test/archi_intru/RelationShipHolder.hpp =================================================================== --- trunk/stdair/test/archi_intru/RelationShipHolder.hpp 2010-09-12 19:11:43 UTC (rev 324) +++ trunk/stdair/test/archi_intru/RelationShipHolder.hpp 2010-09-12 21:57:55 UTC (rev 325) @@ -6,8 +6,12 @@ // ////////////////////////////////////////////////////////////////////// // STL #include <string> +// Boost.Intrusive +#include <boost/intrusive/list.hpp> +#include <boost/intrusive/set.hpp> // Local #include <test/archi_intru/RelationShipHolderAbstract.hpp> +#include <test/archi_intru/IntrusiveHelper.hpp> /** Alias for the boost::intrusive namespace. */ namespace bi = boost::intrusive; @@ -22,19 +26,37 @@ // /////////////////////////////////////////// /** Type definition for a list of either children or siblings. */ typedef bi::member_hook <SECOND_BOM, - bi::list_member_hook<>, - &SECOND_BOM::_childListHook> SecondBomListMemberOption; - typedef bi::list<SECOND_BOM, SecondBomListMemberOption> SecondBomList_T; + bi::set_member_hook<>, + &SECOND_BOM::_childSetHook> SecondBomSetMemberOption; + typedef bi::set<SECOND_BOM, SecondBomSetMemberOption> SecondBomSet_T; // /////////////////////////////////////////// public: RelationShipHolder (FIRST_BOM& ioFirstBom, SECOND_BOM& ioSecondBom) - : _firstBom (ioFirstBom) { + : RelationShipHolderAbstract (ioFirstBom.getKey() + "," + + ioSecondBom.getKey()), + _firstBom (ioFirstBom) { } public: bi::list_member_hook<> _childListHook; bi::set_member_hook<> _childSetHook; + + public: + /** Search for a child/sibling from the dedicated list of the + parents/siblings. */ + SECOND_BOM* find (const std::string& iSecondBomKey) { + SECOND_BOM* oSecondBom_ptr = NULL; + + typename SecondBomSet_T::iterator itSecondBom = + _secondBomSet.find (iSecondBomKey, StrExpComp<SECOND_BOM>()); + if (itSecondBom == _secondBomSet.end()) { + return oSecondBom_ptr; + } + oSecondBom_ptr = &*itSecondBom; + + return oSecondBom_ptr; + } public: // /////////// Display support methods ///////// @@ -53,7 +75,7 @@ /** Relationship, holding a list of children or siblings for a given parent/Bom object. */ FIRST_BOM& _firstBom; - SecondBomList_T _secondBomList; + SecondBomSet_T _secondBomSet; }; } Added: trunk/stdair/test/archi_intru/RelationShipHolderSet.hpp =================================================================== --- trunk/stdair/test/archi_intru/RelationShipHolderSet.hpp (rev 0) +++ trunk/stdair/test/archi_intru/RelationShipHolderSet.hpp 2010-09-12 21:57:55 UTC (rev 325) @@ -0,0 +1,103 @@ +#ifndef __INTRUSIVE_BOM_RELATIONSHIPHOLDERSET_HPP +#define __INTRUSIVE_BOM_RELATIONSHIPHOLDERSET_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <string> +// Boost.Intrusive +#include <boost/intrusive/list.hpp> +#include <boost/intrusive/set.hpp> +// Local +#include <test/archi_intru/RelationShipHolderAbstract.hpp> +#include <test/archi_intru/RelationShipHolder.hpp> +#include <test/archi_intru/IntrusiveHelper.hpp> + +/** Alias for the boost::intrusive namespace. */ +namespace bi = boost::intrusive; + +namespace stdair { + + /** Class holding relationship objects between either a parent Bom and its + children or a Bom object and its siblings. */ + template <typename FIRST_BOM, typename SECOND_BOM> + class RelationShipHolderSet : public RelationShipHolderAbstract { + public: + // /////////////////////////////////////////// + /** Type definition for the specific relationship class. */ + typedef RelationShipHolder<FIRST_BOM, SECOND_BOM> RelationShipHolder_T; + + /** Type definition for a list of relationship objects. */ + typedef bi::member_hook <RelationShipHolder_T, + bi::list_member_hook<>, + &RelationShipHolder_T::_childListHook> RSHListMemberOption; + typedef bi::list<RelationShipHolder_T, + RSHListMemberOption> RelationShipHolderList_T; + + /** Type definition for a set of relationship objects. */ + typedef bi::member_hook <RelationShipHolder_T, + bi::set_member_hook<>, + &RelationShipHolder_T::_childSetHook> RSHSetMemberOption; + typedef bi::set<RelationShipHolder_T, + RSHSetMemberOption> RelationShipHolderSet_T; + // /////////////////////////////////////////// + + public: + /** Constructor. */ + RelationShipHolderSet () + : RelationShipHolderAbstract ("RelationShipHolderSet") { + } + + public: + bi::list_member_hook<> _childListHook; + bi::set_member_hook<> _childSetHook; + + public: + /** Add a child/sibling to the dedicated list of the parent/sibling. */ + void addToList (RelationShipHolder_T& ioRelationShipHolder) { + _relationShipHolderList.push_back (ioRelationShipHolder); + _relationShipHolderSet.insert (ioRelationShipHolder); + } + + /** Search for a child/sibling from the dedicated list of the + parents/siblings. */ + SECOND_BOM* find (const FIRST_BOM& iFirstBom, + const std::string& iSecondBomKey) { + SECOND_BOM* oSecondBom_ptr = NULL; + RelationShipHolder_T* oRSH_ptr = NULL; + + typename RelationShipHolderSet_T::iterator itRSH = + _relationShipHolderSet.find (iSecondBomKey, StrExpComp<RelationShipHolder_T>()); + if (itRSH == _relationShipHolderSet.end()) { + return oSecondBom_ptr; + } + oRSH_ptr = &*itRSH; + + oSecondBom_ptr = oRSH_ptr->find (iSecondBomKey); + + return oSecondBom_ptr; + } + + public: + // /////////// Display support methods ///////// + /** Dump a Business Object into an output stream. + @param ostream& the output stream. */ + void toStream (std::ostream& ioOut) const { toString(); } + + /** Read a Business Object from an input stream. + @param istream& the input stream. */ + void fromStream (std::istream& ioIn) {} + + /** Get the serialised version of the Business Object. */ + std::string toString() const { return _key; }; + + private: + /** Relationship, holding a list of children or siblings for a + given parent/Bom object. */ + RelationShipHolderList_T _relationShipHolderList; + RelationShipHolderSet_T _relationShipHolderSet; + }; + +} +#endif // __INTRUSIVE_BOM_RELATIONSHIPHOLDERSET_HPP Modified: trunk/stdair/test/archi_intru/TestBomUsage.cpp =================================================================== --- trunk/stdair/test/archi_intru/TestBomUsage.cpp 2010-09-12 19:11:43 UTC (rev 324) +++ trunk/stdair/test/archi_intru/TestBomUsage.cpp 2010-09-12 21:57:55 UTC (rev 325) @@ -20,12 +20,18 @@ namespace bi = boost::intrusive; // ////////////////////////////////////////////////////////////////////// +TestBomUsage::TestBomUsage() : _bomRoot (NULL) { + init(); +} + +// ////////////////////////////////////////////////////////////////////// TestBomUsage::~TestBomUsage() { clean(); } // ////////////////////////////////////////////////////////////////////// void TestBomUsage::init() { + _bomRoot = &stdair::FacBom<stdair::BomRoot>::instance().create ("BR"); } // ////////////////////////////////////////////////////////////////////// @@ -36,24 +42,64 @@ bool TestBomUsage::testBomBuilding() { bool oTestSuccessfull = true; - const std::string br0 ("BR"); - stdair::BomRoot& lBomRoot = - stdair::FacBom<stdair::BomRoot>::instance().create (br0); - + // 0. Sanity check + assert (_bomRoot != NULL); + + // 1. FlightDate level + // 1.1. BA177 const std::string fdba117 ("BA117"); stdair::FlightDate& lFDBA117 = stdair::FacBom<stdair::FlightDate>::instance().create (fdba117); stdair::FacRelationShipRoot<stdair::BomRoot, - stdair::FlightDate>::addToList(lBomRoot,lFDBA117); + stdair::FlightDate>::addToList (*_bomRoot, + lFDBA117); + // 1.2. LH434 + const std::string fdlh434 ("LH434"); + stdair::FlightDate& lFDLH434 = + stdair::FacBom<stdair::FlightDate>::instance().create (fdlh434); + + stdair::FacRelationShipRoot<stdair::BomRoot, + stdair::FlightDate>::addToList (*_bomRoot, + lFDLH434); + return oTestSuccessfull; } // ////////////////////////////////////////////////////////////////////// +bool TestBomUsage::testBomSearching() { + bool oTestSuccessfull = true; + + stdair::FlightDate* lFlightDate_ptr = + stdair::FacRelationShipRoot<stdair::BomRoot, + stdair::FlightDate>::find (*_bomRoot, "BA117"); + + // DEBUG + const std::string isFDNullStr = (lFlightDate_ptr == NULL)?"Yes":"No"; + std::cout << "Is FlightDate NULL? " << isFDNullStr << std::endl; + + return oTestSuccessfull; +} + +// ////////////////////////////////////////////////////////////////////// bool TestBomUsage::test() { bool oTestSuccessfull = true; + // + TestBomUsage lTestBomUsage; + + // Test the building of the BOM tree + oTestSuccessfull = lTestBomUsage.testBomBuilding(); + if (oTestSuccessfull == false) { + return oTestSuccessfull; + } + // Test searching within the BOM tree + oTestSuccessfull = lTestBomUsage.testBomSearching(); + if (oTestSuccessfull == false) { + return oTestSuccessfull; + } + return oTestSuccessfull; } Modified: trunk/stdair/test/archi_intru/TestBomUsage.hpp =================================================================== --- trunk/stdair/test/archi_intru/TestBomUsage.hpp 2010-09-12 19:11:43 UTC (rev 324) +++ trunk/stdair/test/archi_intru/TestBomUsage.hpp 2010-09-12 21:57:55 UTC (rev 325) @@ -9,9 +9,16 @@ // Local #include <test/archi_intru/FlightDate.hpp> +// Forward declarations +namespace stdair { + class BomRoot; +} + /** Class wrapping test functions. */ class TestBomUsage { public: + /** Constructor. */ + TestBomUsage(); /** Destructor. */ ~TestBomUsage(); @@ -23,6 +30,9 @@ /** Test the building of the BOM tree. */ bool testBomBuilding(); + /** Test the search within the BOM tree. */ + bool testBomSearching(); + private: /** Initialise. */ void init(); @@ -31,6 +41,7 @@ void clean(); private: + stdair::BomRoot* _bomRoot; }; #endif // __INTRUSIVE_TST_TESTBOMUSAGE_HPP Modified: trunk/stdair/test/archi_intru/TestIntrusive.cpp =================================================================== --- trunk/stdair/test/archi_intru/TestIntrusive.cpp 2010-09-12 19:11:43 UTC (rev 324) +++ trunk/stdair/test/archi_intru/TestIntrusive.cpp 2010-09-12 21:57:55 UTC (rev 325) @@ -7,7 +7,7 @@ #include <sstream> #include <string> #include <vector> -// Boost +// Boost.Intrusive #include <boost/intrusive/list.hpp> // Local #include <test/archi_intru/FacBom.hpp> @@ -165,13 +165,22 @@ lTestIntrusive.init(); // Now test lists - lTestIntrusive.testIntrusiveList(); + oTestSuccessfull = lTestIntrusive.testIntrusiveList(); + if (oTestSuccessfull == false) { + return oTestSuccessfull; + } // Now, test iterator_to() - lTestIntrusive.testIntrusiveIteratorTo(); + oTestSuccessfull = lTestIntrusive.testIntrusiveIteratorTo(); + if (oTestSuccessfull == false) { + return oTestSuccessfull; + } // Now, test sets - lTestIntrusive.testIntrusiveSets(); + oTestSuccessfull = lTestIntrusive.testIntrusiveSets(); + if (oTestSuccessfull == false) { + return oTestSuccessfull; + } return oTestSuccessfull; } Modified: trunk/stdair/test/archi_intru/sources.mk =================================================================== --- trunk/stdair/test/archi_intru/sources.mk 2010-09-12 19:11:43 UTC (rev 324) +++ trunk/stdair/test/archi_intru/sources.mk 2010-09-12 21:57:55 UTC (rev 325) @@ -7,6 +7,7 @@ $(top_srcdir)/test/archi_intru/IntrusiveHelper.hpp \ $(top_srcdir)/test/archi_intru/RelationShipHolderAbstract.hpp \ $(top_srcdir)/test/archi_intru/RelationShipHolder.hpp \ + $(top_srcdir)/test/archi_intru/RelationShipHolderSet.hpp \ $(top_srcdir)/test/archi_intru/BomAbstract.hpp \ $(top_srcdir)/test/archi_intru/BomRoot.hpp \ $(top_srcdir)/test/archi_intru/FlightDate.hpp \ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-09-12 22:29:31
|
Revision: 327 http://stdair.svn.sourceforge.net/stdair/?rev=327&view=rev Author: denis_arnaud Date: 2010-09-12 22:29:25 +0000 (Sun, 12 Sep 2010) Log Message: ----------- [Test] Added a test sub-directory for Boost.Intrusive-based architecture (there is still some work to do). Modified Paths: -------------- trunk/stdair/test/archi_intru/RelationShipHolder.hpp trunk/stdair/test/archi_intru/RelationShipHolderSet.hpp trunk/stdair/test/archi_intru/TestBomUsage.cpp trunk/stdair/test/archi_intru/sources.mk Added Paths: ----------- trunk/stdair/test/archi_intru/BomManager.cpp trunk/stdair/test/archi_intru/BomManager.hpp Added: trunk/stdair/test/archi_intru/BomManager.cpp =================================================================== --- trunk/stdair/test/archi_intru/BomManager.cpp (rev 0) +++ trunk/stdair/test/archi_intru/BomManager.cpp 2010-09-12 22:29:25 UTC (rev 327) @@ -0,0 +1,29 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +#include <sstream> +// Boost.Intrusive +#include <boost/intrusive/list.hpp> +// Local +#include <test/archi_intru/BomRoot.hpp> +#include <test/archi_intru/FlightDate.hpp> +#include <test/archi_intru/FacRelationShipRoot.hpp> +#include <test/archi_intru/BomManager.hpp> + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + std::string BomManager::display (const BomRoot& iBomRoot) { + std::ostringstream oStr; + + // 0. BomRoot level + oStr << "BR[" << iBomRoot << "]" << std::endl; + + // 1. FlightDate level + + return oStr.str(); + } + +} Added: trunk/stdair/test/archi_intru/BomManager.hpp =================================================================== --- trunk/stdair/test/archi_intru/BomManager.hpp (rev 0) +++ trunk/stdair/test/archi_intru/BomManager.hpp 2010-09-12 22:29:25 UTC (rev 327) @@ -0,0 +1,23 @@ +#ifndef __INTRUSIVE_BOM_BOMMANAGER_HPP +#define __INTRUSIVE_BOM_BOMMANAGER_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <string> + +namespace stdair { + + /** Utility class. */ + class BomManager { + public: + /** Display the full BOM tree. */ + static std::string display (const BomRoot&); + + private: + + }; + +} +#endif // __INTRUSIVE_BOM_BOMMANAGER_HPP Modified: trunk/stdair/test/archi_intru/RelationShipHolder.hpp =================================================================== --- trunk/stdair/test/archi_intru/RelationShipHolder.hpp 2010-09-12 22:03:20 UTC (rev 326) +++ trunk/stdair/test/archi_intru/RelationShipHolder.hpp 2010-09-12 22:29:25 UTC (rev 327) @@ -32,9 +32,16 @@ // /////////////////////////////////////////// public: + /** Key calculator. */ + static std::string keyCalculator (const std::string& iKey1, + const std::string& iKey2) { + return (iKey1 + "," + iKey2); + } + + /** Constructor. */ RelationShipHolder (FIRST_BOM& ioFirstBom, SECOND_BOM& ioSecondBom) - : RelationShipHolderAbstract (ioFirstBom.getKey() + "," - + ioSecondBom.getKey()), + : RelationShipHolderAbstract (keyCalculator (ioFirstBom.getKey(), + ioSecondBom.getKey())), _firstBom (ioFirstBom) { } Modified: trunk/stdair/test/archi_intru/RelationShipHolderSet.hpp =================================================================== --- trunk/stdair/test/archi_intru/RelationShipHolderSet.hpp 2010-09-12 22:03:20 UTC (rev 326) +++ trunk/stdair/test/archi_intru/RelationShipHolderSet.hpp 2010-09-12 22:29:25 UTC (rev 327) @@ -73,9 +73,12 @@ return oSecondBom_ptr; } oRSH_ptr = &*itRSH; - - oSecondBom_ptr = oRSH_ptr->find (iSecondBomKey); + // Calculate the RelationShipHolder key (usually, it is "key1,key2") + const std::string& lRSHKey = + RelationShipHolder_T::keyCalculator (iFirstBom.getKey(), iSecondBomKey); + oSecondBom_ptr = oRSH_ptr->find (lRSHKey); + return oSecondBom_ptr; } Modified: trunk/stdair/test/archi_intru/TestBomUsage.cpp =================================================================== --- trunk/stdair/test/archi_intru/TestBomUsage.cpp 2010-09-12 22:03:20 UTC (rev 326) +++ trunk/stdair/test/archi_intru/TestBomUsage.cpp 2010-09-12 22:29:25 UTC (rev 327) @@ -7,13 +7,12 @@ #include <sstream> #include <string> #include <vector> -// Boost -#include <boost/intrusive/list.hpp> // Local #include <test/archi_intru/BomRoot.hpp> #include <test/archi_intru/FlightDate.hpp> #include <test/archi_intru/FacBom.hpp> #include <test/archi_intru/FacRelationShipRoot.hpp> +#include <test/archi_intru/BomManager.hpp> #include <test/archi_intru/TestBomUsage.hpp> /** Alias for the boost::intrusive namespace. */ @@ -64,6 +63,9 @@ stdair::FlightDate>::addToList (*_bomRoot, lFDLH434); + // DEBUG + std::cout << stdair::BomManager::display (*_bomRoot); + return oTestSuccessfull; } Modified: trunk/stdair/test/archi_intru/sources.mk =================================================================== --- trunk/stdair/test/archi_intru/sources.mk 2010-09-12 22:03:20 UTC (rev 326) +++ trunk/stdair/test/archi_intru/sources.mk 2010-09-12 22:29:25 UTC (rev 327) @@ -13,9 +13,11 @@ $(top_srcdir)/test/archi_intru/FlightDate.hpp \ $(top_srcdir)/test/archi_intru/LegDate.hpp \ $(top_srcdir)/test/archi_intru/SegmentDate.hpp \ + $(top_srcdir)/test/archi_intru/BomManager.hpp \ $(top_srcdir)/test/archi_intru/TestIntrusive.hpp \ $(top_srcdir)/test/archi_intru/TestBomUsage.hpp archi_intru_cc_sources = \ $(top_srcdir)/test/archi_intru/FacSupervisor.cpp \ + $(top_srcdir)/test/archi_intru/BomManager.cpp \ $(top_srcdir)/test/archi_intru/TestIntrusive.cpp \ $(top_srcdir)/test/archi_intru/TestBomUsage.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-09-13 06:31:25
|
Revision: 328 http://stdair.svn.sourceforge.net/stdair/?rev=328&view=rev Author: denis_arnaud Date: 2010-09-13 06:31:18 +0000 (Mon, 13 Sep 2010) Log Message: ----------- [Test] Added a test sub-directory for Boost.Intrusive-based architecture (there is still some work to do). Modified Paths: -------------- trunk/stdair/test/archi_intru/BomRoot.hpp trunk/stdair/test/archi_intru/RelationShipHolder.hpp trunk/stdair/test/archi_intru/RelationShipHolderAbstract.hpp Modified: trunk/stdair/test/archi_intru/BomRoot.hpp =================================================================== --- trunk/stdair/test/archi_intru/BomRoot.hpp 2010-09-12 22:29:25 UTC (rev 327) +++ trunk/stdair/test/archi_intru/BomRoot.hpp 2010-09-13 06:31:18 UTC (rev 328) @@ -21,8 +21,17 @@ /** BomRoot. */ class BomRoot : public BomAbstract { public: + /** Constructors. */ BomRoot (const std::string& iKey) : BomAbstract (iKey) {} BomRoot (const int idx) : BomAbstract (idx) {} + /** Destructor. */ + ~BomRoot() {} + private: + /** Default constructors. + <br>They are kept private, so as to forbid their use (only the + public constructors should be used). */ + BomRoot () {} + BomRoot (const BomRoot&) {} public: bi::list_member_hook<> _childListHook; Modified: trunk/stdair/test/archi_intru/RelationShipHolder.hpp =================================================================== --- trunk/stdair/test/archi_intru/RelationShipHolder.hpp 2010-09-12 22:29:25 UTC (rev 327) +++ trunk/stdair/test/archi_intru/RelationShipHolder.hpp 2010-09-13 06:31:18 UTC (rev 328) @@ -44,6 +44,14 @@ ioSecondBom.getKey())), _firstBom (ioFirstBom) { } + /** Destructor. */ + ~RelationShipHolder() {} + private: + /** Default constructors. + <br>They are kept private, so as to forbid their use (only the + public constructors should be used). */ + RelationShipHolder () {} + RelationShipHolder (const RelationShipHolder&) {} public: bi::list_member_hook<> _childListHook; Modified: trunk/stdair/test/archi_intru/RelationShipHolderAbstract.hpp =================================================================== --- trunk/stdair/test/archi_intru/RelationShipHolderAbstract.hpp 2010-09-12 22:29:25 UTC (rev 327) +++ trunk/stdair/test/archi_intru/RelationShipHolderAbstract.hpp 2010-09-13 06:31:18 UTC (rev 328) @@ -24,10 +24,8 @@ oStr << idx; _key = oStr.str(); } - /** Get the key. */ - const std::string& getKey() const { - return _key; - } + /** Destructor. */ + ~RelationShipHolderAbstract() {} protected: /** Default constructors. @@ -37,6 +35,12 @@ RelationShipHolderAbstract (const RelationShipHolderAbstract&) {} public: + /** Get the key. */ + const std::string& getKey() const { + return _key; + } + + public: // Comparison operators friend bool operator< (const RelationShipHolderAbstract& a, const RelationShipHolderAbstract& b) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <den...@us...> - 2010-09-13 06:49:12
|
Revision: 330 http://stdair.svn.sourceforge.net/stdair/?rev=330&view=rev Author: denis_arnaud Date: 2010-09-13 06:49:06 +0000 (Mon, 13 Sep 2010) Log Message: ----------- [Test] Added a test sub-directory for Boost.Intrusive-based architecture (there is still some work to do). Modified Paths: -------------- trunk/stdair/test/archi_intru/BomRoot.hpp trunk/stdair/test/archi_intru/FacRelationShipRoot.hpp trunk/stdair/test/archi_intru/FlightDate.hpp trunk/stdair/test/archi_intru/RelationShipHolder.hpp trunk/stdair/test/archi_intru/RelationShipHolderAbstract.hpp trunk/stdair/test/archi_intru/RelationShipHolderSet.hpp Modified: trunk/stdair/test/archi_intru/BomRoot.hpp =================================================================== --- trunk/stdair/test/archi_intru/BomRoot.hpp 2010-09-13 06:32:16 UTC (rev 329) +++ trunk/stdair/test/archi_intru/BomRoot.hpp 2010-09-13 06:49:06 UTC (rev 330) @@ -20,18 +20,20 @@ /** BomRoot. */ class BomRoot : public BomAbstract { + template <typename BOM> friend class FacBom; + template <typename NODE> friend struct delete_disposer; public: /** Constructors. */ BomRoot (const std::string& iKey) : BomAbstract (iKey) {} BomRoot (const int idx) : BomAbstract (idx) {} - /** Destructor. */ - ~BomRoot() {} private: /** Default constructors. <br>They are kept private, so as to forbid their use (only the public constructors should be used). */ BomRoot () {} BomRoot (const BomRoot&) {} + /** Destructor. */ + ~BomRoot() {} public: bi::list_member_hook<> _childListHook; Modified: trunk/stdair/test/archi_intru/FacRelationShipRoot.hpp =================================================================== --- trunk/stdair/test/archi_intru/FacRelationShipRoot.hpp 2010-09-13 06:32:16 UTC (rev 329) +++ trunk/stdair/test/archi_intru/FacRelationShipRoot.hpp 2010-09-13 06:49:06 UTC (rev 330) @@ -49,8 +49,14 @@ public: /** Constructor. */ - FacRelationShipRoot() : _relationShipHolderSet () { - } + FacRelationShipRoot() : _relationShipHolderSet ("DefaultRSHSet") {} + private: + /** Default constructors. + <br>They are kept private, so as to forbid their use (only the + public constructors should be used). */ + FacRelationShipRoot (const FacRelationShipRoot&) {} + /** Destructor. */ + ~FacRelationShipRoot() {} public: /** Add a child/sibling to the dedicated list of the parent/sibling. */ Modified: trunk/stdair/test/archi_intru/FlightDate.hpp =================================================================== --- trunk/stdair/test/archi_intru/FlightDate.hpp 2010-09-13 06:32:16 UTC (rev 329) +++ trunk/stdair/test/archi_intru/FlightDate.hpp 2010-09-13 06:49:06 UTC (rev 330) @@ -20,11 +20,14 @@ /** FlightDate. */ class FlightDate : public BomAbstract { + template <typename BOM> friend class FacBom; + template <typename NODE> friend struct delete_disposer; public: /** Constructors. */ FlightDate (const std::string& iKey) : BomAbstract (iKey) {} FlightDate (const int idx) : BomAbstract (idx) {} - /** Destructor. */ + /** Destructor. + <br>Note: it should be private, but there is still a compilation bug. */ ~FlightDate() {} private: /** Default constructors. Modified: trunk/stdair/test/archi_intru/RelationShipHolder.hpp =================================================================== --- trunk/stdair/test/archi_intru/RelationShipHolder.hpp 2010-09-13 06:32:16 UTC (rev 329) +++ trunk/stdair/test/archi_intru/RelationShipHolder.hpp 2010-09-13 06:49:06 UTC (rev 330) @@ -44,14 +44,14 @@ ioSecondBom.getKey())), _firstBom (ioFirstBom) { } - /** Destructor. */ - ~RelationShipHolder() {} private: /** Default constructors. <br>They are kept private, so as to forbid their use (only the public constructors should be used). */ RelationShipHolder () {} RelationShipHolder (const RelationShipHolder&) {} + /** Destructor. */ + ~RelationShipHolder() {} public: bi::list_member_hook<> _childListHook; Modified: trunk/stdair/test/archi_intru/RelationShipHolderAbstract.hpp =================================================================== --- trunk/stdair/test/archi_intru/RelationShipHolderAbstract.hpp 2010-09-13 06:32:16 UTC (rev 329) +++ trunk/stdair/test/archi_intru/RelationShipHolderAbstract.hpp 2010-09-13 06:49:06 UTC (rev 330) @@ -25,7 +25,7 @@ _key = oStr.str(); } /** Destructor. */ - ~RelationShipHolderAbstract() {} + virtual ~RelationShipHolderAbstract() {} protected: /** Default constructors. Modified: trunk/stdair/test/archi_intru/RelationShipHolderSet.hpp =================================================================== --- trunk/stdair/test/archi_intru/RelationShipHolderSet.hpp 2010-09-13 06:32:16 UTC (rev 329) +++ trunk/stdair/test/archi_intru/RelationShipHolderSet.hpp 2010-09-13 06:49:06 UTC (rev 330) @@ -23,6 +23,7 @@ children or a Bom object and its siblings. */ template <typename FIRST_BOM, typename SECOND_BOM> class RelationShipHolderSet : public RelationShipHolderAbstract { + template <typename ONE, typename SECOND> friend class FacRelationShipRoot; public: // /////////////////////////////////////////// /** Type definition for the specific relationship class. */ @@ -45,9 +46,18 @@ public: /** Constructor. */ + RelationShipHolderSet (const std::string& iKey) + : RelationShipHolderAbstract (iKey) { + } + private: + /** Default constructors. + <br>They are kept private, so as to forbid their use (only the + public constructors should be used). */ RelationShipHolderSet () - : RelationShipHolderAbstract ("RelationShipHolderSet") { - } + : RelationShipHolderAbstract ("RelationShipHolderSet") {} + RelationShipHolderSet (const RelationShipHolderSet&) {} + /** Destructor. */ + ~RelationShipHolderSet() {} public: bi::list_member_hook<> _childListHook; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |