|
From: <qua...@us...> - 2009-12-30 11:28:36
|
Revision: 34
http://dsim.svn.sourceforge.net/dsim/?rev=34&view=rev
Author: quannaus
Date: 2009-12-30 10:14:40 +0000 (Wed, 30 Dec 2009)
Log Message:
-----------
[Dev] Added the ConfigurationParameters and the RDSParameters holders.
Modified Paths:
--------------
trunk/dsim/dsim/DSIM_Service.hpp
trunk/dsim/dsim/bom/sources.mk
trunk/dsim/dsim/service/DSIM_Service.cpp
trunk/dsim/dsim/service/DSIM_ServiceContext.hpp
Added Paths:
-----------
trunk/dsim/dsim/bom/ConfigurationParameters.cpp
trunk/dsim/dsim/bom/ConfigurationParameters.hpp
trunk/dsim/dsim/bom/RDSParameters.cpp
trunk/dsim/dsim/bom/RDSParameters.hpp
trunk/dsim/dsim/bom/StructAbstract.hpp
Modified: trunk/dsim/dsim/DSIM_Service.hpp
===================================================================
--- trunk/dsim/dsim/DSIM_Service.hpp 2009-12-30 10:13:43 UTC (rev 33)
+++ trunk/dsim/dsim/DSIM_Service.hpp 2009-12-30 10:14:40 UTC (rev 34)
@@ -14,20 +14,21 @@
// Forward declaration
class DSIM_ServiceContext;
-
+ struct RDSParameters;
/** Interface for the DSIM Services. */
class DSIM_Service {
+
+ private:
+ // ///////// Service Context /////////
+ /** Dsim context. */
+ DSIM_ServiceContext* _dsimServiceContext;
+
public:
- // /////////// Business Methods /////////////
- /** Perform a simulation. */
- void simulate();
-
-
// ////////// Constructors and destructors //////////
/** Constructor.
@param std::ostream& Output log stream (for instance, std::cout). */
- DSIM_Service (std::ostream& ioLogStream);
+ DSIM_Service (const std::string&, std::ostream& ioLogStream);
/** Destructor. */
~DSIM_Service();
@@ -41,16 +42,16 @@
DSIM_Service (const DSIM_Service&);
/** Initialise. */
- void init (std::ostream& ioLogStream);
+ void init (const std::string&, std::ostream& ioLogStream);
/** Finalise. */
void finalise ();
-
- private:
- // ///////// Service Context /////////
- /** Dsim context. */
- DSIM_ServiceContext* _dsimServiceContext;
+ public:
+ // /////////// Business Methods /////////////
+ /** Perform a simulation. */
+ void simulate();
+
};
}
#endif // __DSIM_SVC_DSIM_SERVICE_HPP
Added: trunk/dsim/dsim/bom/ConfigurationParameters.cpp
===================================================================
--- trunk/dsim/dsim/bom/ConfigurationParameters.cpp (rev 0)
+++ trunk/dsim/dsim/bom/ConfigurationParameters.cpp 2009-12-30 10:14:40 UTC (rev 34)
@@ -0,0 +1,39 @@
+// //////////////////////////////////////////////////////////////////////
+// Import section
+// //////////////////////////////////////////////////////////////////////
+// STL
+#include <sstream>
+#include <cassert>
+// DSIM
+#include <dsim/bom/ConfigurationParameters.hpp>
+#include <dsim/service/Logger.hpp>
+
+namespace DSIM {
+
+ // ////////////////////////////////////////////////////////////////////
+ ConfigurationParameters::ConfigurationParameters () {
+ }
+
+ // ////////////////////////////////////////////////////////////////////
+ ConfigurationParameters::
+ ConfigurationParameters (const ConfigurationParameters& iConfigurationParameters) {
+ }
+
+ // ////////////////////////////////////////////////////////////////////
+ ConfigurationParameters::~ConfigurationParameters () {
+ }
+
+ // ////////////////////////////////////////////////////////////////////
+ const std::string ConfigurationParameters::describe() const {
+ // Store current formatting flags of std::cout
+ std::ios::fmtflags oldFlags = std::cout.flags();
+
+ std::ostringstream ostr;
+
+ // Reset formatting flags of std::cout
+ std::cout.flags (oldFlags);
+
+ return ostr.str();
+ }
+
+}
Added: trunk/dsim/dsim/bom/ConfigurationParameters.hpp
===================================================================
--- trunk/dsim/dsim/bom/ConfigurationParameters.hpp (rev 0)
+++ trunk/dsim/dsim/bom/ConfigurationParameters.hpp 2009-12-30 10:14:40 UTC (rev 34)
@@ -0,0 +1,38 @@
+#ifndef __DSIM_BOM_CONFIGURATIONPARAMETERS_HPP
+#define __DSIM_BOM_CONFIGURATIONPARAMETERS_HPP
+
+// //////////////////////////////////////////////////////////////////////////
+// Import section
+// //////////////////////////////////////////////////////////////////////////
+// DSIM
+#include <dsim/bom/StructAbstract.hpp>
+
+namespace DSIM {
+
+ /** Structure wrapping the configuration parameters. */
+ struct ConfigurationParameters : public StructAbstract {
+
+ public:
+ // ///////// Attributes //////////
+
+ public:
+ /** Costructor. */
+ ConfigurationParameters ();
+ ConfigurationParameters (const ConfigurationParameters&);
+
+ /** Destructor. */
+ ~ConfigurationParameters ();
+
+
+ public:
+ // //////// GETTERS /////////
+
+ // //////// SETTERS /////////
+
+ /////////// DISPLAY METHOD ///////////
+ const std::string describe() const;
+
+ };
+
+}
+#endif //__DSIM_BOM_CONFIGURATIONPARAMETERS_HPP
Added: trunk/dsim/dsim/bom/RDSParameters.cpp
===================================================================
--- trunk/dsim/dsim/bom/RDSParameters.cpp (rev 0)
+++ trunk/dsim/dsim/bom/RDSParameters.cpp 2009-12-30 10:14:40 UTC (rev 34)
@@ -0,0 +1,44 @@
+// //////////////////////////////////////////////////////////////////////
+// Import section
+// //////////////////////////////////////////////////////////////////////
+// STL
+#include <sstream>
+#include <cassert>
+// DSIM
+#include <dsim/bom/RDSParameters.hpp>
+#include <dsim/service/Logger.hpp>
+
+namespace DSIM {
+
+ // ////////////////////////////////////////////////////////////////////
+ RDSParameters::RDSParameters () {
+ }
+
+ // ////////////////////////////////////////////////////////////////////
+ RDSParameters::RDSParameters (const RDSParameters& iRDSParameters)
+ : _scheduleInputFilename (iRDSParameters._scheduleInputFilename) {
+ }
+
+ // ////////////////////////////////////////////////////////////////////
+ RDSParameters::~RDSParameters () {
+ }
+
+ // ////////////////////////////////////////////////////////////////////
+ const std::string RDSParameters::describe() const {
+ // Store current formatting flags of std::cout
+ std::ios::fmtflags oldFlags = std::cout.flags();
+
+ std::ostringstream ostr;
+
+ ostr << "RDS Parameters: " << std::endl;
+
+ ostr << " Schedule file: " << _scheduleInputFilename;
+ ostr << std::endl;
+
+ // Reset formatting flags of std::cout
+ std::cout.flags (oldFlags);
+
+ return ostr.str();
+ }
+
+}
Added: trunk/dsim/dsim/bom/RDSParameters.hpp
===================================================================
--- trunk/dsim/dsim/bom/RDSParameters.hpp (rev 0)
+++ trunk/dsim/dsim/bom/RDSParameters.hpp 2009-12-30 10:14:40 UTC (rev 34)
@@ -0,0 +1,47 @@
+#ifndef __DSIM_BOM_RDSPARAMETERS_HPP
+#define __DSIM_BOM_RDSPARAMETERS_HPP
+
+// //////////////////////////////////////////////////////////////////////////
+// Import section
+// //////////////////////////////////////////////////////////////////////////
+// DSIM
+#include <dsim/bom/StructAbstract.hpp>
+
+namespace DSIM {
+
+ /** Structure wrapping the Reference Data Set parameters. */
+ struct RDSParameters : public StructAbstract {
+
+ public:
+ // ////////// Attributes ///////////
+ /** Schedule input filename. */
+ std::string _scheduleInputFilename;
+
+ public:
+ /** Costructor. */
+ RDSParameters ();
+ RDSParameters (const RDSParameters&);
+
+ /** Destructor. */
+ ~RDSParameters ();
+
+ public:
+ // //////// GETTERS /////////
+ /** Get the schedule input filename. */
+ const std::string& getScheduleInputFilename () const {
+ return _scheduleInputFilename;
+ }
+
+ // //////// SETTERS /////////
+ /** Set the schedule input filename. */
+ void setScheduleInputFilename (const std::string& iInputFilename) {
+ _scheduleInputFilename = iInputFilename;
+ }
+
+ /////////// DISPLAY METHOD ///////////
+ const std::string describe() const;
+
+ };
+
+}
+#endif //__DSIM_BOM_RDSPARAMETERS_HPP
Added: trunk/dsim/dsim/bom/StructAbstract.hpp
===================================================================
--- trunk/dsim/dsim/bom/StructAbstract.hpp (rev 0)
+++ trunk/dsim/dsim/bom/StructAbstract.hpp 2009-12-30 10:14:40 UTC (rev 34)
@@ -0,0 +1,84 @@
+#ifndef __DSIM_BOM_STRUCTABSTRACT_HPP
+#define __DSIM_BOM_STRUCTABSTRACT_HPP
+
+// //////////////////////////////////////////////////////////////////////
+// Import section
+// //////////////////////////////////////////////////////////////////////
+// STL
+#include <iostream>
+#include <sstream>
+
+namespace DSIM {
+
+ /** Base class for the Structures of the Business Object Model (BOM)
+ layer. */
+ struct StructAbstract {
+ public:
+
+ /** Destructor. */
+ virtual ~StructAbstract() {}
+
+ /** Dump a Business Object into an output stream.
+ @param ostream& the output stream. */
+ void toStream (std::ostream& ioOut) const {
+ ioOut << describe();
+ }
+
+ /** Read a Business Object from an input stream.
+ @param istream& the input stream. */
+ virtual void fromStream (std::istream& ioIn) {}
+
+ /** Display of the structure. */
+ virtual const std::string describe() const = 0;
+
+ protected:
+ /** Protected Default Constructor to ensure this class is abtract. */
+ StructAbstract() {}
+ };
+}
+
+/**
+ 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 DSIM::StructAbstract& iStruct) {
+ /**
+ string stream:
+ - with same format
+ - without special field width
+ */
+ std::basic_ostringstream<charT,traits> ostr;
+ ostr.copyfmt (ioOut);
+ ostr.width (0);
+
+ // Fill string stream
+ iStruct.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,
+ DSIM::StructAbstract& ioStruct) {
+ // Fill the Structure object with the input stream.
+ ioStruct.fromStream (ioIn);
+ return ioIn;
+
+}
+
+#endif // __DSIM_BOM_STRUCTABSTRACT_HPP
Modified: trunk/dsim/dsim/bom/sources.mk
===================================================================
--- trunk/dsim/dsim/bom/sources.mk 2009-12-30 10:13:43 UTC (rev 33)
+++ trunk/dsim/dsim/bom/sources.mk 2009-12-30 10:14:40 UTC (rev 34)
@@ -1,2 +1,7 @@
-bom_h_sources = $(top_srcdir)/dsim/bom/BomAbstract.hpp
-bom_cc_sources = $(top_srcdir)/dsim/bom/BomAbstract.cpp
+bom_h_sources = $(top_srcdir)/dsim/bom/BomAbstract.hpp \
+ $(top_srcdir)/dsim/bom/StructAbstract.hpp \
+ $(top_srcdir)/dsim/bom/ConfigurationParameters.hpp \
+ $(top_srcdir)/dsim/bom/RDSParameters.hpp
+bom_cc_sources = $(top_srcdir)/dsim/bom/BomAbstract.cpp \
+ $(top_srcdir)/dsim/bom/ConfigurationParameters.cpp \
+ $(top_srcdir)/dsim/bom/RDSParameters.cpp
Modified: trunk/dsim/dsim/service/DSIM_Service.cpp
===================================================================
--- trunk/dsim/dsim/service/DSIM_Service.cpp 2009-12-30 10:13:43 UTC (rev 33)
+++ trunk/dsim/dsim/service/DSIM_Service.cpp 2009-12-30 10:14:40 UTC (rev 34)
@@ -21,9 +21,10 @@
// //////////////////////////////////////////////////////////////////////
DSIM_Service::
- DSIM_Service (std::ostream& ioLogStream)
+ DSIM_Service (const std::string& iScheduleInputFilename,
+ std::ostream& ioLogStream)
: _dsimServiceContext (NULL) {
- init (ioLogStream);
+ init (iScheduleInputFilename, ioLogStream);
}
// //////////////////////////////////////////////////////////////////////
@@ -50,7 +51,8 @@
}
// //////////////////////////////////////////////////////////////////////
- void DSIM_Service::init (std::ostream& ioLogStream) {
+ void DSIM_Service::init (const std::string& iScheduleInputFilename,
+ std::ostream& ioLogStream) {
// Set the log file
logInit (LOG::DEBUG, ioLogStream);
@@ -64,7 +66,8 @@
// Initialise the SIMCRS service handler
const SIMCRS::CRSCode_T lCRSCode = "1S";
SIMCRS_ServicePtr_T lSIMCRS_Service =
- SIMCRS_ServicePtr_T (new SIMCRS::SIMCRS_Service (ioLogStream, lCRSCode));
+ SIMCRS_ServicePtr_T (new SIMCRS::SIMCRS_Service (ioLogStream, lCRSCode,
+ iScheduleInputFilename));
lDSIM_ServiceContext.setSIMCRS_Service (lSIMCRS_Service);
}
Modified: trunk/dsim/dsim/service/DSIM_ServiceContext.hpp
===================================================================
--- trunk/dsim/dsim/service/DSIM_ServiceContext.hpp 2009-12-30 10:13:43 UTC (rev 33)
+++ trunk/dsim/dsim/service/DSIM_ServiceContext.hpp 2009-12-30 10:14:40 UTC (rev 34)
@@ -10,6 +10,8 @@
#include <boost/shared_ptr.hpp>
// Dsim
#include <dsim/DSIM_Types.hpp>
+#include <dsim/bom/ConfigurationParameters.hpp>
+#include <dsim/bom/RDSParameters.hpp>
#include <dsim/service/ServiceAbstract.hpp>
// Forward declarations
@@ -22,10 +24,37 @@
namespace DSIM {
-
+
/** Class holding the context of the Dsim services. */
class DSIM_ServiceContext : public ServiceAbstract {
friend class FacDsimServiceContext;
+
+ private:
+ // ///////////// Children ////////////
+ /** CRS Service Handler. */
+ SIMCRS_ServicePtr_T _simcrsService;
+
+ private:
+ // //////////// Attributes //////////////////
+ /** Simulator ID. */
+ SimulatorID_T _simulatorID;
+
+ /** Configuration parameters. */
+ ConfigurationParameters _configurationParameters;
+
+ /** Reference Data Set parameters. */
+ RDSParameters _rdsParameters;
+
+ private:
+ // /////// Construction / initialisation ////////
+ /** Constructors. */
+ DSIM_ServiceContext ();
+ DSIM_ServiceContext (const SimulatorID_T&);
+ DSIM_ServiceContext (const DSIM_ServiceContext&);
+
+ /** Destructor. */
+ ~DSIM_ServiceContext();
+
public:
// ///////// Getters //////////
/** Get the simulator ID. */
@@ -33,6 +62,16 @@
return _simulatorID;
}
+ /** Get the configuration parameters. */
+ const ConfigurationParameters& getConfigurationParameters () const {
+ return _configurationParameters;
+ }
+
+ /** Get the RDS parameters. */
+ const RDSParameters& getRDSParameters () const {
+ return _rdsParameters;
+ }
+
/** Get a reference on the SIMCRS service handler. */
SIMCRS::SIMCRS_Service& getSIMCRS_Service () const {
return *_simcrsService.get();
@@ -44,6 +83,16 @@
_simulatorID = iSimulatorID;
}
+ /** Set the configuration parameters. */
+ void setConfigurationParameters (const ConfigurationParameters& iConfigurationParameters) {
+ _configurationParameters = iConfigurationParameters;
+ }
+
+ /** Set the RDS parameters. */
+ void setRDSParameters (const RDSParameters& iRDSParameters) {
+ _rdsParameters = iRDSParameters;
+ }
+
/** Set the pointer on the SIMCRS service handler. */
void setSIMCRS_Service (SIMCRS_ServicePtr_T ioSIMCRS_ServicePtr) {
_simcrsService = ioSIMCRS_ServicePtr;
@@ -55,29 +104,6 @@
/** Display the full DSIM_ServiceContext content. */
const std::string display() const;
-
-
- private:
- // /////// Construction / initialisation ////////
- /** Constructors. */
- DSIM_ServiceContext ();
- DSIM_ServiceContext (const SimulatorID_T&);
- DSIM_ServiceContext (const DSIM_ServiceContext&);
-
- /** Destructor. */
- ~DSIM_ServiceContext();
-
-
- private:
- // ///////////// Children ////////////
- /** CRS Service Handler. */
- SIMCRS_ServicePtr_T _simcrsService;
-
-
- private:
- // //////////// Attributes //////////////////
- /** Simulator ID. */
- SimulatorID_T _simulatorID;
};
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|