From: <den...@us...> - 2010-01-22 19:47:36
|
Revision: 104 http://stdair.svn.sourceforge.net/stdair/?rev=104&view=rev Author: denis_arnaud Date: 2010-01-22 19:47:29 +0000 (Fri, 22 Jan 2010) Log Message: ----------- [Dev] Added a STDAIR_Service, wrapper around both the static Logger instance and the stdair::FacSupervisor one. Modified Paths: -------------- trunk/stdair/stdair/Makefile.am trunk/stdair/stdair/basic/Makefile.am trunk/stdair/stdair/bom/Makefile.am trunk/stdair/stdair/core/Makefile.am trunk/stdair/stdair/core/sources.mk trunk/stdair/stdair/factory/FacSupervisor.cpp trunk/stdair/stdair/factory/FacSupervisor.hpp trunk/stdair/stdair/factory/Makefile.am trunk/stdair/stdair/service/Logger.cpp trunk/stdair/stdair/service/Makefile.am trunk/stdair/stdair/service/sources.mk Added Paths: ----------- trunk/stdair/stdair/STDAIR_Service.hpp trunk/stdair/stdair/service/STDAIR_Service.cpp Modified: trunk/stdair/stdair/Makefile.am =================================================================== --- trunk/stdair/stdair/Makefile.am 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/Makefile.am 2010-01-22 19:47:29 UTC (rev 104) @@ -13,5 +13,5 @@ # Header files -nobase_pkginclude_HEADERS = $(service_h_sources) +#nobase_pkginclude_HEADERS = $(service_h_sources) #nobase_nodist_pkginclude_HEADERS = $(top_builddir)/@PACKAGE@/config.h Added: trunk/stdair/stdair/STDAIR_Service.hpp =================================================================== --- trunk/stdair/stdair/STDAIR_Service.hpp (rev 0) +++ trunk/stdair/stdair/STDAIR_Service.hpp 2010-01-22 19:47:29 UTC (rev 104) @@ -0,0 +1,52 @@ +#ifndef __STDAIR_SVC_STDAIR_SERVICE_HPP +#define __STDAIR_SVC_STDAIR_SERVICE_HPP + +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// StdAir +#include <stdair/basic/BasLogParams.hpp> + +namespace stdair { + + /** Interface for the STDAIR Services. */ + class STDAIR_Service { + public: + // ////////// Constructors and destructors ////////// + /** Constructor. + <br>The init() method is called; see the corresponding documentation + for more details. + <br>Moreover, a reference on an output stream is given, so + that log outputs can be directed onto that stream. + @param const stdair::BasLogParams& Parameters for the output log + stream. */ + STDAIR_Service (const BasLogParams&); + + /** Destructor. */ + ~STDAIR_Service(); + + + private: + // /////// Construction and Destruction helper methods /////// + /** Default constructor. */ + STDAIR_Service (); + /** Default copy constructor. */ + STDAIR_Service (const STDAIR_Service&); + + /** Initialise the log. */ + void logInit (const BasLogParams&); + + /** Initialise. + <br>The static instance of the log service (Logger object) is created. + <br>The static instance of the FacSupervisor object, itself referencing + all the other objects (factories and BOM), is created. + <br>As those two objects are static, there is no need to store them + in any service context. However, some lock mechanism may be needed + in order to secure the access to the corresponding resources. */ + void init (); + + /** Finalise. */ + void finalise (); + }; +} +#endif // __STDAIR_SVC_STDAIR_SERVICE_HPP Modified: trunk/stdair/stdair/basic/Makefile.am =================================================================== --- trunk/stdair/stdair/basic/Makefile.am 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/basic/Makefile.am 2010-01-22 19:47:29 UTC (rev 104) @@ -2,11 +2,14 @@ include $(top_srcdir)/Makefile.common include $(srcdir)/sources.mk +# noinst_LTLIBRARIES= libbas.la libbas_la_SOURCES = $(bas_h_sources) $(bas_cc_sources) libbas_la_CXXFLAGS = $(BOOST_CFLAGS) libbas_la_LDFLAGS = -#pkgincludedir = $(includedir)/@PACKAGE@/basic -#pkginclude_HEADERS = $(bas_h_sources) + +# Header files +pkgincludedir = $(includedir)/stdair/basic +pkginclude_HEADERS = $(bas_h_sources) Modified: trunk/stdair/stdair/bom/Makefile.am =================================================================== --- trunk/stdair/stdair/bom/Makefile.am 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/bom/Makefile.am 2010-01-22 19:47:29 UTC (rev 104) @@ -8,5 +8,7 @@ libbom_la_CXXFLAGS = $(BOOST_CFLAGS) libbom_la_LDFLAGS = -#pkgincludedir = $(includedir)/@PACKAGE@/bom -#pkginclude_HEADERS = $(bom_h_sources) + +# Header files +pkgincludedir = $(includedir)/stdair/bom +pkginclude_HEADERS = $(bom_h_sources) Modified: trunk/stdair/stdair/core/Makefile.am =================================================================== --- trunk/stdair/stdair/core/Makefile.am 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/core/Makefile.am 2010-01-22 19:47:29 UTC (rev 104) @@ -21,3 +21,7 @@ libstdair_la_LDFLAGS = \ $(BOOST_DATE_TIME_LIB) $(BOOST_PROGRAM_OPTIONS_LIB) $(BOOST_FILESYSTEM_LIB) \ -version-info $(GENERIC_LIBRARY_VERSION) + +# +pkgincludedir = $(includedir)/stdair +pkginclude_HEADERS = $(service_h_sources) Modified: trunk/stdair/stdair/core/sources.mk =================================================================== --- trunk/stdair/stdair/core/sources.mk 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/core/sources.mk 2010-01-22 19:47:29 UTC (rev 104) @@ -1,2 +1,3 @@ -service_h_sources = $(top_srcdir)/stdair/STDAIR_Types.hpp +service_h_sources = $(top_srcdir)/stdair/STDAIR_Types.hpp \ + $(top_srcdir)/stdair/STDAIR_Service.hpp service_cc_sources = Modified: trunk/stdair/stdair/factory/FacSupervisor.cpp =================================================================== --- trunk/stdair/stdair/factory/FacSupervisor.cpp 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/factory/FacSupervisor.cpp 2010-01-22 19:47:29 UTC (rev 104) @@ -38,7 +38,6 @@ FacSupervisor::~FacSupervisor() { cleanBomStructureLayer(); cleanBomContentLayer(); - cleanLoggerService(); } // ////////////////////////////////////////////////////////////////////// @@ -78,11 +77,13 @@ } // ////////////////////////////////////////////////////////////////////// - void FacSupervisor::cleanFactory () { + void FacSupervisor::cleanAll () { // Clean the static instance of the log service - Logger::clean(); + cleanLoggerService(); - // Clean the static instance of the FacSupervisor + // Clean the static instance of the FacSupervisor. + // This in turn will invoke the destructor (~FacSupervisor() method) + // of the static instance. delete _instance; _instance = NULL; } Modified: trunk/stdair/stdair/factory/FacSupervisor.hpp =================================================================== --- trunk/stdair/stdair/factory/FacSupervisor.hpp 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/factory/FacSupervisor.hpp 2010-01-22 19:47:29 UTC (rev 104) @@ -24,43 +24,46 @@ typedef std::vector<FacBomStructure*> BomStructureFactoryPool_T; typedef std::vector<FacBomContent*> BomContentFactoryPool_T; - /** Provides the unique instance. + /** 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 factory for the BomStructure layer. + /** Register a newly instantiated concrete factory for the + BomStructure layer. <br>When a concrete Factory is firstly instantiated this factory have to register itself to the FacSupervisor - @param FacBomStructure& the concrete Factory to register. */ + @param FacBomStructure* The concrete Factory to register. */ void registerBomStructureFactory (FacBomStructure*); - /** Register a newly instantiated concrete factory for the BomContent layer. + /** Register a newly instantiated concrete factory for the + BomContent layer. <br>When a concrete Factory is firstly instantiated this factory have to register itself to the FacSupervisor - @param FacBomContent& the concrete Factory to register. */ + @param FacBomContent* The concrete Factory to register. */ void registerBomContentFactory (FacBomContent*); - /** Clean all created object. - <br>Call the clean method of all the instantiated factories + /** Clean all registered object. + <br>Call the clean method of all the instantiated factories for the BomStructure layer. */ void cleanBomStructureLayer(); - /** Clean all created object. - <br>Call the clean method of all the instantiated factories + /** Clean all the registered object. + <br>Call the clean method of all the instantiated factories for the BomContent layer. */ void cleanBomContentLayer(); - /** Delete the Logger object. */ - void cleanLoggerService(); + /** Delete the static instance of the Logger object. */ + static void cleanLoggerService(); /** Clean the static instance. - <br> The singleton is deleted.*/ - static void cleanFactory (); + <br>As the static instance (singleton) is deleted, all the other + registered objects will be deleted in turn. */ + static void cleanAll (); - /** Destructor - <br>The static instance is deleted (and reset to NULL) - by the static cleanFactory() method. */ + /** Destructor. + <br>That destructors is applied on the static instance. It then + deletes in turn all the other registered objects. */ ~FacSupervisor(); Modified: trunk/stdair/stdair/factory/Makefile.am =================================================================== --- trunk/stdair/stdair/factory/Makefile.am 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/factory/Makefile.am 2010-01-22 19:47:29 UTC (rev 104) @@ -7,5 +7,7 @@ libfac_la_SOURCES= $(fac_h_sources) $(fac_cc_sources) libfac_la_CXXFLAGS = -#pkgincludedir = $(includedir)/@PACKAGE@/factory -#pkginclude_HEADERS = $(fac_h_sources) + +# Header files +pkgincludedir = $(includedir)/stdair/factory +pkginclude_HEADERS = $(fac_h_sources) Modified: trunk/stdair/stdair/service/Logger.cpp =================================================================== --- trunk/stdair/stdair/service/Logger.cpp 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/service/Logger.cpp 2010-01-22 19:47:29 UTC (rev 104) @@ -26,7 +26,7 @@ // ////////////////////////////////////////////////////////////////////// Logger::~Logger () { - std::cout << "In Logger destructor" << std::endl; + // std::cout << "In Logger destructor" << std::endl; } // ////////////////////////////////////////////////////////////////////// @@ -52,9 +52,11 @@ // ////////////////////////////////////////////////////////////////////// void Logger::clean() { - std::cout << "In Logger::clean(), before static instance deletion" << std::endl; + // std::cout << "In Logger::clean(), before static instance deletion" + // << std::endl; delete _instance; _instance = NULL; - std::cout << "In Logger::clean(), after static instance deletion" << std::endl; + // std::cout << "In Logger::clean(), after static instance deletion" + // << std::endl; } } Modified: trunk/stdair/stdair/service/Makefile.am =================================================================== --- trunk/stdair/stdair/service/Makefile.am 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/service/Makefile.am 2010-01-22 19:47:29 UTC (rev 104) @@ -2,10 +2,12 @@ include $(top_srcdir)/Makefile.common include $(srcdir)/sources.mk +# noinst_LTLIBRARIES= libsvc.la libsvc_la_SOURCES= $(svc_h_sources) $(svc_cc_sources) libsvc_la_CXXFLAGS = -#pkgincludedir = $(includedir)/@PACKAGE@/service -#pkginclude_HEADERS = $(svc_h_sources) +# Header files +pkgincludedir = $(includedir)/stdair/service +pkginclude_HEADERS = $(svc_h_sources) Added: trunk/stdair/stdair/service/STDAIR_Service.cpp =================================================================== --- trunk/stdair/stdair/service/STDAIR_Service.cpp (rev 0) +++ trunk/stdair/stdair/service/STDAIR_Service.cpp 2010-01-22 19:47:29 UTC (rev 104) @@ -0,0 +1,58 @@ +// ////////////////////////////////////////////////////////////////////// +// Import section +// ////////////////////////////////////////////////////////////////////// +// STL +#include <cassert> +// StdAir +#include <stdair/basic/BasChronometer.hpp> +#include <stdair/bom/BomManager.hpp> // for display() +#include <stdair/factory/FacSupervisor.hpp> +#include <stdair/service/Logger.hpp> +#include <stdair/STDAIR_Service.hpp> + +namespace stdair { + + // ////////////////////////////////////////////////////////////////////// + STDAIR_Service::STDAIR_Service () { + assert (false); + } + + // ////////////////////////////////////////////////////////////////////// + STDAIR_Service::STDAIR_Service (const STDAIR_Service& iService) { + assert (false); + } + + // ////////////////////////////////////////////////////////////////////// + STDAIR_Service::STDAIR_Service (const stdair::BasLogParams& iLogParams) { + // Set the log file + logInit (iLogParams); + + // Initialise the (remaining of the) context + init (); + } + + // ////////////////////////////////////////////////////////////////////// + STDAIR_Service::~STDAIR_Service () { + // Delete/Clean all the objects from memory + finalise(); + } + + // ////////////////////////////////////////////////////////////////////// + void STDAIR_Service::logInit (const BasLogParams& iLogParams) { + Logger::init (iLogParams); + } + + // ////////////////////////////////////////////////////////////////////// + void STDAIR_Service::init () { + // Create the static instance of the FacSupervisor object + FacSupervisor::instance(); + } + + // ////////////////////////////////////////////////////////////////////// + void STDAIR_Service::finalise () { + // std::cout << "In STDAIR_Service destructor, before cleaning" << std::endl; + FacSupervisor::cleanAll(); + // std::cout << "In STDAIR_Service destructor, after cleaning" << std::endl; + } + +} Modified: trunk/stdair/stdair/service/sources.mk =================================================================== --- trunk/stdair/stdair/service/sources.mk 2010-01-21 23:30:57 UTC (rev 103) +++ trunk/stdair/stdair/service/sources.mk 2010-01-22 19:47:29 UTC (rev 104) @@ -1,2 +1,3 @@ svc_h_sources = $(top_srcdir)/stdair/service/Logger.hpp -svc_cc_sources = $(top_srcdir)/stdair/service/Logger.cpp +svc_cc_sources = $(top_srcdir)/stdair/service/Logger.cpp \ + $(top_srcdir)/stdair/service/STDAIR_Service.cpp This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |