echempp-devel Mailing List for EChem++ (Page 8)
Status: Beta
Brought to you by:
berndspeiser
You can subscribe to this list here.
| 2003 |
Jan
|
Feb
|
Mar
|
Apr
(1) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(6) |
Jun
(3) |
Jul
|
Aug
|
Sep
|
Oct
(6) |
Nov
(6) |
Dec
(1) |
| 2005 |
Jan
(3) |
Feb
(12) |
Mar
(4) |
Apr
|
May
|
Jun
(4) |
Jul
|
Aug
(9) |
Sep
(2) |
Oct
|
Nov
(5) |
Dec
(4) |
| 2006 |
Jan
(56) |
Feb
(2) |
Mar
|
Apr
(1) |
May
(29) |
Jun
(38) |
Jul
(3) |
Aug
(4) |
Sep
(5) |
Oct
(1) |
Nov
(33) |
Dec
(26) |
| 2007 |
Jan
|
Feb
(56) |
Mar
(68) |
Apr
(14) |
May
(25) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(60) |
| 2008 |
Jan
(15) |
Feb
|
Mar
(59) |
Apr
(5) |
May
|
Jun
|
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
| 2009 |
Jan
|
Feb
|
Mar
|
Apr
(17) |
May
(4) |
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Bernd S. <ber...@us...> - 2007-05-14 15:38:29
|
Update of /cvsroot/echempp/Experiment/ExcitationFunction
In directory sc8-pr-cvs17:/tmp/cvs-serv31228/Experiment/ExcitationFunction
Modified Files:
excitationFunction.hpp
Log Message:
testing xml input failure
Index: excitationFunction.hpp
===================================================================
RCS file: /cvsroot/echempp/Experiment/ExcitationFunction/excitationFunction.hpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -d -r1.35 -r1.36
*** excitationFunction.hpp 11 May 2007 14:50:50 -0000 1.35
--- excitationFunction.hpp 14 May 2007 15:38:19 -0000 1.36
***************
*** 276,280 ****
void save (BSUtilities::xmlw::XmlStream &os) const
{
! os << BSUtilities::xmlw::tag (TAG)
<< BSUtilities::xmlw::attr ("segmentNumber")
<< (_segments.size());
--- 276,280 ----
void save (BSUtilities::xmlw::XmlStream &os) const
{
! os << BSUtilities::xmlw::tag (ExcitationFunction::TAG)
<< BSUtilities::xmlw::attr ("segmentNumber")
<< (_segments.size());
***************
*** 283,287 ****
_segments[i]->save (os);
! os << BSUtilities::xmlw::endtag (TAG);
}
--- 283,287 ----
_segments[i]->save (os);
! os << BSUtilities::xmlw::endtag (ExcitationFunction::TAG);
}
***************
*** 330,337 ****
TiXmlElement *element = node.Element();
! std::cout << " Tag zum Vergleich: `" << TAG << "'" << std::endl;
std::cout << " in ef load, TAG: `" << element->ValueStr () << std::endl;
! if (element && (element->ValueStr() == TAG))
{
TiXmlNode *child = 0;
--- 330,337 ----
TiXmlElement *element = node.Element();
! std::cout << " Tag zum Vergleich: `" << ExcitationFunction::TAG << "'" << std::endl;
std::cout << " in ef load, TAG: `" << element->ValueStr () << std::endl;
! if (element && (element->ValueStr() == ExcitationFunction::TAG))
{
TiXmlNode *child = 0;
***************
*** 884,887 ****
--- 884,889 ----
TiXmlElement *element = node.Element();
+ std::cout << " Tag zum Vergleich: `" << ExcitationFunction::TAG << "'" << std::endl;
+ //std::cout << " in sd_ef load, TAG: `" << element->ValueStr () << std::endl;
if (element && (element->ValueStr() == Segments::Segment::TAG))
{
|
|
From: Bernd S. <ber...@us...> - 2007-05-14 15:38:29
|
Update of /cvsroot/echempp/Experiment/ExcitationFunction/test
In directory sc8-pr-cvs17:/tmp/cvs-serv31228/Experiment/ExcitationFunction/test
Modified Files:
Makefile.am excitationFunctionTest.cpp
Log Message:
testing xml input failure
Index: excitationFunctionTest.cpp
===================================================================
RCS file: /cvsroot/echempp/Experiment/ExcitationFunction/test/excitationFunctionTest.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -C2 -d -r1.20 -r1.21
*** excitationFunctionTest.cpp 17 Feb 2007 18:03:16 -0000 1.20
--- excitationFunctionTest.cpp 14 May 2007 15:38:19 -0000 1.21
***************
*** 1013,1018 ****
--- 1013,1021 ----
<< std::endl;
CVExcitationFunction cv_xmlload;
+ std::cout << " CVExcitationFunction object generated!" << std::endl;
+ /*
try {
TiXmlHandle root = BSUtilities::xmlr::xmlInit (xmlsave_ef_filename);
+
cv_xmlload.load (root);
BSUtilities::xmlr::xmlFinish (root);
***************
*** 1030,1033 ****
--- 1033,1037 ----
<< " (expect: " << CV3.maximum () << ")" << std::endl;
std::cout << std::endl;
+ */
EtExcitationFunction et_xmlsave (HR);
Index: Makefile.am
===================================================================
RCS file: /cvsroot/echempp/Experiment/ExcitationFunction/test/Makefile.am,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** Makefile.am 23 Nov 2006 09:15:54 -0000 1.19
--- Makefile.am 14 May 2007 15:38:19 -0000 1.20
***************
*** 6,10 ****
-lQuantity \
-L$(BSUTILITIESLIB) -lBSUtilities \
! -L$(LOKILIB) -lloki
segmentsTest_SOURCES = segmentsTest.cpp
--- 6,10 ----
-lQuantity \
-L$(BSUTILITIESLIB) -lBSUtilities \
! -L$(LOKILIB) -lloki -lboost_serialization
segmentsTest_SOURCES = segmentsTest.cpp
***************
*** 27,31 ****
-lQuantity \
-L$(BSUTILITIESLIB) -lBSUtilities \
! -L$(LOKILIB) -lloki
INCLUDES = -I../.. \
--- 27,31 ----
-lQuantity \
-L$(BSUTILITIESLIB) -lBSUtilities \
! -L$(LOKILIB) -lloki -lboost_serialization
INCLUDES = -I../.. \
***************
*** 34,44 ****
-I$(BSUTILITIESSRC)
loadFunctionsTest_CXXFLAGS = -Wall -Werror -pedantic-errors \
! -DTIXML_USE_STL=YES
segmentsTest_CXXFLAGS = -Wall -Werror -pedantic-errors \
-DTIXML_USE_STL=YES
excitationFunctionTest_CXXFLAGS = -Wall -Werror -pedantic-errors \
! -DTIXML_USE_STL=YES
excitationFunctionTimingTest_CXXFLAGS = -Wall -Werror -pedantic-errors \
-DTIXML_USE_STL=YES
--- 34,54 ----
-I$(BSUTILITIESSRC)
+ # -Wno-parentheses is needed due to boost::serialization
+ # -Wno-unused-parameter is needed due to boost::serialization
loadFunctionsTest_CXXFLAGS = -Wall -Werror -pedantic-errors \
! -DTIXML_USE_STL=YES \
! -Wno-unused-parameter\
! -Wno-parentheses
segmentsTest_CXXFLAGS = -Wall -Werror -pedantic-errors \
-DTIXML_USE_STL=YES
+
+ # -Wno-parentheses is needed due to boost::serialization
+ # -Wno-unused-parameter is needed due to boost::serialization
excitationFunctionTest_CXXFLAGS = -Wall -Werror -pedantic-errors \
! -DTIXML_USE_STL=YES\
! -Wno-unused-parameter\
! -Wno-parentheses
!
excitationFunctionTimingTest_CXXFLAGS = -Wall -Werror -pedantic-errors \
-DTIXML_USE_STL=YES
|
|
From: Bernd S. <ber...@us...> - 2007-05-11 14:51:00
|
Update of /cvsroot/echempp/GUI/Windows/Qt/EChem++/Model/documentation In directory sc8-pr-cvs17:/tmp/cvs-serv22460/GUI/Windows/Qt/EChem++/Model/documentation Modified Files: Notes.log Log Message: testing xml input failure Index: Notes.log =================================================================== RCS file: /cvsroot/echempp/GUI/Windows/Qt/EChem++/Model/documentation/Notes.log,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Notes.log 26 Mar 2007 17:05:32 -0000 1.10 --- Notes.log 11 May 2007 14:50:50 -0000 1.11 *************** *** 98,99 **** --- 98,103 ---- added -Wno-parentheses to Makefile.am, since Qt3 produces such a warning. + + 10.05.2007 + + added -lboost_serialization to ModSim_LDADD. |
|
From: Bernd S. <ber...@us...> - 2007-05-11 14:51:00
|
Update of /cvsroot/echempp/Experiment/ExcitationFunction
In directory sc8-pr-cvs17:/tmp/cvs-serv22460/Experiment/ExcitationFunction
Modified Files:
excitationFunction.hpp
Log Message:
testing xml input failure
Index: excitationFunction.hpp
===================================================================
RCS file: /cvsroot/echempp/Experiment/ExcitationFunction/excitationFunction.hpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** excitationFunction.hpp 17 Feb 2007 18:03:16 -0000 1.34
--- excitationFunction.hpp 11 May 2007 14:50:50 -0000 1.35
***************
*** 329,332 ****
--- 329,336 ----
TiXmlElement *element = node.Element();
+
+ std::cout << " Tag zum Vergleich: `" << TAG << "'" << std::endl;
+ std::cout << " in ef load, TAG: `" << element->ValueStr () << std::endl;
+
if (element && (element->ValueStr() == TAG))
{
***************
*** 879,882 ****
--- 883,887 ----
TiXmlElement *element = node.Element();
+
if (element && (element->ValueStr() == Segments::Segment::TAG))
{
|
|
From: Bernd S. <ber...@us...> - 2007-05-11 14:51:00
|
Update of /cvsroot/echempp/Model/Adapters/documentation In directory sc8-pr-cvs17:/tmp/cvs-serv22460/Model/Adapters/documentation Modified Files: Notes.log Log Message: testing xml input failure Index: Notes.log =================================================================== RCS file: /cvsroot/echempp/Model/Adapters/documentation/Notes.log,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Notes.log 25 Mar 2007 17:45:52 -0000 1.2 --- Notes.log 11 May 2007 14:50:50 -0000 1.3 *************** *** 10,11 **** --- 10,15 ---- hetSurfacePowerLawParameters.cpp and homogeneousPowerLawParameters.cpp. + + 10.05.1007 + + adapted Makefile to boost::serialization (-W flags) |
|
From: Bernd S. <ber...@us...> - 2007-05-11 14:51:00
|
Update of /cvsroot/echempp/Model/Adapters
In directory sc8-pr-cvs17:/tmp/cvs-serv22460/Model/Adapters
Modified Files:
Makefile.am
Log Message:
testing xml input failure
Index: Makefile.am
===================================================================
RCS file: /cvsroot/echempp/Model/Adapters/Makefile.am,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** Makefile.am 23 Feb 2007 12:10:27 -0000 1.22
--- Makefile.am 11 May 2007 14:50:50 -0000 1.23
***************
*** 37,41 ****
--- 37,46 ----
dimGeometry1D.hpp \
dimGeometry1D.cpp
+
+ # -Wno-parentheses is needed due to boost::serialization
+ # -Wno-unused-parameter is needed due to boost::serialization
libeppAdapters_la_CXXFLAGS = -Wall -Werror -pedantic-errors\
+ -Wno-unused-parameter\
+ -Wno-parentheses\
-DTIXML_USE_STL
|
|
From: Bernd S. <ber...@us...> - 2007-05-11 14:51:00
|
Update of /cvsroot/echempp/GUI/Windows/Qt/EChem++/Model In directory sc8-pr-cvs17:/tmp/cvs-serv22460/GUI/Windows/Qt/EChem++/Model Modified Files: Makefile.am Log Message: testing xml input failure Index: Makefile.am =================================================================== RCS file: /cvsroot/echempp/GUI/Windows/Qt/EChem++/Model/Makefile.am,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** Makefile.am 27 Mar 2007 12:53:59 -0000 1.41 --- Makefile.am 11 May 2007 14:50:50 -0000 1.42 *************** *** 249,253 **** BUILT_SOURCES = $(ModSim_MOC) $(ModSim_UI) ! ModSim_LDFLAGS = $(GUI_LDFLAGS) # option -Wnon-non-virtual-dtor has to be used since Ginac produces a lot of warnings --- 249,253 ---- BUILT_SOURCES = $(ModSim_MOC) $(ModSim_UI) ! ModSim_LDFLAGS = $(GUI_LDFLAGS) # option -Wnon-non-virtual-dtor has to be used since Ginac produces a lot of warnings *************** *** 263,267 **** -Wno-non-virtual-dtor -Wno-deprecated -Wno-long-long -Wno-strict-aliasing ! ModSim_LDADD = ../../../../../Analysis/Data/libeppDataold.la ../../../../../Model/Problem/libeppProblem.la ../../../../../Model/Adapters/libeppAdapters.la ../../../../../Model/Ecco/libeppEcco.la ../../../../../Model/Solvers/libeppSolvers.la ../../../../../Model/Numerics/libeppNumerics.la ../../../../../Experiment/ExcitationFunction/libeppExcitationFunction.la ../../../../Visualization/libeppVisualization.la -L$(QUANTITIESLIB) -lPhysicalQuantities -lQuantity -L$(BSUTILITIESLIB) -lBSUtilities -L$(LOKILIB) -lloki -L$(GINACLIB) -lginac $(LDADD) $(QT_LDADD) $(VTK_LDADD) $(MODEL_LDADD) CLEANFILES = $(BUILT_SOURCES) --- 263,267 ---- -Wno-non-virtual-dtor -Wno-deprecated -Wno-long-long -Wno-strict-aliasing ! ModSim_LDADD = ../../../../../Analysis/Data/libeppDataold.la ../../../../../Model/Problem/libeppProblem.la ../../../../../Model/Adapters/libeppAdapters.la ../../../../../Model/Ecco/libeppEcco.la ../../../../../Model/Solvers/libeppSolvers.la ../../../../../Model/Numerics/libeppNumerics.la ../../../../../Experiment/ExcitationFunction/libeppExcitationFunction.la ../../../../Visualization/libeppVisualization.la -L$(QUANTITIESLIB) -lPhysicalQuantities -lQuantity -L$(BSUTILITIESLIB) -lBSUtilities -L$(LOKILIB) -lloki -L$(GINACLIB) -lginac $(LDADD) $(QT_LDADD) $(VTK_LDADD) $(MODEL_LDADD) -lboost_serialization CLEANFILES = $(BUILT_SOURCES) |
|
From: Bernd S. <ber...@us...> - 2007-05-11 14:51:00
|
Update of /cvsroot/echempp/Analysis/Data
In directory sc8-pr-cvs17:/tmp/cvs-serv22460/Analysis/Data
Modified Files:
Makefile.am
Log Message:
testing xml input failure
Index: Makefile.am
===================================================================
RCS file: /cvsroot/echempp/Analysis/Data/Makefile.am,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** Makefile.am 9 Feb 2006 11:22:58 -0000 1.15
--- Makefile.am 11 May 2007 14:50:50 -0000 1.16
***************
*** 28,32 ****
--- 28,37 ----
bas100dataOld.hpp \
bas100dataOld.cpp
+
+ # -Wno-parentheses is needed due to boost::serialization
+ # -Wno-unused-parameter is needed due to boost::serialization
libeppDataold_la_CXXFLAGS = -Wall -Werror -pedantic-errors -Wno-deprecated \
+ -Wno-unused-parameter\
+ -Wno-parentheses\
-DTIXML_USE_STL
|
|
From: beeblbrox <bee...@us...> - 2007-05-05 08:49:11
|
Update of /cvsroot/echempp/Experiment/Experiment In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv28324 Modified Files: Experiment.hpp Log Message: Updated to use TechniqueType, autoregistration yet to be added. Index: Experiment.hpp =================================================================== RCS file: /cvsroot/echempp/Experiment/Experiment/Experiment.hpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Experiment.hpp 11 Apr 2007 08:25:35 -0000 1.4 --- Experiment.hpp 5 May 2007 08:49:07 -0000 1.5 *************** *** 1,2 **** --- 1,26 ---- + /*! \file Experiment.hpp + \brief header file for experiment classes. + + Experiment.hpp is part of the Experiment package. + */ + + /* Copyright (C) 2007, Dominik Brugger, Bernd Speiser + This file is part of EChem++. + + EChem++ is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + EChem++ is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. + */ // $Id$ *************** *** 27,32 **** --- 51,62 ---- #include <loki/LokiTypeInfo.h> + // BSUtilities includes + #include "TemplateTools.h" + #include "SerializationTools.h" + #include "TypeToName.h" + // Local includes #include "ExcitationFunction/excitationFunction.hpp" + #include "Experiment/TechniqueType.hpp" namespace experiment *************** *** 38,43 **** --- 68,76 ---- { public: + //! Type of functor argument. typedef Obj argument_type; + //! Type of functor result. typedef void result_type; + //! Apply functor to argument. result_type operator()(argument_type obj) { *************** *** 50,58 **** { //! Type used to designate simulated experiments. ! struct Simulated{}; //! Type used to designate real experiments. ! struct Real{}; //! Type used to designate dual experiments, e.g. one part real the other simulated. ! struct Dual{}; } //! Namespace for dynamics types. --- 83,103 ---- { //! Type used to designate simulated experiments. ! struct Simulated ! { ! static const std::string TSID; ! }; ! const std::string Simulated::TSID = "experiment::realism::Simulated"; //! Type used to designate real experiments. ! struct Real ! { ! static const std::string TSID; ! }; ! const std::string Real::TSID = "experiment::realism::Real"; //! Type used to designate dual experiments, e.g. one part real the other simulated. ! struct Dual ! { ! static const std::string TSID; ! }; ! const std::string Dual::TSID = "experiment::realism::Dual"; } //! Namespace for dynamics types. *************** *** 60,70 **** { //! Type used to designate dynamic experiments. ! struct Dynamic{}; //! Type used to designate static experiments. ! struct Static{}; } //! Exception class for experiment module. ! //! This exception is thrown for example, when violation of //! Experiment container invariants occurs. //! \sa Homogeneous --- 105,123 ---- { //! Type used to designate dynamic experiments. ! struct Dynamic ! { ! static const std::string TSID; ! }; ! const std::string Dynamic::TSID = "experiment::dynamics::Dynamic"; //! Type used to designate static experiments. ! struct Static ! { ! static const std::string TSID; ! }; ! const std::string Static::TSID = "experiment::dynamics::Static"; } //! Exception class for experiment module. ! //! This exception is thrown for example, when a violation of //! Experiment container invariants occurs. //! \sa Homogeneous *************** *** 88,97 **** { public: ! Experiment() { title_ = "Insert Experiment title"; } ! Experiment(const std::string title) : title_(title) {} virtual ~Experiment() {} virtual void perform() = 0; virtual void add(Experiment* e) = 0; virtual void remove(const size_t idx) = 0; virtual const Loki::TypeInfo get_independent_type() const = 0; virtual const Loki::TypeInfo get_dependent_type() const = 0; --- 141,152 ---- { public: ! Experiment() { title_ = "Insert Experiment title"; parent_ = NULL; } ! Experiment(const std::string title) : title_(title) { parent_ = NULL; } virtual ~Experiment() {} virtual void perform() = 0; virtual void add(Experiment* e) = 0; virtual void remove(const size_t idx) = 0; + Experiment* get_parent() { return parent_; } + void set_parent(Experiment* parent) { parent_ = parent; } virtual const Loki::TypeInfo get_independent_type() const = 0; virtual const Loki::TypeInfo get_dependent_type() const = 0; *************** *** 109,117 **** private: std::string title_; friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ! ar & BOOST_SERIALIZATION_NVP(title_); } }; --- 164,174 ---- private: std::string title_; + Experiment* parent_; friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ! ar & BOOST_SERIALIZATION_NVP(title_) ! & BOOST_SERIALIZATION_NVP(parent_); } }; *************** *** 120,128 **** //! Atomic experiments are used to represent self-contained //! experiments that are not further divisible. ! template<class Realism, ! class Dynamics> class Atomic : public Experiment { public: Atomic() {} Atomic(const std::string title) : Experiment(title) {} --- 177,186 ---- //! Atomic experiments are used to represent self-contained //! experiments that are not further divisible. ! template<class TechType> class Atomic : public Experiment { public: + typedef typename TechType::dynamics_type dynamics_type; + typedef typename TechType::realism_type realism_type; Atomic() {} Atomic(const std::string title) : Experiment(title) {} *************** *** 131,140 **** const Loki::TypeInfo get_realism_type() const { ! Loki::TypeInfo info = typeid(Realism); return info; } const Loki::TypeInfo get_dynamics_type() const { ! Loki::TypeInfo info = typeid(Dynamics); return info; } --- 189,198 ---- const Loki::TypeInfo get_realism_type() const { ! Loki::TypeInfo info = typeid(realism_type); return info; } const Loki::TypeInfo get_dynamics_type() const { ! Loki::TypeInfo info = typeid(dynamics_type); return info; } *************** *** 162,175 **** //! \sa Induced //! \sa Observation template<class Realism, class Dynamics, ! class D, /* type of dependent variable */ ! class I> /* type of independent variable */ ! class Action : public Atomic<Realism, Dynamics> { public: ! typedef Atomic<Realism, Dynamics> AtomicBase; Action() {} ! Action(const std::string title) : AtomicBase(title) {} virtual ~Action() {} virtual void perform() {} --- 220,243 ---- //! \sa Induced //! \sa Observation + template<class TechType> class Action : public Atomic<TechType> {}; template<class Realism, class Dynamics, ! class I, ! class D, ! class R, ! template<class, class> class S> ! class Action<TechniqueType<Realism, Dynamics, I, D, R, S> > ! : public Atomic<TechniqueType<Realism, Dynamics, I, D, R, S> > { public: ! typedef TechniqueType<Realism, Dynamics, I, D, R, S> TechType; ! // BSUtilities::AutoRegistor<Action<TechType> > reg; ! // static const std::string TSID; ! typedef Atomic<TechType> ! _AtomicBase; ! typedef Action<TechType> ! _Action; Action() {} ! Action(const std::string title) : _AtomicBase(title) {} virtual ~Action() {} virtual void perform() {} *************** *** 206,214 **** execution_end = pt; } ! const ExcitationFunctions::DIExcitationFunction<D,I> get_exc_func() const { return exc_func; } ! void set_exc_func(const ExcitationFunctions::DIExcitationFunction<D,I>& ef) { exc_func = ef; --- 274,284 ---- execution_end = pt; } ! const ExcitationFunctions::SDIExcitationFunction<D,I,S> ! get_exc_func() const { return exc_func; } ! void set_exc_func(const ExcitationFunctions::SDIExcitationFunction< ! D, I, S>& ef) { exc_func = ef; *************** *** 216,221 **** const bool has_matching_independent_range(Experiment* e) const { ! Action<Realism, Dynamics, D, I> *a = ! dynamic_cast<Action<Realism, Dynamics, D, I> *>(e); if(a != 0) { --- 286,290 ---- const bool has_matching_independent_range(Experiment* e) const { ! _Action *a = dynamic_cast<_Action *>(e); if(a != 0) { *************** *** 233,238 **** virtual const bool equal(Experiment* e) const { ! Action<Realism, Dynamics, D, I>* a ! = dynamic_cast<Action<Realism, Dynamics, D, I>* >(e); return a != 0 && execution_start == a->execution_start --- 302,306 ---- virtual const bool equal(Experiment* e) const { ! _Action* a = dynamic_cast<_Action *>(e); return a != 0 && execution_start == a->execution_start *************** *** 240,244 **** && exc_func == a->exc_func /* TODO: Check equality of other fields */ ! && Atomic<Realism, Dynamics>::equal(e); } private: --- 308,312 ---- && exc_func == a->exc_func /* TODO: Check equality of other fields */ ! && _AtomicBase::equal(e); } private: *************** *** 247,251 **** void serialize(Archive & ar, const unsigned int version) { ! ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(AtomicBase) & BOOST_SERIALIZATION_NVP(execution_start) & BOOST_SERIALIZATION_NVP(execution_end); --- 315,319 ---- void serialize(Archive & ar, const unsigned int version) { ! ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(_AtomicBase) & BOOST_SERIALIZATION_NVP(execution_start) & BOOST_SERIALIZATION_NVP(execution_end); *************** *** 254,259 **** boost::posix_time::ptime execution_start; boost::posix_time::ptime execution_end; ! ExcitationFunctions::DIExcitationFunction<D,I> exc_func; }; //! Class to represent induced experiments. --- 322,337 ---- boost::posix_time::ptime execution_start; boost::posix_time::ptime execution_end; ! ExcitationFunctions::SDIExcitationFunction<D,I,S> exc_func; }; + + // template<class Realism, + // class Dynamics, + // class I, + // class D, + // class R, + // template<class, class> class S> + // const std::string Action<TechniqueType<Realism,Dynamics,I,D,R,S> >::TSID = + // "experiment::Action" + + // BSUtilities::TypeToName<TechniqueType<Realism,Dynamics,I,D,R,S> >(); //! Class to represent induced experiments. *************** *** 262,273 **** //! \sa Action //! \sa Observation template<class Realism, class Dynamics, ! class D, /* type of dependent variable */ ! class I, /* type of independent variable */ ! class R> /* type of result variable */ ! class Induced : public Atomic<Realism, Dynamics> { public: Induced() {}; virtual ~Induced() { std::cout << "Called ~Induced" << std::endl; }; --- 340,358 ---- //! \sa Action //! \sa Observation + template<class TechType> class Induced : public Atomic<TechType> {}; template<class Realism, class Dynamics, ! class I, ! class D, ! class R, ! template<class, class> class S> ! class Induced<TechniqueType<Realism, Dynamics, I, D, R, S> > ! : public Atomic<TechniqueType<Realism, Dynamics, I, D, R, S> > { public: + typedef Atomic<TechniqueType<Realism, Dynamics, I, D, R, S> > + _AtomicBase; + typedef Induced<TechniqueType<Realism, Dynamics, I, D, R, S> > + _Induced; Induced() {}; virtual ~Induced() { std::cout << "Called ~Induced" << std::endl; }; *************** *** 291,296 **** const bool has_matching_independent_range(Experiment* e) const { ! Induced<Realism, Dynamics, D, I, R> *i = ! dynamic_cast<Induced<Realism, Dynamics, D, I, R> *>(e); if(i != 0) { --- 376,380 ---- const bool has_matching_independent_range(Experiment* e) const { ! _Induced *i = dynamic_cast<_Induced *>(e); if(i != 0) { *************** *** 308,313 **** virtual const bool equal(Experiment* e) const { ! Induced<Realism, Dynamics, D, I, R> *i = ! dynamic_cast<Induced<Realism, Dynamics, D, I, R>* >(e); return i != 0 && induction_start == i->induction_start --- 392,396 ---- virtual const bool equal(Experiment* e) const { ! _Induced *i = dynamic_cast<_Induced *>(e); return i != 0 && induction_start == i->induction_start *************** *** 315,319 **** && exc_func == i->exc_func /* TODO: Check equality of other fields */ ! && Atomic<Realism, Dynamics>::equal(e); } const boost::posix_time::ptime get_induction_start() const --- 398,402 ---- && exc_func == i->exc_func /* TODO: Check equality of other fields */ ! && _AtomicBase::equal(e); } const boost::posix_time::ptime get_induction_start() const *************** *** 333,351 **** induction_end = pt; } ! const ExcitationFunctions::DIExcitationFunction<D,I> get_exc_func() const { return exc_func; } ! void set_exc_func(const ExcitationFunctions::DIExcitationFunction<D,I>& ef) { exc_func = ef; } private: - typedef Atomic<Realism, Dynamics> AtomicBase; friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ! ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(AtomicBase) & BOOST_SERIALIZATION_NVP(induction_start) & BOOST_SERIALIZATION_NVP(induction_end); --- 416,435 ---- induction_end = pt; } ! const ExcitationFunctions::SDIExcitationFunction<D, I, S> ! get_exc_func() const { return exc_func; } ! void set_exc_func(const ExcitationFunctions::SDIExcitationFunction< ! D, I, S>& ef) { exc_func = ef; } private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ! ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(_AtomicBase) & BOOST_SERIALIZATION_NVP(induction_start) & BOOST_SERIALIZATION_NVP(induction_end); *************** *** 354,358 **** boost::posix_time::ptime induction_start; boost::posix_time::ptime induction_end; ! ExcitationFunctions::DIExcitationFunction<D,I> exc_func; // TODO: MeasurementData ? R result; --- 438,442 ---- boost::posix_time::ptime induction_start; boost::posix_time::ptime induction_end; ! ExcitationFunctions::SDIExcitationFunction<D, I, S> exc_func; // TODO: MeasurementData ? R result; *************** *** 365,373 **** //! \sa Action //! \sa Induced ! template<class Realism, ! class Dynamics, ! class I, /* type of independent variable */ ! class R> /* type of result variable */ ! class Observation : public Atomic<Realism, Dynamics> {}; // partial template specialization to enforce constraint, --- 449,458 ---- //! \sa Action //! \sa Induced ! template<class TechType> ! class Observation : Atomic<TechType> {}; ! // { ! // private: ! // Observation(){} ! // }; // partial template specialization to enforce constraint, *************** *** 377,385 **** class I, class R> ! class Observation<Realism, dynamics::Dynamic, I, R> ! : public Atomic<Realism, dynamics::Dynamic> { public: Observation() {}; Observation(const I start, const I end) : start_(start), end_(end) {}; --- 462,472 ---- class I, class R> ! class Observation<TechniqueType<Realism, dynamics::Dynamic, I, Loki::EmptyType, R, BSUtilities::EmptyTemplate_2> > ! : public Atomic<TechniqueType<Realism, dynamics::Dynamic, I, Loki::EmptyType, R, BSUtilities::EmptyTemplate_2> > { public: Observation() {}; + typedef Observation<TechniqueType<Realism, dynamics::Dynamic, I, Loki::EmptyType, R, BSUtilities::EmptyTemplate_2> > _Observation; + typedef Atomic<TechniqueType<Realism, dynamics::Dynamic, I, Loki::EmptyType, R, BSUtilities::EmptyTemplate_2> > _AtomicBase; Observation(const I start, const I end) : start_(start), end_(end) {}; *************** *** 404,409 **** const bool has_matching_independent_range(Experiment* e) const { ! Observation<Realism, dynamics::Dynamic, I, R> *o = ! dynamic_cast<Observation<Realism, dynamics::Dynamic, I, R> *>(e); if(o != 0) { --- 491,495 ---- const bool has_matching_independent_range(Experiment* e) const { ! _Observation *o = dynamic_cast<_Observation *>(e); if(o != 0) { *************** *** 433,442 **** void set_end(const I end) { end_ = end; } private: - typedef Atomic<Realism, dynamics::Dynamic> AtomicBase; friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ! ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(AtomicBase) & BOOST_SERIALIZATION_NVP(recording_start_) & BOOST_SERIALIZATION_NVP(recording_end_); --- 519,527 ---- void set_end(const I end) { end_ = end; } private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ! ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(_AtomicBase) & BOOST_SERIALIZATION_NVP(recording_start_) & BOOST_SERIALIZATION_NVP(recording_end_); *************** *** 453,460 **** template<class Realism, class R> ! class Observation<Realism, dynamics::Static, Loki::EmptyType, R> ! : public Atomic<Realism, dynamics::Static> { public: Observation() {}; virtual ~Observation() { std::cout << "Called ~Observation" << std::endl; }; --- 538,555 ---- template<class Realism, class R> ! class Observation<TechniqueType<Realism, dynamics::Static, Loki::EmptyType, ! Loki::EmptyType, ! R, BSUtilities::EmptyTemplate_2> > ! : public Atomic<TechniqueType<Realism, dynamics::Static, Loki::EmptyType, ! Loki::EmptyType, ! R, BSUtilities::EmptyTemplate_2> > { public: + typedef Observation<TechniqueType<Realism, dynamics::Static, Loki::EmptyType, + Loki::EmptyType, + R, BSUtilities::EmptyTemplate_2> > _Observation; + typedef Atomic<TechniqueType<Realism, dynamics::Static, Loki::EmptyType, + Loki::EmptyType, + R, BSUtilities::EmptyTemplate_2> > _AtomicBase; Observation() {}; virtual ~Observation() { std::cout << "Called ~Observation" << std::endl; }; *************** *** 481,490 **** } private: - typedef Atomic<Realism, dynamics::Static> AtomicBase; friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ! ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(AtomicBase) & BOOST_SERIALIZATION_NVP(recording_start) & BOOST_SERIALIZATION_NVP(recording_end); --- 576,584 ---- } private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ! ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(_AtomicBase) & BOOST_SERIALIZATION_NVP(recording_start) & BOOST_SERIALIZATION_NVP(recording_end); *************** *** 515,518 **** --- 609,613 ---- virtual void add(Experiment* e) { + e->set_parent(this); elements.push_back(e); } *************** *** 772,811 **** }; ! typedef Action<realism::Real, dynamics::Dynamic, ! quantity::ElectricPotential, quantity::Time> ! RealDynamicEPTAction; ! typedef Action<realism::Simulated, dynamics::Dynamic, ! quantity::ElectricPotential, quantity::Time> ! SimulatedDynamicEPTAction; ! typedef Action<realism::Dual, dynamics::Dynamic, ! quantity::ElectricPotential, quantity::Time> ! DualDynamicEPTAction; ! typedef Action<realism::Real, dynamics::Static, ! quantity::ElectricPotential, quantity::Time> ! RealStaticEPTAction; ! typedef Action<realism::Simulated, dynamics::Static, ! quantity::ElectricPotential, quantity::Time> ! SimulatedStaticEPTAction; ! typedef Action<realism::Dual, dynamics::Static, ! quantity::ElectricPotential, quantity::Time> ! DualStaticEPTAction; ! typedef Action<realism::Real, dynamics::Dynamic, ! quantity::ElectricPotential, quantity::CelsiusTemperature> ! RealDynamicEPTempAction; ! typedef Action<realism::Real, dynamics::Dynamic, ! quantity::ElectricCurrent, quantity::Time> ! RealDynamicECTAction; ! typedef Observation<realism::Real, dynamics::Dynamic, quantity::Time, ! quantity::ElectricPotential> ! RealDynamicTEPObservation; ! typedef Induced<realism::Real, dynamics::Dynamic, ! quantity::ElectricPotential, quantity::Time, quantity::Time> ! RealDynamicEPTInduced; ! typedef Atomic<realism::Real, dynamics::Dynamic> RealDynamicAtomic; ! typedef Atomic<realism::Real, dynamics::Static> RealStaticAtomic; ! typedef Atomic<realism::Simulated, dynamics::Dynamic> SimulatedDynamicAtomic; ! typedef Atomic<realism::Simulated, dynamics::Static> SimulatedStaticAtomic; ! typedef Atomic<realism::Dual, dynamics::Dynamic> DualDynamicAtomic; ! typedef Atomic<realism::Dual, dynamics::Static> DualStaticAtomic; } // end namespace experiment --- 867,1016 ---- }; ! namespace cv ! { ! typedef TechniqueType<realism::Real, ! dynamics::Dynamic, ! quantity::Time, ! quantity::ElectricPotential, ! quantity::ElectricCurrent, ! ExcitationFunctions::Segments::LinearSegment> ! RealDynamicTech; ! typedef TechniqueType<realism::Simulated, ! dynamics::Dynamic, ! quantity::Time, ! quantity::ElectricPotential, ! quantity::ElectricCurrent, ! ExcitationFunctions::Segments::LinearSegment> ! SimulatedDynamicTech; ! typedef TechniqueType<realism::Dual, ! dynamics::Dynamic, ! quantity::Time, ! quantity::ElectricPotential, ! quantity::ElectricCurrent, ! ExcitationFunctions::Segments::LinearSegment> ! DualDynamicTech; ! } // end namespace cv ! ! namespace internal{ ! // for internal testing of experiment classes, do not use ! typedef TechniqueType<realism::Real, ! dynamics::Dynamic, ! quantity::Time, ! quantity::ElectricPotential, ! Loki::EmptyType, ! ExcitationFunctions::Segments::LinearSegment> ! AT1; ! typedef TechniqueType<realism::Simulated, ! dynamics::Dynamic, ! quantity::Time, ! quantity::ElectricPotential, ! Loki::EmptyType, ! ExcitationFunctions::Segments::LinearSegment> ! AT2; ! typedef TechniqueType<realism::Dual, ! dynamics::Dynamic, ! quantity::Time, ! quantity::ElectricPotential, ! Loki::EmptyType, ! ExcitationFunctions::Segments::LinearSegment> ! AT3; ! typedef TechniqueType<realism::Real, ! dynamics::Static, ! quantity::Time, ! quantity::ElectricPotential, ! Loki::EmptyType, ! ExcitationFunctions::Segments::LinearSegment> ! AT4; ! typedef TechniqueType<realism::Simulated, ! dynamics::Static, ! quantity::Time, ! quantity::ElectricPotential, ! Loki::EmptyType, ! ExcitationFunctions::Segments::LinearSegment> ! AT5; ! typedef TechniqueType<realism::Dual, ! dynamics::Static, ! quantity::Time, ! quantity::ElectricPotential, ! Loki::EmptyType, ! ExcitationFunctions::Segments::LinearSegment> ! AT6; ! typedef TechniqueType<realism::Real, ! dynamics::Dynamic, ! quantity::CelsiusTemperature, ! quantity::ElectricPotential, ! Loki::EmptyType, ! ExcitationFunctions::Segments::LinearSegment> ! AT7; ! typedef TechniqueType<realism::Real, ! dynamics::Dynamic, ! quantity::Time, ! quantity::ElectricCurrent, ! Loki::EmptyType, ! ExcitationFunctions::Segments::LinearSegment> ! AT8; ! typedef TechniqueType<realism::Real, ! dynamics::Dynamic, ! quantity::Time, ! Loki::EmptyType, ! quantity::ElectricCurrent, ! BSUtilities::EmptyTemplate_2> ! OT1; ! typedef TechniqueType<realism::Simulated, ! dynamics::Dynamic, ! quantity::Time, ! Loki::EmptyType, ! quantity::ElectricCurrent, ! BSUtilities::EmptyTemplate_2> ! OT2; ! typedef TechniqueType<realism::Dual, ! dynamics::Dynamic, ! quantity::Time, ! Loki::EmptyType, ! quantity::ElectricCurrent, ! ExcitationFunctions::Segments::LinearSegment> ! OT3; ! typedef TechniqueType<realism::Real, ! dynamics::Dynamic, ! quantity::Time, ! quantity::ElectricPotential, ! quantity::ElectricCurrent, ! ExcitationFunctions::Segments::LinearSegment> ! IT1; ! typedef TechniqueType<realism::Simulated, ! dynamics::Dynamic, ! quantity::Time, ! quantity::ElectricPotential, ! quantity::ElectricCurrent, ! ExcitationFunctions::Segments::LinearSegment> ! IT2; ! typedef TechniqueType<realism::Dual, ! dynamics::Dynamic, ! quantity::Time, ! quantity::ElectricPotential, ! quantity::ElectricCurrent, ! ExcitationFunctions::Segments::LinearSegment> ! IT3; ! ! } ! ! typedef Action<internal::AT1> RealDynamicEPTAction; ! typedef Action<internal::AT2> SimulatedDynamicEPTAction; ! typedef Action<internal::AT3> DualDynamicEPTAction; ! typedef Observation<internal::OT1> RealDynamicTEPObservation; ! typedef Induced<internal::IT1> RealDynamicEPTInduced; ! ! typedef Action<internal::AT4> RealStaticEPTAction; ! typedef Action<internal::AT5> SimulatedStaticEPTAction; ! typedef Action<internal::AT6> DualStaticEPTAction; ! typedef Action<internal::AT7> RealDynamicEPTempAction; ! typedef Action<internal::AT8> RealDynamicECTAction; ! ! typedef Atomic<internal::AT1> RealDynamicAtomic; ! typedef Atomic<internal::AT4> RealStaticAtomic; ! typedef Atomic<internal::AT2> SimulatedDynamicAtomic; ! typedef Atomic<internal::AT5> SimulatedStaticAtomic; ! typedef Atomic<internal::AT3> DualDynamicAtomic; ! typedef Atomic<internal::AT6> DualStaticAtomic; } // end namespace experiment |
|
From: beeblbrox <bee...@us...> - 2007-05-05 08:49:10
|
Update of /cvsroot/echempp/Experiment/Experiment/test In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv28324/test Modified Files: ExperimentTest.cpp Log Message: Updated to use TechniqueType, autoregistration yet to be added. Index: ExperimentTest.cpp =================================================================== RCS file: /cvsroot/echempp/Experiment/Experiment/test/ExperimentTest.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ExperimentTest.cpp 11 Apr 2007 08:24:32 -0000 1.5 --- ExperimentTest.cpp 5 May 2007 08:49:07 -0000 1.6 *************** *** 148,152 **** ap->set_execution_end(en); BOOST_CHECK( ap->get_execution_end() == en ); ! ExcitationFunctions::DIExcitationFunction<quantity::ElectricPotential,quantity::Time> ef; ap->set_exc_func(ef); BOOST_CHECK( ap->get_exc_func() == ef ); --- 148,152 ---- ap->set_execution_end(en); BOOST_CHECK( ap->get_execution_end() == en ); ! ExcitationFunctions::SDIExcitationFunction<quantity::ElectricPotential,quantity::Time,ExcitationFunctions::Segments::LinearSegment> ef; ap->set_exc_func(ef); BOOST_CHECK( ap->get_exc_func() == ef ); *************** *** 163,167 **** ip->set_induction_end(en); BOOST_CHECK( ip->get_induction_end() == en ); ! ExcitationFunctions::DIExcitationFunction<quantity::ElectricPotential,quantity::Time> ef; ip->set_exc_func(ef); BOOST_CHECK( ip->get_exc_func() == ef ); --- 163,167 ---- ip->set_induction_end(en); BOOST_CHECK( ip->get_induction_end() == en ); ! ExcitationFunctions::SDIExcitationFunction<quantity::ElectricPotential,quantity::Time,ExcitationFunctions::Segments::LinearSegment> ef; ip->set_exc_func(ef); BOOST_CHECK( ip->get_exc_func() == ef ); |
|
From: beeblbrox <bee...@us...> - 2007-05-05 08:48:10
|
Update of /cvsroot/echempp/Experiment/Experiment In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv28161 Added Files: TechniqueType.hpp Log Message: Initial version. --- NEW FILE: TechniqueType.hpp --- /*! \file TechniqueType.hpp \brief header file for technique types. TechniqueType.hpp is part of the Experiment package. */ /* Copyright (C) 2007, Dominik Brugger, Bernd Speiser This file is part of EChem++. EChem++ is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. EChem++ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ // $Id: TechniqueType.hpp,v 1.1 2007/05/05 08:48:06 beeblbrox Exp $ #ifndef __TECHNIQUE_TYPE_HPP__ #define __TECHNIQUE_TYPE_HPP__ namespace experiment { template<class Realism, class Dynamics, class I, class D, class R, template<class, class> class SegmentType> class TechniqueType { public: // static const std::string TSID; typedef Realism realism_type; typedef Dynamics dynamics_type; typedef I independent_type; typedef D dependent_type; typedef R result_type; typedef SegmentType<D,I> segment_type; }; // template<class Realism, // class Dynamics, // class I, // class D, // class R, // template<class, class> class SegmentType> // TechniqueType::TSID = "experiment::TechniqueType" + // TypeToName<Realism>() + TypeToName<Dynamics>() + // TypeToName<I>() + TypeToName<D>() + TypeToName<R>() + // TypeToName<SegmentType>(); } // end namespace experiment #endif |
|
From: beeblbrox <bee...@us...> - 2007-04-11 08:25:40
|
Update of /cvsroot/echempp/Experiment/Experiment In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv30627 Modified Files: Experiment.hpp Log Message: Added basic documentation of classes. Remove method for Compound. Index: Experiment.hpp =================================================================== RCS file: /cvsroot/echempp/Experiment/Experiment/Experiment.hpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Experiment.hpp 10 Apr 2007 09:17:24 -0000 1.3 --- Experiment.hpp 11 Apr 2007 08:25:35 -0000 1.4 *************** *** 33,37 **** { ! // Unary functor for deletion template<typename Obj> class functor_delete --- 33,37 ---- { ! //! Unary functor for deletion. template<typename Obj> class functor_delete *************** *** 46,61 **** }; namespace realism { ! struct Simulated{}; struct Real{}; struct Dual{}; } namespace dynamics { struct Dynamic{}; struct Static{}; } class ExperimentException { --- 46,74 ---- }; + //! Namespace for realism types. namespace realism { ! //! Type used to designate simulated experiments. ! struct Simulated{}; ! //! Type used to designate real experiments. struct Real{}; + //! Type used to designate dual experiments, e.g. one part real the other simulated. struct Dual{}; } + //! Namespace for dynamics types. namespace dynamics { + //! Type used to designate dynamic experiments. struct Dynamic{}; + //! Type used to designate static experiments. struct Static{}; } + //! Exception class for experiment module. + //! This exception is thrown for example, when violation of + //! Experiment container invariants occurs. + //! \sa Homogeneous + //! \sa Sequential + //! \sa Simultaneous class ExperimentException { *************** *** 71,74 **** --- 84,88 ---- }; + //! Base class for all experiments. class Experiment { *************** *** 79,82 **** --- 93,97 ---- virtual void perform() = 0; virtual void add(Experiment* e) = 0; + virtual void remove(const size_t idx) = 0; virtual const Loki::TypeInfo get_independent_type() const = 0; virtual const Loki::TypeInfo get_dependent_type() const = 0; *************** *** 102,105 **** --- 117,123 ---- }; + //! Base class for all atomic experiments. + //! Atomic experiments are used to represent self-contained + //! experiments that are not further divisible. template<class Realism, class Dynamics> *************** *** 126,129 **** --- 144,151 ---- throw ExperimentException("Adding to Atomic not possible!"); } + void remove(const size_t idx) + { + throw ExperimentException("Removing from Atomic not possible!"); + } private: friend class boost::serialization::access; *************** *** 135,138 **** --- 157,165 ---- }; + //! Class to represent Actions. + //! Actions are used to influence the experimental system + //! without collecting data. + //! \sa Induced + //! \sa Observation template<class Realism, class Dynamics, *************** *** 229,233 **** ExcitationFunctions::DIExcitationFunction<D,I> exc_func; }; ! template<class Realism, class Dynamics, --- 256,265 ---- ExcitationFunctions::DIExcitationFunction<D,I> exc_func; }; ! ! //! Class to represent induced experiments. ! //! Induced experiments influence the system like Action but ! //! also collect the result. ! //! \sa Action ! //! \sa Observation template<class Realism, class Dynamics, *************** *** 327,330 **** --- 359,368 ---- }; + //! Class to represent Observations. + //! Dynamic Observations collect information about the + //! relationship between independent and result variable. + //! Static Observations collect a single result. + //! \sa Action + //! \sa Induced template<class Realism, class Dynamics, *************** *** 457,460 **** --- 495,503 ---- }; + //! Base class for all composed experiments. + //! \sa Collection + //! \sa Homogeneous + //! \sa Sequential + //! \sa Simultaneous class Compound : public Experiment { *************** *** 474,477 **** --- 517,527 ---- elements.push_back(e); } + void remove(const size_t idx) + { + if(idx > elements.size()-1) + throw ExperimentException("Index out of range!"); + delete elements[idx]; + elements.erase(elements.begin()+idx); + } int num_elements() const { *************** *** 591,594 **** --- 641,650 ---- }; + //! Class for collection of experiments. + //! A collection of experiments, where no contraint on the + //! type of contained experiments is placed. + //! \sa Homogeneous + //! \sa Sequential + //! \sa Simultaneous class Collection : public Compound { *************** *** 606,609 **** --- 662,673 ---- }; + //! Class for homogeneous composition of experiments. + //! A homogeneous composition contains only experiments with + //! the same type (w.r.t independent, dependent, result, dynamics + //! and realism type). Mixtures of atomic and composed Experiments + //! are not allowed. + //! \sa Collection + //! \sa Sequential + //! \sa Simultaneous class Homogeneous : public Compound { *************** *** 647,650 **** --- 711,720 ---- }; + //! Class for sequential composition of experiments. + //! A sequential composition may contain experiments which are dynamic + //! and have the same type of independent variable. + //! \sa Collection + //! \sa Homogeneous + //! \sa Simultaneous class Sequential : public Compound { *************** *** 670,673 **** --- 740,749 ---- }; + //! Class for simultaneous composition of experiments. + //! A simultaneous composition may contain experiments which are dynamic and + //! have the same type and range of the independent variable. + //! \sa Collection + //! \sa Homogeneous + //! \sa Sequential class Simultaneous : public Compound { |
|
From: beeblbrox <bee...@us...> - 2007-04-11 08:24:35
|
Update of /cvsroot/echempp/Experiment/Experiment/test In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv30202/test Modified Files: ExperimentTest.cpp Log Message: Added test case for remove function of Compound. Index: ExperimentTest.cpp =================================================================== RCS file: /cvsroot/echempp/Experiment/Experiment/test/ExperimentTest.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ExperimentTest.cpp 10 Apr 2007 09:18:30 -0000 1.4 --- ExperimentTest.cpp 11 Apr 2007 08:24:32 -0000 1.5 *************** *** 442,445 **** --- 442,456 ---- } + void test_remove() + { + Collection col; + BOOST_REQUIRE_NO_THROW( col.add(new RealDynamicEPTAction()) ); + BOOST_REQUIRE_NO_THROW( col.add(new Homogeneous()) ); + BOOST_REQUIRE_NO_THROW( col.add(new RealDynamicEPTAction()) ); + BOOST_REQUIRE_NO_THROW( col.remove(1) ); + BOOST_REQUIRE_THROW( col.remove(2), ExperimentException ); + BOOST_CHECK( col.num_elements() == 2 ); + } + test_suite* init_unit_test_suite( int argc, char * argv[] ) { *************** *** 450,453 **** --- 461,465 ---- test->add( BOOST_TEST_CASE( &test_container_invariants ) ); test->add( BOOST_TEST_CASE( &test_serialization ) ); + test->add( BOOST_TEST_CASE( &test_remove ) ); // test->add( BOOST_TEST_CASE( &infinite_loop ), 0, /* timeout */ 2 ); return test; |
|
From: beeblbrox <bee...@us...> - 2007-04-10 09:18:34
|
Update of /cvsroot/echempp/Experiment/Experiment/test In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv5286/test Modified Files: ExperimentTest.cpp Log Message: Completed test cases for container invariants, serialization, basic creation/destruction and setters/getters. Index: ExperimentTest.cpp =================================================================== RCS file: /cvsroot/echempp/Experiment/Experiment/test/ExperimentTest.cpp,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ExperimentTest.cpp 7 Apr 2007 08:06:45 -0000 1.3 --- ExperimentTest.cpp 10 Apr 2007 09:18:30 -0000 1.4 *************** *** 4,7 **** --- 4,8 ---- #include <boost/test/unit_test.hpp> using namespace boost::unit_test; + #include <boost/archive/tmpdir.hpp> #include <boost/archive/text_oarchive.hpp> #include <boost/archive/text_iarchive.hpp> *************** *** 15,105 **** // Note: Compile and link with: // g++ -o ExperimentTest ExperimentTest.cpp -lboost_unit_test_framework - // TODO: Enter this in Makefile.am ! void test_creation_destruction() { ! Experiment *ep; ! ep = new MyAction(); ! delete ep; ! ep = new MyObservation(); ! delete ep; ! // ep = new Collection(); ! // delete ep; ! ep = new Homogeneous(); ! delete ep; ! // ep = new Sequential(); ! // delete ep; ! // ep = new Simultaneous(); ! // delete ep; } ! void test_serialization() { ! const Experiment *cep; { ! // Action serialization ! MyAction *act; ! act = new MyAction(); ! std::ofstream ofs_txt("/tmp/action.txt"); ! boost::archive::text_oarchive oa_txt(ofs_txt); ! std::ofstream ofs_xml("/tmp/action.xml"); ! boost::archive::xml_oarchive oa_xml(ofs_xml); ! const MyAction a; ! cep = act; ! // oa_txt << *cep; ! oa_txt << a; ! oa_xml << BOOST_SERIALIZATION_NVP(a); ! ! ofs_txt.close(); ! ofs_xml.close(); } ! // Homogeneous serialization ! Homogeneous hg; ! hg.add(new experiment::MyAction()); ! try ! { ! hg.add(new experiment::MyObservation()); ! } ! catch(ExperimentException& e) ! { ! std::cout << e.what() << std::endl; ! } ! hg.add(new experiment::MyAction()); ! ! std::ofstream ofs_txt("/tmp/exp.txt"); ! boost::archive::text_oarchive oa_txt(ofs_txt); ! std::ofstream ofs_xml("/tmp/exp.xml"); ! boost::archive::xml_oarchive oa_xml(ofs_xml); ! //cep = hg; ! const Homogeneous& hgc = hg; ! oa_txt << hgc; ! oa_xml << BOOST_SERIALIZATION_NVP(hgc); ! // oa_xml << BOOST_SERIALIZATION_NVP(*cep); ofs_txt.close(); ! ofs_xml.close(); ! std::ifstream ifs_txt("/tmp/exp.txt"); boost::archive::text_iarchive ia_txt(ifs_txt); ! Homogeneous hg2; ! ia_txt >> hg2; ifs_txt.close(); { ! const Homogeneous& hgc = hg2; ! std::ofstream ofs_xml("/tmp/exp2.xml"); ! boost::archive::xml_oarchive oa_xml(ofs_xml); ! oa_xml << BOOST_SERIALIZATION_NVP(hgc); ! ofs_xml.close(); } } --- 16,443 ---- // Note: Compile and link with: // g++ -o ExperimentTest ExperimentTest.cpp -lboost_unit_test_framework ! Experiment* create_homogeneous() { ! Experiment* ep = new Homogeneous(); ! Experiment* ep2 = new Homogeneous(); ! BOOST_REQUIRE_NO_THROW( ep2->add( new RealDynamicEPTAction() ) ); ! BOOST_REQUIRE_NO_THROW( ep2->add( new RealDynamicEPTAction() ) ); ! Experiment* ep3 = new Homogeneous(); ! BOOST_REQUIRE_NO_THROW( ep3->add( new RealDynamicEPTAction() ) ); ! BOOST_REQUIRE_NO_THROW( ep3->add( new RealDynamicEPTAction() ) ); ! BOOST_REQUIRE_NO_THROW( ep->add( ep2 ) ); ! BOOST_REQUIRE_NO_THROW( ep->add( ep3 ) ); ! return ep; } + Experiment* create_sequential() + { + Experiment* ep = new Sequential(); + BOOST_REQUIRE_NO_THROW( ep->add( new RealDynamicEPTAction() ) ); + BOOST_REQUIRE_NO_THROW( ep->add( new RealDynamicTEPObservation() ) ); + Experiment* ep2 = new Sequential(); + BOOST_REQUIRE_NO_THROW( ep2->add( new RealDynamicEPTAction() ) ); + ep->add( ep2 ); + return ep; + } + Experiment* create_simultaneous() + { + Experiment* ep = new Simultaneous(); + // Construct observation1 lasting 5s + RealDynamicTEPObservation* o1 = + new RealDynamicTEPObservation(quantity::Time(5.0),quantity::Time(10.0)); + // Construct observation2 lasting 5s + RealDynamicTEPObservation* o2 = + new RealDynamicTEPObservation(quantity::Time(5.0),quantity::Time(10.0)); + BOOST_REQUIRE_NO_THROW( ep->add( o1 ) ); + BOOST_REQUIRE_NO_THROW( ep->add( o2 ) ); + return ep; + } ! Experiment* create_collection() { ! Experiment* ep = new Collection(); ! ep->add( new RealDynamicEPTAction() ); ! ep->add( new RealStaticEPTAction() ); ! ep->add( new Homogeneous() ); ! ep->add( new Sequential() ); ! ep->add( new Simultaneous() ); ! Experiment* ep2 = new Sequential(); ! ep2->add( new RealDynamicEPTAction() ); ! ep2->add( new RealDynamicTEPObservation() ); ! ep->add( ep2 ); ! return ep; ! } + void test_creation_destruction() + { + Experiment *ep = NULL; + + // 1) Action { ! RealDynamicEPTAction a; ! ep = new RealDynamicEPTAction(); ! BOOST_CHECK( ep != NULL ); ! delete ep; ! } ! // 2) Induced ! { ! RealDynamicEPTInduced i; ! ep = new RealDynamicEPTInduced(); ! BOOST_CHECK( ep != NULL ); ! delete ep; ! } ! // 3) Observation ! { ! RealDynamicTEPObservation o; ! ep = new RealDynamicTEPObservation(); ! BOOST_CHECK( ep != NULL ); ! delete ep; ! } ! // 4) Homogeneous ! { ! Homogeneous hg; ! ep = create_homogeneous(); ! BOOST_CHECK( ep != NULL ); ! delete ep; ! } ! // 5) Sequential ! { ! Sequential seq; ! ep = create_sequential(); ! BOOST_CHECK(ep != NULL ); ! delete ep; ! } ! // 6) Simultaneous ! { ! Simultaneous sim; ! ep = create_simultaneous(); ! BOOST_CHECK(ep != NULL ); ! delete ep; ! } ! // 7) Collection ! { ! Collection col; ! ep = create_collection(); ! BOOST_CHECK(ep != NULL ); ! delete ep; ! } ! } ! // Test get_X() and set_X() for all data ! // members X of Experiment classes ! void test_getters_setters() ! { ! // Experiment::get_title(), Experiment::set_title() ! { ! Experiment *ep = new RealDynamicEPTAction("title 1"); ! BOOST_CHECK( ep->get_title() == "title 1" ); ! ep->set_title("title 2"); ! BOOST_CHECK( ep->get_title() == "title 2" ); ! } ! // Action::get_execution_x(), Action::set_execution_x() ! // Action::get_exc_func(), Action::set_exc_func() ! { ! RealDynamicEPTAction *ap = new RealDynamicEPTAction(); ! boost::posix_time::ptime st(boost::posix_time::second_clock::universal_time()); ! ap->set_execution_start(st); ! BOOST_CHECK( ap->get_execution_start() == st ); ! boost::posix_time::ptime en = st + (boost::posix_time::minutes(5)); ! ap->set_execution_end(en); ! BOOST_CHECK( ap->get_execution_end() == en ); ! ExcitationFunctions::DIExcitationFunction<quantity::ElectricPotential,quantity::Time> ef; ! ap->set_exc_func(ef); ! BOOST_CHECK( ap->get_exc_func() == ef ); ! } ! // Induced::get_induction_x(), Induced::set_induction_x() ! // Induced::get_exc_func(), Induced::set_exc_func() ! { ! RealDynamicEPTInduced *ip = new RealDynamicEPTInduced(); ! boost::posix_time::ptime st(boost::posix_time::second_clock::universal_time()); ! ip->set_induction_start(st); ! BOOST_CHECK( ip->get_induction_start() == st ); ! boost::posix_time::ptime en = st + (boost::posix_time::minutes(7)); ! ip->set_induction_end(en); ! BOOST_CHECK( ip->get_induction_end() == en ); ! ExcitationFunctions::DIExcitationFunction<quantity::ElectricPotential,quantity::Time> ef; ! ip->set_exc_func(ef); ! BOOST_CHECK( ip->get_exc_func() == ef ); } ! // Observation::get_recording_x(), Observation::set_recording_x() ! // Observation::get_x(), Observation::set_x() ! { ! RealDynamicTEPObservation* op = new RealDynamicTEPObservation(); ! boost::posix_time::ptime st(boost::posix_time::second_clock::universal_time()); ! boost::posix_time::ptime en = st + (boost::posix_time::minutes(10)); ! op->set_recording_start(st); ! BOOST_CHECK( op->get_recording_start() == st ); ! op->set_recording_end(en); ! BOOST_CHECK( op->get_recording_end() == en ); ! op->set_start(quantity::Time(1)); ! BOOST_CHECK( op->get_start() == quantity::Time(1) ); ! op->set_end(quantity::Time(2)); ! BOOST_CHECK( op->get_end() == quantity::Time(2) ); ! } ! } ! // Tests all the invariants which are imposed on ! // elements of containers Homogeneous, Sequential and Simultaneous ! void test_container_invariants() ! { ! // 1) Homogeneous ! { ! Homogeneous hg; ! BOOST_REQUIRE_NO_THROW( hg.add(new RealDynamicEPTAction()) ); ! BOOST_REQUIRE_THROW( hg.add(new RealDynamicTEPObservation()), ! ExperimentException ); ! BOOST_REQUIRE_THROW( hg.add(new RealDynamicEPTInduced()), ! ExperimentException ); ! BOOST_REQUIRE_THROW( hg.add(new Homogeneous()), ! ExperimentException ); ! BOOST_REQUIRE_THROW( hg.add(new Sequential()), ! ExperimentException ); ! BOOST_REQUIRE_THROW( hg.add(new Simultaneous()), ! ExperimentException ); ! BOOST_REQUIRE_THROW( hg.add(new Collection()), ! ExperimentException ); ! BOOST_REQUIRE_THROW( hg.add(new SimulatedDynamicEPTAction()), ! ExperimentException ); ! BOOST_REQUIRE_THROW( hg.add(new DualDynamicEPTAction()), ! ExperimentException ); ! BOOST_REQUIRE_THROW( hg.add(new RealStaticEPTAction()), ! ExperimentException ); ! BOOST_REQUIRE_THROW( hg.add(new RealDynamicECTAction()), ! ExperimentException ); ! BOOST_REQUIRE_THROW( hg.add(new RealDynamicEPTempAction()), ! ExperimentException ); ! Homogeneous hg2 = Homogeneous(); ! Homogeneous *hp = new Homogeneous(); ! BOOST_REQUIRE_NO_THROW( hp->add(new RealDynamicEPTAction()) ); ! BOOST_REQUIRE_NO_THROW( hg2.add(hp) ); ! Sequential *sp = new Sequential(); ! BOOST_REQUIRE_NO_THROW( sp->add(new RealDynamicEPTAction()) ); ! BOOST_REQUIRE_NO_THROW( hg2.add(sp) ); ! Simultaneous *sip = new Simultaneous(); ! BOOST_REQUIRE_NO_THROW( sip->add(new RealDynamicEPTAction()) ); ! BOOST_REQUIRE_NO_THROW( hg2.add(sip) ); ! Collection *cp = new Collection(); ! BOOST_REQUIRE_NO_THROW( cp->add(new RealDynamicEPTAction()) ); ! BOOST_REQUIRE_NO_THROW( hg2.add(cp) ); ! Homogeneous *hp2 = new Homogeneous(); ! BOOST_REQUIRE_NO_THROW( hp2->add(new RealDynamicECTAction()) ); ! BOOST_REQUIRE_THROW( hg.add(hp2), ExperimentException ); ! Sequential *sp2 = new Sequential(); ! BOOST_REQUIRE_NO_THROW( sp2->add(new RealDynamicECTAction()) ); ! BOOST_REQUIRE_THROW( hg.add(sp2), ExperimentException ); ! Simultaneous *sip2 = new Simultaneous(); ! BOOST_REQUIRE_NO_THROW( sip2->add(new RealDynamicECTAction()) ); ! BOOST_REQUIRE_THROW( hg.add(sip2), ExperimentException ); ! Collection *cp2 = new Collection(); ! BOOST_REQUIRE_NO_THROW( cp2->add(new RealDynamicECTAction()) ); ! BOOST_REQUIRE_THROW( hg.add(cp2), ExperimentException ); ! } + // 2) Sequential + { + Sequential seq; + BOOST_REQUIRE_NO_THROW( seq.add(new RealDynamicEPTAction()) ); + BOOST_REQUIRE_NO_THROW( seq.add(new SimulatedDynamicEPTAction()) ); + BOOST_REQUIRE_NO_THROW( seq.add(new DualDynamicEPTAction()) ); + BOOST_REQUIRE_NO_THROW( seq.add(new RealDynamicTEPObservation()) ); + BOOST_REQUIRE_NO_THROW( seq.add(new RealDynamicEPTInduced()) ); + BOOST_REQUIRE_NO_THROW( seq.add(new RealDynamicECTAction()) ); + BOOST_REQUIRE_NO_THROW( seq.add(new RealDynamicTEPObservation()) ); + BOOST_REQUIRE_THROW( seq.add(new RealStaticEPTAction()), ExperimentException ); + BOOST_REQUIRE_THROW( seq.add(new RealDynamicEPTempAction()), + ExperimentException ); + Homogeneous *hp = new Homogeneous(); + BOOST_REQUIRE_NO_THROW( hp->add(new RealDynamicEPTAction()) ); + BOOST_REQUIRE_NO_THROW( hp->add(new RealDynamicEPTAction()) ); + BOOST_REQUIRE_NO_THROW( seq.add(hp) ); + Sequential *sp = new Sequential(); + BOOST_REQUIRE_NO_THROW( sp->add(new SimulatedDynamicEPTAction()) ); + BOOST_REQUIRE_NO_THROW( seq.add(sp) ); + Simultaneous *sip = new Simultaneous(); + BOOST_REQUIRE_NO_THROW( sip->add(new SimulatedDynamicEPTAction()) ); + BOOST_REQUIRE_NO_THROW( seq.add(sip) ); + Collection *cp = new Collection(); + BOOST_REQUIRE_NO_THROW( cp->add(new SimulatedDynamicEPTAction()) ); + BOOST_REQUIRE_NO_THROW( seq.add(cp) ); + Homogeneous *hp2 = new Homogeneous(); + BOOST_REQUIRE_NO_THROW( hp2->add(new RealStaticEPTAction()) ); + BOOST_REQUIRE_THROW( seq.add(hp2), ExperimentException ); + Sequential *sp2 = new Sequential(); + BOOST_REQUIRE_NO_THROW( sp2->add(new RealDynamicEPTempAction()) ); + BOOST_REQUIRE_THROW( seq.add(sp2), ExperimentException ); + Simultaneous *sip2 = new Simultaneous(); + BOOST_REQUIRE_NO_THROW( sip2->add(new RealDynamicEPTempAction()) ); + BOOST_REQUIRE_THROW( seq.add(sip2), ExperimentException ); + Collection *cp2 = new Collection(); + BOOST_REQUIRE_NO_THROW( cp2->add(new RealStaticEPTAction()) ); + BOOST_REQUIRE_THROW( seq.add(cp2), ExperimentException ); + } + + // 3) Simultaneous + { + Simultaneous sim; + BOOST_REQUIRE_NO_THROW( sim.add(new RealDynamicTEPObservation(quantity::Time(5.0), quantity::Time(10.0))) ); + BOOST_REQUIRE_NO_THROW( sim.add(new RealDynamicTEPObservation(quantity::Time(5.0), quantity::Time(10.0))) ); + BOOST_REQUIRE_THROW( sim.add(new RealDynamicTEPObservation(quantity::Time(5.0), quantity::Time(20.0))), ExperimentException ); + Simultaneous sim2; + BOOST_REQUIRE_THROW( sim2.add(new RealStaticEPTAction()), ExperimentException ); + BOOST_REQUIRE_NO_THROW( sim2.add(new RealDynamicEPTAction()) ); + BOOST_REQUIRE_THROW( sim2.add(new RealDynamicEPTempAction()), ExperimentException ); + Simultaneous sim3; + Sequential *seq1 = new Sequential(); + BOOST_REQUIRE_NO_THROW( seq1->add(new RealDynamicTEPObservation(quantity::Time(1.0), quantity::Time(5.0))) ); + BOOST_REQUIRE_NO_THROW( seq1->add(new RealDynamicTEPObservation(quantity::Time(5.0), quantity::Time(10.0))) ); + Sequential *seq2 = new Sequential(); + BOOST_REQUIRE_NO_THROW( seq2->add(new RealDynamicTEPObservation(quantity::Time(1.0), quantity::Time(5.0))) ); + BOOST_REQUIRE_NO_THROW( seq2->add(new RealDynamicTEPObservation(quantity::Time(5.0), quantity::Time(10.0))) ); + Sequential *seq3 = new Sequential(); + BOOST_REQUIRE_NO_THROW( seq3->add(new RealDynamicTEPObservation(quantity::Time(1.0), quantity::Time(5.0))) ); + BOOST_REQUIRE_NO_THROW( seq3->add(new RealDynamicTEPObservation(quantity::Time(5.0), quantity::Time(11.0))) ); + BOOST_REQUIRE_NO_THROW( sim3.add(seq1) ); + BOOST_REQUIRE_NO_THROW( sim3.add(seq2) ); + BOOST_REQUIRE_THROW( sim3.add(seq3), ExperimentException ); + } + + // 4) Collection + { + Collection col; + BOOST_REQUIRE_NO_THROW( col.add(new RealDynamicEPTAction()) ); + BOOST_REQUIRE_NO_THROW( col.add(new RealDynamicTEPObservation()) ); + BOOST_REQUIRE_NO_THROW( col.add(new RealDynamicEPTInduced()) ); + BOOST_REQUIRE_NO_THROW( col.add(new SimulatedDynamicEPTAction()) ); + BOOST_REQUIRE_NO_THROW( col.add(new DualDynamicEPTAction()) ); + BOOST_REQUIRE_NO_THROW( col.add(new RealStaticEPTAction()) ); + BOOST_REQUIRE_NO_THROW( col.add(new SimulatedStaticEPTAction()) ); + BOOST_REQUIRE_NO_THROW( col.add(new DualStaticEPTAction()) ); + BOOST_REQUIRE_NO_THROW( col.add(new Homogeneous()) ); + BOOST_REQUIRE_NO_THROW( col.add(new Sequential()) ); + BOOST_REQUIRE_NO_THROW( col.add(new Simultaneous()) ); + BOOST_REQUIRE_NO_THROW( col.add(new Collection()) ); + } + + } + + void save_txt(const char* filename, Experiment* ep) + { + std::ofstream ofs_txt(filename); + boost::archive::text_oarchive oa_txt(ofs_txt); + oa_txt << BOOST_SERIALIZATION_NVP(ep); ofs_txt.close(); ! } ! Experiment* load_txt(const char* filename) ! { ! Experiment* ep = NULL; ! std::ifstream ifs_txt(filename); boost::archive::text_iarchive ia_txt(ifs_txt); ! ia_txt >> BOOST_SERIALIZATION_NVP(ep); ifs_txt.close(); + return ep; + } + + void save_xml(const char* filename, Experiment* ep) + { + std::ofstream ofs_xml(filename); + boost::archive::xml_oarchive oa_xml(ofs_xml); + oa_xml << BOOST_SERIALIZATION_NVP(ep); + ofs_xml.close(); + } + + Experiment* load_xml(const char* filename) + { + Experiment* ep = NULL; + std::ifstream ifs_xml(filename); + boost::archive::xml_iarchive ia_xml(ifs_xml); + ia_xml >> BOOST_SERIALIZATION_NVP(ep); + ifs_xml.close(); + return ep; + } + void check_load_save(Experiment* ep, std::string filename) + { + Experiment* ep2 = NULL; + std::string fn1 = filename + ".xml"; + save_xml(fn1.c_str(), ep); + ep2 = load_xml(fn1.c_str()); + BOOST_CHECK( ep->equal(ep2) ); + delete ep2; + std::string fn2 = filename + ".txt"; + save_txt(fn2.c_str(), ep); + ep2 = load_txt(fn2.c_str()); + BOOST_CHECK( ep->equal(ep2) ); + delete ep2; + } + + // Test serialization of all Experiment Objects + void test_serialization() + { + Experiment *ep = NULL; + std::string dirname = "/tmp/"; + + // Polymorphic Action serialization { ! ep = new RealDynamicEPTAction(); ! std::string filename = dirname + "action"; ! check_load_save(ep, filename); ! delete ep; ! } ! ! // Polymorphic Induced serialization ! { ! ep = new RealDynamicEPTInduced(); ! std::string filename = dirname + "induced"; ! check_load_save(ep, filename); ! delete ep; ! } ! ! // Polymorphic Observation serialization ! { ! ep = new RealDynamicTEPObservation(); ! std::string filename = dirname + "observation"; ! check_load_save(ep, filename); ! delete ep; ! } ! ! // Polymorphic Homogeneous serialization ! { ! ep = create_homogeneous(); ! std::string filename = dirname + "homogeneous"; ! check_load_save(ep, filename); ! delete ep; } + + // Polymorphic Sequential serialization + { + ep = create_sequential(); + std::string filename = dirname + "sequential"; + check_load_save(ep, filename); + delete ep; + } + + // Polymorphic Simultaneous serialization + { + ep = create_simultaneous(); + std::string filename = dirname + "simultaneous"; + check_load_save(ep, filename); + delete ep; + } + + // Polymorphic Collection serialization + { + ep = create_collection(); + std::string filename = dirname + "collection"; + check_load_save(ep, filename); + delete ep; + } + } *************** *** 109,112 **** --- 447,452 ---- test->add( BOOST_TEST_CASE( &test_creation_destruction ) ); + test->add( BOOST_TEST_CASE( &test_getters_setters ) ); + test->add( BOOST_TEST_CASE( &test_container_invariants ) ); test->add( BOOST_TEST_CASE( &test_serialization ) ); // test->add( BOOST_TEST_CASE( &infinite_loop ), 0, /* timeout */ 2 ); |
|
From: beeblbrox <bee...@us...> - 2007-04-10 09:17:29
|
Update of /cvsroot/echempp/Experiment/Experiment In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv4876 Modified Files: Experiment.hpp Log Message: Implemented container invariants + setters/getters for member data. Still needs documentation + navigation function for composite. Index: Experiment.hpp =================================================================== RCS file: /cvsroot/echempp/Experiment/Experiment/Experiment.hpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Experiment.hpp 6 Apr 2007 17:17:05 -0000 1.2 --- Experiment.hpp 10 Apr 2007 09:17:24 -0000 1.3 *************** *** 15,19 **** // Boost includes #include <boost/serialization/serialization.hpp> - #include <boost/serialization/export.hpp> #include <boost/serialization/base_object.hpp> #include <boost/serialization/is_abstract.hpp> --- 15,18 ---- *************** *** 21,24 **** --- 20,24 ---- #include <boost/serialization/utility.hpp> #include <boost/serialization/vector.hpp> + #include <boost/serialization/export.hpp> #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/posix_time/time_serialize.hpp> *************** *** 45,60 **** } }; - // Unary functor to call perform - template<typename Obj> - class functor_perform - { - public: - typedef Obj argument_type; - typedef void result_type; - result_type operator()(argument_type obj) - { - obj->perform(); - } - }; namespace realism --- 45,48 ---- *************** *** 90,93 **** --- 78,82 ---- virtual ~Experiment() {} virtual void perform() = 0; + virtual void add(Experiment* e) = 0; virtual const Loki::TypeInfo get_independent_type() const = 0; virtual const Loki::TypeInfo get_dependent_type() const = 0; *************** *** 95,100 **** --- 84,95 ---- virtual const Loki::TypeInfo get_realism_type() const = 0; virtual const Loki::TypeInfo get_dynamics_type() const = 0; + virtual const bool has_matching_independent_range(Experiment* e) const = 0; + virtual const bool is_compound() const = 0; const std::string& get_title() const { return title_; } void set_title(const std::string& title) { title_ = title; } + virtual const bool equal(Experiment* e) const + { + return title_ == e->get_title(); + } private: std::string title_; *************** *** 112,116 **** { public: ! Atomic() {}; virtual ~Atomic() {}; // RTTI --- 107,112 ---- { public: ! Atomic() {} ! Atomic(const std::string title) : Experiment(title) {} virtual ~Atomic() {}; // RTTI *************** *** 125,128 **** --- 121,129 ---- return info; } + const bool is_compound() const { return false; } + void add(Experiment* e) + { + throw ExperimentException("Adding to Atomic not possible!"); + } private: friend class boost::serialization::access; *************** *** 136,147 **** template<class Realism, class Dynamics, ! class I, /* type of independent variable */ ! class D> /* type of dependent variable */ class Action : public Atomic<Realism, Dynamics> { public: ! Action() {}; ! virtual ~Action() {}; ! virtual void perform() {}; // RTTI const Loki::TypeInfo get_independent_type() const --- 137,150 ---- template<class Realism, class Dynamics, ! class D, /* type of dependent variable */ ! class I> /* type of independent variable */ class Action : public Atomic<Realism, Dynamics> { public: ! typedef Atomic<Realism, Dynamics> AtomicBase; ! Action() {} ! Action(const std::string title) : AtomicBase(title) {} ! virtual ~Action() {} ! virtual void perform() {} // RTTI const Loki::TypeInfo get_independent_type() const *************** *** 160,165 **** return info; } private: - typedef Atomic<Realism, Dynamics> AtomicBase; friend class boost::serialization::access; template<class Archive> --- 163,219 ---- return info; } + const boost::posix_time::ptime get_execution_start() const + { + return execution_start; + } + void set_execution_start(const boost::posix_time::ptime& pt) + { + execution_start = pt; + } + const boost::posix_time::ptime get_execution_end() const + { + return execution_end; + } + void set_execution_end(const boost::posix_time::ptime& pt) + { + execution_end = pt; + } + const ExcitationFunctions::DIExcitationFunction<D,I> get_exc_func() const + { + return exc_func; + } + void set_exc_func(const ExcitationFunctions::DIExcitationFunction<D,I>& ef) + { + exc_func = ef; + } + const bool has_matching_independent_range(Experiment* e) const + { + Action<Realism, Dynamics, D, I> *a = + dynamic_cast<Action<Realism, Dynamics, D, I> *>(e); + if(a != 0) + { + std::vector<I> inits1 = exc_func.inits(); + std::vector<I> ends1 = exc_func.ends(); + std::vector<I> inits2 = a->exc_func.inits(); + std::vector<I> ends2 = a->exc_func.ends(); + if(inits1.size() > 0 && inits2.size() > 0 && + ends1.size() > 0 && ends2.size() > 0) + return inits1[0] == inits2[0] + && ends1[ends1.size()-1] == ends2[ends2.size()-1]; + } + return false; + } + virtual const bool equal(Experiment* e) const + { + Action<Realism, Dynamics, D, I>* a + = dynamic_cast<Action<Realism, Dynamics, D, I>* >(e); + return a != 0 + && execution_start == a->execution_start + && execution_end == a->execution_end + && exc_func == a->exc_func + /* TODO: Check equality of other fields */ + && Atomic<Realism, Dynamics>::equal(e); + } private: friend class boost::serialization::access; template<class Archive> *************** *** 173,183 **** boost::posix_time::ptime execution_start; boost::posix_time::ptime execution_end; ! ExcitationFunctions::DIExcitationFunction<I,D> exc_func; }; template<class Realism, class Dynamics, - class I, /* type of independent variable */ class D, /* type of dependent variable */ class R> /* type of result variable */ class Induced : public Atomic<Realism, Dynamics> --- 227,237 ---- boost::posix_time::ptime execution_start; boost::posix_time::ptime execution_end; ! ExcitationFunctions::DIExcitationFunction<D,I> exc_func; }; template<class Realism, class Dynamics, class D, /* type of dependent variable */ + class I, /* type of independent variable */ class R> /* type of result variable */ class Induced : public Atomic<Realism, Dynamics> *************** *** 185,189 **** public: Induced() {}; ! virtual ~Induced() {}; virtual void perform() {}; // RTTI --- 239,243 ---- public: Induced() {}; ! virtual ~Induced() { std::cout << "Called ~Induced" << std::endl; }; virtual void perform() {}; // RTTI *************** *** 203,206 **** --- 257,312 ---- return info; } + const bool has_matching_independent_range(Experiment* e) const + { + Induced<Realism, Dynamics, D, I, R> *i = + dynamic_cast<Induced<Realism, Dynamics, D, I, R> *>(e); + if(i != 0) + { + std::vector<I> inits1 = exc_func.inits(); + std::vector<I> ends1 = exc_func.ends(); + std::vector<I> inits2 = i->exc_func.inits(); + std::vector<I> ends2 = i->exc_func.ends(); + if(inits1.size() > 0 && inits2.size() > 0 && + ends1.size() > 0 && ends2.size() > 0) + return inits1[0] == inits2[0] + && ends1[ends1.size()-1] == ends2[ends2.size()-1]; + } + return false; + } + virtual const bool equal(Experiment* e) const + { + Induced<Realism, Dynamics, D, I, R> *i = + dynamic_cast<Induced<Realism, Dynamics, D, I, R>* >(e); + return i != 0 + && induction_start == i->induction_start + && induction_end == i->induction_end + && exc_func == i->exc_func + /* TODO: Check equality of other fields */ + && Atomic<Realism, Dynamics>::equal(e); + } + const boost::posix_time::ptime get_induction_start() const + { + return induction_start; + } + void set_induction_start(const boost::posix_time::ptime& pt) + { + induction_start = pt; + } + const boost::posix_time::ptime get_induction_end() const + { + return induction_end; + } + void set_induction_end(const boost::posix_time::ptime& pt) + { + induction_end = pt; + } + const ExcitationFunctions::DIExcitationFunction<D,I> get_exc_func() const + { + return exc_func; + } + void set_exc_func(const ExcitationFunctions::DIExcitationFunction<D,I>& ef) + { + exc_func = ef; + } private: typedef Atomic<Realism, Dynamics> AtomicBase; *************** *** 216,220 **** boost::posix_time::ptime induction_start; boost::posix_time::ptime induction_end; ! ExcitationFunctions::DIExcitationFunction<I,D> exc_func; // TODO: MeasurementData ? R result; --- 322,326 ---- boost::posix_time::ptime induction_start; boost::posix_time::ptime induction_end; ! ExcitationFunctions::DIExcitationFunction<D,I> exc_func; // TODO: MeasurementData ? R result; *************** *** 238,242 **** public: Observation() {}; ! virtual ~Observation() {}; virtual void perform() {}; // RTTI --- 344,350 ---- public: Observation() {}; ! Observation(const I start, const I end) ! : start_(start), end_(end) {}; ! virtual ~Observation() { std::cout << "Called ~Observation" << std::endl; }; virtual void perform() {}; // RTTI *************** *** 256,259 **** --- 364,397 ---- return info; } + const bool has_matching_independent_range(Experiment* e) const + { + Observation<Realism, dynamics::Dynamic, I, R> *o = + dynamic_cast<Observation<Realism, dynamics::Dynamic, I, R> *>(e); + if(o != 0) + { + return start_ == o->get_start() && end_ == o->get_end(); + } + return false; + } + const boost::posix_time::ptime get_recording_start() const + { + return recording_start_; + } + void set_recording_start(const boost::posix_time::ptime& pt) + { + recording_start_ = pt; + } + const boost::posix_time::ptime get_recording_end() const + { + return recording_end_; + } + void set_recording_end(const boost::posix_time::ptime& pt) + { + recording_end_ = pt; + } + const I get_start() const { return start_; } + void set_start(const I start) { start_ = start; } + const I get_end() const { return end_; } + void set_end(const I end) { end_ = end; } private: typedef Atomic<Realism, dynamics::Dynamic> AtomicBase; *************** *** 263,271 **** { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(AtomicBase) ! & BOOST_SERIALIZATION_NVP(recording_start) ! & BOOST_SERIALIZATION_NVP(recording_end); } ! boost::posix_time::ptime recording_start; ! boost::posix_time::ptime recording_end; // TODO: insert Conditions, StateData }; --- 401,413 ---- { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(AtomicBase) ! & BOOST_SERIALIZATION_NVP(recording_start_) ! & BOOST_SERIALIZATION_NVP(recording_end_); ! // & BOOST_SERIALIZATION_NVP(start_) ! // & BOOST_SERIALIZATION_NVP(end_); } ! boost::posix_time::ptime recording_start_; ! boost::posix_time::ptime recording_end_; ! I start_; ! I end_; // TODO: insert Conditions, StateData }; *************** *** 278,282 **** public: Observation() {}; ! virtual ~Observation() {}; virtual void perform() {}; // RTTI --- 420,424 ---- public: Observation() {}; ! virtual ~Observation() { std::cout << "Called ~Observation" << std::endl; }; virtual void perform() {}; // RTTI *************** *** 296,299 **** --- 438,445 ---- return info; } + const bool has_matching_independent_range(Experiment* e) const + { + return false; + } private: typedef Atomic<Realism, dynamics::Static> AtomicBase; *************** *** 317,332 **** { std::for_each(elements.begin(), elements.end(), ! functor_delete<Experiment* >() ); } virtual void perform() { std::for_each(elements.begin(), elements.end(), ! functor_perform<Experiment* >() ); } virtual void add(Experiment* e) { - std::cout << "Compound::add called!" << std::endl; elements.push_back(e); } bool empty() const { --- 463,481 ---- { std::for_each(elements.begin(), elements.end(), ! functor_delete<Experiment* >() ); } virtual void perform() { std::for_each(elements.begin(), elements.end(), ! std::mem_fun(&Experiment::perform)); } virtual void add(Experiment* e) { elements.push_back(e); } + int num_elements() const + { + return elements.size(); + } bool empty() const { *************** *** 338,341 **** --- 487,494 ---- return elements.begin(); } + const_iterator end() const + { + return elements.end(); + } // RTTI const Loki::TypeInfo get_realism_type() const *************** *** 394,397 **** --- 547,583 ---- return ep->get_result_type(); } + const bool is_compound() const { return true; } + const bool has_matching_independent_range(Experiment* e) const + { + Compound* cp = dynamic_cast<Compound*>(e); + if(cp != 0) + { + if(num_elements() != cp->num_elements()) + return false; + const_iterator i = begin(); + const_iterator j = cp->begin(); + for(; i < end() && j < cp->end(); ++i, ++j) + if(!(*i)->has_matching_independent_range(*j)) + return false; + return true; + } + return false; + } + const bool equal(Experiment* e) const + { + Compound* cp = dynamic_cast<Compound*>(e); + if(cp != 0) + { + if(num_elements() != cp->num_elements()) + return false; + const_iterator i = begin(); + const_iterator j = cp->begin(); + for(; i < end() && j < cp->end(); ++i, ++j) + if(!(*i)->equal(*j)) + return false; + return Experiment::equal(e); + } + return false; + } private: friend class boost::serialization::access; *************** *** 399,403 **** void serialize(Archive & ar, const unsigned int version) { - std::cout << "Compound::serialize called!" << std::endl; ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Experiment) & BOOST_SERIALIZATION_NVP(elements); --- 585,588 ---- *************** *** 425,438 **** public: virtual ~Homogeneous() {}; ! virtual void add(Experiment* e) { - std::cout << "Homogeneous::add called!" << std::endl; if(Compound::empty()) return Compound::add(e); if(get_realism_type() != e->get_realism_type()) throw ExperimentException("Cannot add element because realism type does not match!"); if(get_dynamics_type() != e->get_dynamics_type()) throw ExperimentException("Cannot add element because dynamics type does not match!"); ! if(get_independent_type() != e->get_independent_type()) throw ExperimentException("Cannot add element because types of independent variable are not equal!"); if(get_dependent_type() != e->get_dependent_type()) --- 610,634 ---- public: virtual ~Homogeneous() {}; ! void add(Experiment* e) { if(Compound::empty()) return Compound::add(e); + Experiment *ep = *Compound::begin(); + if(e->is_compound() && !ep->is_compound()) + throw ExperimentException("Cannot add element of Atomic type to Homogeneous containing Compounds!"); + if(!e->is_compound() && ep->is_compound()) + throw ExperimentException("Cannot add element of Compound type to Homogeneous containing Atomics!"); + if(e->is_compound()) + { + Compound* cp1 = dynamic_cast<Compound*>(e); + Compound* cp2 = dynamic_cast<Compound*>(ep); + if(cp1->num_elements() != cp2->num_elements()) + throw ExperimentException("Cannot add element because number of elements in Compound differ!"); + } if(get_realism_type() != e->get_realism_type()) throw ExperimentException("Cannot add element because realism type does not match!"); if(get_dynamics_type() != e->get_dynamics_type()) throw ExperimentException("Cannot add element because dynamics type does not match!"); ! if(get_independent_type() != e->get_independent_type()) throw ExperimentException("Cannot add element because types of independent variable are not equal!"); if(get_dependent_type() != e->get_dependent_type()) *************** *** 447,451 **** void serialize(Archive & ar, const unsigned int version) { - std::cout << "Homogeneous::serialize called!" << std::endl; ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Compound); } --- 643,646 ---- *************** *** 456,459 **** --- 651,664 ---- public: virtual ~Sequential() {}; + void add(Experiment* e) + { + if(e->get_dynamics_type() == Loki::TypeInfo(typeid(dynamics::Static))) + throw ExperimentException("Cannot add static elements to Sequential!"); + if(Compound::empty()) + return Compound::add(e); + if(get_independent_type() != e->get_independent_type()) + throw ExperimentException("Cannot add element because types of independent variable are not equal!"); + return Compound::add(e); + } private: friend class boost::serialization::access; *************** *** 469,472 **** --- 674,690 ---- public: virtual ~Simultaneous() {}; + void add(Experiment* e) + { + if(e->get_dynamics_type() == Loki::TypeInfo(typeid(dynamics::Static))) + throw ExperimentException("Cannot add static elements to Simultaneous!"); + if(Compound::empty()) + return Compound::add(e); + if(get_independent_type() != e->get_independent_type()) + throw ExperimentException("Cannot add element because types of independent variable are not equal!"); + Experiment* ep = *Compound::begin(); + if(!ep->has_matching_independent_range(e)) + throw ExperimentException("Cannot add element because ranges of the independent variable do not match!"); + return Compound::add(e); + } private: friend class boost::serialization::access; *************** *** 478,493 **** }; ! typedef Action<realism::Real, dynamics::Dynamic, quantity::ElectricPotential, quantity::Time> MyAction; ! typedef Observation<realism::Real, dynamics::Dynamic, quantity::ElectricPotential, quantity::Time> MyObservation; ! typedef Atomic<realism::Real, dynamics::Dynamic> MyAtomic; } // end namespace experiment BOOST_IS_ABSTRACT(experiment::Experiment) ! BOOST_IS_ABSTRACT(experiment::MyAtomic) ! BOOST_CLASS_EXPORT_GUID(experiment::MyAtomic, "experiment::MyAtomic") ! BOOST_CLASS_EXPORT_GUID(experiment::MyAction, "experiment::MyAction") ! BOOST_CLASS_EXPORT_GUID(experiment::MyObservation, "experiment::MyObservation") BOOST_CLASS_EXPORT_GUID(experiment::Compound, "experiment::Compound") BOOST_CLASS_EXPORT_GUID(experiment::Homogeneous, "experiment::Homogeneous") BOOST_CLASS_EXPORT_GUID(experiment::Sequential, "experiment::Sequential") --- 696,772 ---- }; ! typedef Action<realism::Real, dynamics::Dynamic, ! quantity::ElectricPotential, quantity::Time> ! RealDynamicEPTAction; ! typedef Action<realism::Simulated, dynamics::Dynamic, ! quantity::ElectricPotential, quantity::Time> ! SimulatedDynamicEPTAction; ! typedef Action<realism::Dual, dynamics::Dynamic, ! quantity::ElectricPotential, quantity::Time> ! DualDynamicEPTAction; ! typedef Action<realism::Real, dynamics::Static, ! quantity::ElectricPotential, quantity::Time> ! RealStaticEPTAction; ! typedef Action<realism::Simulated, dynamics::Static, ! quantity::ElectricPotential, quantity::Time> ! SimulatedStaticEPTAction; ! typedef Action<realism::Dual, dynamics::Static, ! quantity::ElectricPotential, quantity::Time> ! DualStaticEPTAction; ! typedef Action<realism::Real, dynamics::Dynamic, ! quantity::ElectricPotential, quantity::CelsiusTemperature> ! RealDynamicEPTempAction; ! typedef Action<realism::Real, dynamics::Dynamic, ! quantity::ElectricCurrent, quantity::Time> ! RealDynamicECTAction; ! typedef Observation<realism::Real, dynamics::Dynamic, quantity::Time, ! quantity::ElectricPotential> ! RealDynamicTEPObservation; ! typedef Induced<realism::Real, dynamics::Dynamic, ! quantity::ElectricPotential, quantity::Time, quantity::Time> ! RealDynamicEPTInduced; ! typedef Atomic<realism::Real, dynamics::Dynamic> RealDynamicAtomic; ! typedef Atomic<realism::Real, dynamics::Static> RealStaticAtomic; ! typedef Atomic<realism::Simulated, dynamics::Dynamic> SimulatedDynamicAtomic; ! typedef Atomic<realism::Simulated, dynamics::Static> SimulatedStaticAtomic; ! typedef Atomic<realism::Dual, dynamics::Dynamic> DualDynamicAtomic; ! typedef Atomic<realism::Dual, dynamics::Static> DualStaticAtomic; } // end namespace experiment BOOST_IS_ABSTRACT(experiment::Experiment) ! BOOST_IS_ABSTRACT(experiment::RealDynamicAtomic) ! BOOST_IS_ABSTRACT(experiment::RealStaticAtomic) ! BOOST_IS_ABSTRACT(experiment::SimulatedDynamicAtomic) ! BOOST_IS_ABSTRACT(experiment::SimulatedStaticAtomic) ! BOOST_IS_ABSTRACT(experiment::DualDynamicAtomic) ! BOOST_IS_ABSTRACT(experiment::DualStaticAtomic) ! BOOST_CLASS_EXPORT_GUID(experiment::Experiment, "experiment::Experiment") ! BOOST_CLASS_EXPORT_GUID(experiment::RealDynamicAtomic, ! "experiment::RealDynamicAtomic") ! BOOST_CLASS_EXPORT_GUID(experiment::RealStaticAtomic, ! "experiment::RealDynamicAtomic") ! BOOST_CLASS_EXPORT_GUID(experiment::SimulatedDynamicAtomic, ! "experiment::RealDynamicAtomic") ! BOOST_CLASS_EXPORT_GUID(experiment::SimulatedStaticAtomic, ! "experiment::RealDynamicAtomic") ! BOOST_CLASS_EXPORT_GUID(experiment::DualDynamicAtomic, ! "experiment::RealDynamicAtomic") ! BOOST_CLASS_EXPORT_GUID(experiment::DualStaticAtomic, ! "experiment::RealDynamicAtomic") ! ! BOOST_CLASS_EXPORT(experiment::RealDynamicEPTAction) ! BOOST_CLASS_EXPORT(experiment::SimulatedDynamicEPTAction) ! BOOST_CLASS_EXPORT(experiment::DualDynamicEPTAction) ! BOOST_CLASS_EXPORT(experiment::RealStaticEPTAction) ! BOOST_CLASS_EXPORT(experiment::SimulatedStaticEPTAction) ! BOOST_CLASS_EXPORT(experiment::DualStaticEPTAction) ! BOOST_CLASS_EXPORT(experiment::RealDynamicEPTempAction) ! BOOST_CLASS_EXPORT(experiment::RealDynamicECTAction) ! BOOST_CLASS_EXPORT(experiment::RealDynamicTEPObservation) ! BOOST_CLASS_EXPORT(experiment::RealDynamicEPTInduced) ! BOOST_CLASS_EXPORT_GUID(experiment::Compound, "experiment::Compound") + BOOST_CLASS_EXPORT_GUID(experiment::Collection, "experiment::Collection") BOOST_CLASS_EXPORT_GUID(experiment::Homogeneous, "experiment::Homogeneous") BOOST_CLASS_EXPORT_GUID(experiment::Sequential, "experiment::Sequential") |
|
From: <ber...@t-...> - 2007-04-10 08:29:11
|
Dominik Brugger wrote: > Hi, > > well this is certainly one of the many "feature clashs" that > make C++ so troublesome. The core problem is > instantiation of templates, which occurs *after* the preprocessor > run. For this reason no automatic generation of names > is possible for template classes. > > The only solution I see is the one proposed in the newsgroup, > that is using typeid. This will obviously work as long as we > use the same compiler and portability across different platforms > is not an issue. We could establish an additional mechanism, which is maybe not VERY elegant, but it should work: we add a static const std::string ID to each class to be serialized (we have to add some code anyway ...). This can be related to the Name of the class, in the case of templates, we need also to code in some way the ID of parametrizing classes. I had done this for the old version of XML save/load in ExcitationFunction. Although this will be obsolete soon (when we have introduced the sreialization concept), it might be a model. Now, I have started to do something like this in the context of serialization with the Quantity classes. I will upload this to cvs later this morning. I have coded into this template serialization ID (TSID) the Quantity, the storage unit and the mode of the quantity into one string, which is then given to BOOST_CLASS_EXPORT_GUID - unfortunately not yet automatically. I am afraid - and I agree with the above - that we might have to substitute the preprocessor macros by some template construct ... Another problem which I have in the moment, is that I need to code the `storage type' (i.e., is the Quantity given as int, double, bool, etc) into the TSID. Does anyone know about some code which does convert a POD type into a corresponding string? Also, the TSID construction is not yet complete for some units (the Composed units) and some modes of quantities. Bernd -- ======================================================================= Bernd Speiser Institut für Organische Chemie Auf der Morgenstelle 18 D-72076 Tübingen Germany phone: +49-7071-2976205 (office) +49-7071-2976242 (laboratory) fax: +49-7071-295518 e-mail: ber...@un... Internet: http://www.uni-tuebingen.de/speiser ======================================================================= |
|
From: <ber...@t-...> - 2007-04-09 08:54:01
|
Dominik Brugger wrote: > Hello, > > yesterday it was correctly pointed out by Bernd Speiser, > that serialization of whole class hierarchies necessitates > the usage of the Factory design pattern. > > But it is not necessary to wrap up boost::serialization > with this kind of mechanism as it is already provided by > the library. > > To illustrate the serialization capabilities consider the > example program below. One important point are the > BOOST_EXPORT_GUID makros which equip each > class with a globally unique identifier. If these are > omitted the code will compile, but when reading back > the objects at runtime an exception of type "unregistered class" > will be thrown. Otherwise the objects are correctly read > back without knowing the exact type (polymorphic base*). > > Dominik Brugger Hi, yes, I am convinced in the meantime. Test with the Quantity library show thatb it indeed works in this way. (this is why I crosspost this e-mail to the quantity-devel list). One problem remains which has already been discussed several times in the boost mailing list (see, http://thread.gmane.org/gmane.comp.lib.boost.user/13244/focus=13300): automatic `registration' of template classes is not possible. This means that we explicitly have to register all necessary instances of a templare class with the serialization library. I have no clear idea in the very moment how to overcome this. One important aspect of this may also be that we have to assemble the unique identifier names for templated classes. Anyway, I will try to finalize the Quantity classes for serialization quickly. Bernd > > #include <boost/archive/xml_iarchive.hpp> > #include <boost/archive/xml_oarchive.hpp> > #include <boost/serialization/serialization.hpp> > #include <boost/serialization/base_object.hpp> > #include <boost/serialization/nvp.hpp> > #include <boost/serialization/export.hpp> > #include <fstream> > #include <iostream> > > class base > { > public: > base() : data(3.14) {} > virtual void print() > { > std::cout << "base.data " << data << std::endl; > } > private: > friend class boost::serialization::access; > template<class Archive> > void serialize(Archive & ar, const unsigned int file_version) > { > ar & BOOST_SERIALIZATION_NVP(data); > } > double data; > }; > > class derived1 : public base > { > public: > derived1() : derived1_data(42) {} > virtual void print() > { > base::print(); > std::cout << "derived1.data " << derived1_data << std::endl; > } > private: > friend class boost::serialization::access; > template<class Archive> > void serialize(Archive &ar, const unsigned int file_version) > { > ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(base) > & BOOST_SERIALIZATION_NVP(derived1_data); > } > int derived1_data; > }; > > class derived2 : public base > { > public: > derived2() : derived2_data(123) {} > virtual void print() > { > base::print(); > std::cout << "derived2.data " << derived2_data << std::endl; > } > private: > friend class boost::serialization::access; > template<class Archive> > void serialize(Archive &ar, const unsigned int file_version) > { > ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(base) > & BOOST_SERIALIZATION_NVP(derived2_data); > } > int derived2_data; > }; > > BOOST_CLASS_EXPORT_GUID(base, "base"); > BOOST_CLASS_EXPORT_GUID(derived1, "derived1"); > BOOST_CLASS_EXPORT_GUID(derived2, "derived2"); > > void save(const char *testfile) > { > std::ofstream os(testfile); > boost::archive::xml_oarchive oa(os); > > base *b1 = new derived1(); > base *b2 = new derived2(); > > oa << BOOST_SERIALIZATION_NVP(b1); > oa << BOOST_SERIALIZATION_NVP(b2); > > delete b1; > delete b2; > } > > void load(const char *testfile) > { > std::ifstream is(testfile); > boost::archive::xml_iarchive ia(is); > > // Note that we do not know anything about the type > // of stored objects at this point > base *b1 = NULL; > base *b2 = NULL; > > // The factory design pattern is already included in > // boost::serialization > ia >> BOOST_SERIALIZATION_NVP(b1); > ia >> BOOST_SERIALIZATION_NVP(b2); > > // Dump to stdout to check that we read back the right > // types > std::cout << "Read: "; > b1->print(); > std::cout << "Read: "; > b2->print(); > > delete b1; > delete b2; > } > > int main(int argc, char* argv[]) > { > // Note that calls to save/load can be made in > // different program runs, compilation units etc. > save("test.xml"); > load("test.xml"); > return EXIT_SUCCESS; > } -- ======================================================================= Bernd Speiser Institut für Organische Chemie Auf der Morgenstelle 18 D-72076 Tübingen Germany phone: +49-7071-2976205 (office) +49-7071-2976242 (laboratory) fax: +49-7071-295518 e-mail: ber...@un... Internet: http://www.uni-tuebingen.de/speiser ======================================================================= |
|
From: Dominik B. <dom...@gm...> - 2007-04-08 08:38:55
|
Hello,
yesterday it was correctly pointed out by Bernd Speiser,
that serialization of whole class hierarchies necessitates
the usage of the Factory design pattern.
But it is not necessary to wrap up boost::serialization
with this kind of mechanism as it is already provided by
the library.
To illustrate the serialization capabilities consider the
example program below. One important point are the
BOOST_EXPORT_GUID makros which equip each
class with a globally unique identifier. If these are
omitted the code will compile, but when reading back
the objects at runtime an exception of type "unregistered class"
will be thrown. Otherwise the objects are correctly read
back without knowing the exact type (polymorphic base*).
Dominik Brugger
#include <boost/archive/xml_iarchive.hpp>
#include <boost/archive/xml_oarchive.hpp>
#include <boost/serialization/serialization.hpp>
#include <boost/serialization/base_object.hpp>
#include <boost/serialization/nvp.hpp>
#include <boost/serialization/export.hpp>
#include <fstream>
#include <iostream>
class base
{
public:
base() : data(3.14) {}
virtual void print()
{
std::cout << "base.data " << data << std::endl;
}
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive & ar, const unsigned int file_version)
{
ar & BOOST_SERIALIZATION_NVP(data);
}
double data;
};
class derived1 : public base
{
public:
derived1() : derived1_data(42) {}
virtual void print()
{
base::print();
std::cout << "derived1.data " << derived1_data << std::endl;
}
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive &ar, const unsigned int file_version)
{
ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(base)
& BOOST_SERIALIZATION_NVP(derived1_data);
}
int derived1_data;
};
class derived2 : public base
{
public:
derived2() : derived2_data(123) {}
virtual void print()
{
base::print();
std::cout << "derived2.data " << derived2_data << std::endl;
}
private:
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive &ar, const unsigned int file_version)
{
ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(base)
& BOOST_SERIALIZATION_NVP(derived2_data);
}
int derived2_data;
};
BOOST_CLASS_EXPORT_GUID(base, "base");
BOOST_CLASS_EXPORT_GUID(derived1, "derived1");
BOOST_CLASS_EXPORT_GUID(derived2, "derived2");
void save(const char *testfile)
{
std::ofstream os(testfile);
boost::archive::xml_oarchive oa(os);
base *b1 = new derived1();
base *b2 = new derived2();
oa << BOOST_SERIALIZATION_NVP(b1);
oa << BOOST_SERIALIZATION_NVP(b2);
delete b1;
delete b2;
}
void load(const char *testfile)
{
std::ifstream is(testfile);
boost::archive::xml_iarchive ia(is);
// Note that we do not know anything about the type
// of stored objects at this point
base *b1 = NULL;
base *b2 = NULL;
// The factory design pattern is already included in
// boost::serialization
ia >> BOOST_SERIALIZATION_NVP(b1);
ia >> BOOST_SERIALIZATION_NVP(b2);
// Dump to stdout to check that we read back the right
// types
std::cout << "Read: ";
b1->print();
std::cout << "Read: ";
b2->print();
delete b1;
delete b2;
}
int main(int argc, char* argv[])
{
// Note that calls to save/load can be made in
// different program runs, compilation units etc.
save("test.xml");
load("test.xml");
return EXIT_SUCCESS;
}
|
|
From: beeblbrox <bee...@us...> - 2007-04-07 08:06:59
|
Update of /cvsroot/echempp/Experiment/Experiment/test In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv11788 Modified Files: ExperimentTest.cpp Log Message: Modification to serialization test. Index: ExperimentTest.cpp =================================================================== RCS file: /cvsroot/echempp/Experiment/Experiment/test/ExperimentTest.cpp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ExperimentTest.cpp 6 Apr 2007 17:18:18 -0000 1.2 --- ExperimentTest.cpp 7 Apr 2007 08:06:45 -0000 1.3 *************** *** 1,2 **** --- 1,4 ---- + #include <iostream> + // Boost includes #include <boost/test/unit_test.hpp> *************** *** 62,66 **** Homogeneous hg; hg.add(new experiment::MyAction()); ! // hg.add(new Observation(Dynamic,Real)); hg.add(new experiment::MyAction()); --- 64,75 ---- Homogeneous hg; hg.add(new experiment::MyAction()); ! try ! { ! hg.add(new experiment::MyObservation()); ! } ! catch(ExperimentException& e) ! { ! std::cout << e.what() << std::endl; ! } hg.add(new experiment::MyAction()); *************** *** 85,88 **** --- 94,105 ---- ia_txt >> hg2; ifs_txt.close(); + + { + const Homogeneous& hgc = hg2; + std::ofstream ofs_xml("/tmp/exp2.xml"); + boost::archive::xml_oarchive oa_xml(ofs_xml); + oa_xml << BOOST_SERIALIZATION_NVP(hgc); + ofs_xml.close(); + } } |
|
From: beeblbrox <bee...@us...> - 2007-04-06 17:18:21
|
Update of /cvsroot/echempp/Experiment/Experiment/test In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv19931/test Modified Files: ExperimentTest.cpp Log Message: Updated to reflect changes done in Experiment.hpp. Index: ExperimentTest.cpp =================================================================== RCS file: /cvsroot/echempp/Experiment/Experiment/test/ExperimentTest.cpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ExperimentTest.cpp 6 Apr 2007 10:13:39 -0000 1.1 --- ExperimentTest.cpp 6 Apr 2007 17:18:18 -0000 1.2 *************** *** 18,24 **** { Experiment *ep; ! ep = new experiment::MyAction(Dynamic,Real); delete ep; ! ep = new Observation(Dynamic,Real); delete ep; // ep = new Collection(); --- 18,24 ---- { Experiment *ep; ! ep = new MyAction(); delete ep; ! ep = new MyObservation(); delete ep; // ep = new Collection(); *************** *** 40,45 **** { // Action serialization ! experiment::MyAction *act; ! act = new experiment::MyAction(Dynamic, Real); std::ofstream ofs_txt("/tmp/action.txt"); --- 40,45 ---- { // Action serialization ! MyAction *act; ! act = new MyAction(); std::ofstream ofs_txt("/tmp/action.txt"); *************** *** 49,53 **** boost::archive::xml_oarchive oa_xml(ofs_xml); ! const experiment::MyAction a(Dynamic, Real); cep = act; // oa_txt << *cep; --- 49,53 ---- boost::archive::xml_oarchive oa_xml(ofs_xml); ! const MyAction a; cep = act; // oa_txt << *cep; *************** *** 61,67 **** // Homogeneous serialization Homogeneous hg; ! hg.add(new experiment::MyAction(Dynamic,Real)); ! hg.add(new Observation(Dynamic,Real)); ! hg.add(new experiment::MyAction(Dynamic,Real)); std::ofstream ofs_txt("/tmp/exp.txt"); --- 61,67 ---- // Homogeneous serialization Homogeneous hg; ! hg.add(new experiment::MyAction()); ! // hg.add(new Observation(Dynamic,Real)); ! hg.add(new experiment::MyAction()); std::ofstream ofs_txt("/tmp/exp.txt"); |
|
From: beeblbrox <bee...@us...> - 2007-04-06 17:17:54
|
Update of /cvsroot/echempp/Experiment/Experiment/test In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv19531/test Modified Files: Makefile.am Log Message: Updated to link with Loki and Quantities. Index: Makefile.am =================================================================== RCS file: /cvsroot/echempp/Experiment/Experiment/test/Makefile.am,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** Makefile.am 6 Apr 2007 10:15:51 -0000 1.13 --- Makefile.am 6 Apr 2007 17:17:51 -0000 1.14 *************** *** 4,10 **** ExperimentTest_LDADD = -lboost_unit_test_framework \ ! -lboost_serialization \ ! -lboost_date_time \ ! -leppExcitationFunction \ -leppData \ -L$(QUANTITIESLIB) -lGeneralQuantities \ --- 4,10 ---- ExperimentTest_LDADD = -lboost_unit_test_framework \ ! -lboost_serialization \ ! -lboost_date_time \ ! -leppExcitationFunction \ -leppData \ -L$(QUANTITIESLIB) -lGeneralQuantities \ *************** *** 13,17 **** -L$(BSUTILITIESLIB) -lBSUtilities \ -L$(LOKILIB) -lloki - # ../libeppExperiment.la --- 13,16 ---- *************** *** 21,23 **** -I$(QUANTITIESSRC) ! ExperimentTest_CXXFLAGS = -Wall -Werror -pedantic-errors \ -DTIXML_USE_STL=YES --- 20,22 ---- -I$(QUANTITIESSRC) ! ExperimentTest_CXXFLAGS = -Wall -Werror -pedantic-errors -DTIXML_USE_STL=YES |
|
From: beeblbrox <bee...@us...> - 2007-04-06 17:17:08
|
Update of /cvsroot/echempp/Experiment/Experiment In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv19144 Modified Files: Experiment.hpp Log Message: Made Realism and Dynamics template parameters, added functions for extraction of RTTI for checks done in Containers. Implemented checks for add on Homogeneous. Index: Experiment.hpp =================================================================== RCS file: /cvsroot/echempp/Experiment/Experiment/Experiment.hpp,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** Experiment.hpp 6 Apr 2007 10:12:10 -0000 1.1 --- Experiment.hpp 6 Apr 2007 17:17:05 -0000 1.2 *************** *** 1,3 **** --- 1,5 ---- + // $Id$ + #ifndef __EXPERIMENT_HPP__ #define __EXPERIMENT_HPP__ *************** *** 9,12 **** --- 11,15 ---- #include <functional> #include <fstream> + #include <typeinfo> // Boost includes *************** *** 21,24 **** --- 24,30 ---- #include <boost/date_time/posix_time/time_serialize.hpp> + // Loki includes + #include <loki/LokiTypeInfo.h> + // Local includes #include "ExcitationFunction/excitationFunction.hpp" *************** *** 52,64 **** }; ! enum Realism{ ! Simulated, ! Real, ! Dual ! }; ! enum Dynamics{ ! Dynamic, ! Static ! }; class ExperimentException --- 58,72 ---- }; ! namespace realism ! { ! struct Simulated{}; ! struct Real{}; ! struct Dual{}; ! } ! namespace dynamics ! { ! struct Dynamic{}; ! struct Static{}; ! } class ExperimentException *************** *** 78,99 **** { public: virtual ~Experiment() {} virtual void perform() = 0; ! virtual const int dynamics_kind() const = 0; ! virtual const int realism_kind() const = 0; private: friend class boost::serialization::access; template<class Archive> ! void serialize(Archive & ar, const unsigned int version){} }; ! class Atomic : public Experiment { public: ! Atomic(int dynamics, int realism) ! : dynamics_(dynamics), realism_(realism) {} virtual ~Atomic() {}; ! const int dynamics_kind() const { return dynamics_; } ! const int realism_kind() const { return realism_; } private: friend class boost::serialization::access; --- 86,128 ---- { public: + Experiment() { title_ = "Insert Experiment title"; } + Experiment(const std::string title) : title_(title) {} virtual ~Experiment() {} virtual void perform() = 0; ! virtual const Loki::TypeInfo get_independent_type() const = 0; ! virtual const Loki::TypeInfo get_dependent_type() const = 0; ! virtual const Loki::TypeInfo get_result_type() const = 0; ! virtual const Loki::TypeInfo get_realism_type() const = 0; ! virtual const Loki::TypeInfo get_dynamics_type() const = 0; ! const std::string& get_title() const { return title_; } ! void set_title(const std::string& title) { title_ = title; } private: + std::string title_; friend class boost::serialization::access; template<class Archive> ! void serialize(Archive & ar, const unsigned int version) ! { ! ar & BOOST_SERIALIZATION_NVP(title_); ! } }; ! ! template<class Realism, ! class Dynamics> class Atomic : public Experiment { public: ! Atomic() {}; virtual ~Atomic() {}; ! // RTTI ! const Loki::TypeInfo get_realism_type() const ! { ! Loki::TypeInfo info = typeid(Realism); ! return info; ! } ! const Loki::TypeInfo get_dynamics_type() const ! { ! Loki::TypeInfo info = typeid(Dynamics); ! return info; ! } private: friend class boost::serialization::access; *************** *** 101,156 **** void serialize(Archive & ar, const unsigned int version) { ! ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Experiment) ! & BOOST_SERIALIZATION_NVP(dynamics_) ! & BOOST_SERIALIZATION_NVP(realism_); } - int dynamics_; - int realism_; - // TODO: insert ExcitationFunction - protected: - Atomic() {} // For serialization }; ! template<class I, class D> ! class Action : public Atomic { public: ! Action(int dynamics, int realism) ! : Atomic(dynamics, realism){} virtual ~Action() {}; virtual void perform() {}; private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ! ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Atomic) & BOOST_SERIALIZATION_NVP(execution_start) & BOOST_SERIALIZATION_NVP(execution_end); } - Action(){} // For serialization boost::posix_time::ptime execution_start; boost::posix_time::ptime execution_end; - // TODO: insert ExcitationFunc ExcitationFunctions::DIExcitationFunction<I,D> exc_func; }; ! class Observation : public Atomic { public: ! Observation(int dynamics, int realism) ! : Atomic(dynamics, realism){} virtual ~Observation() {}; virtual void perform() {}; private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ! ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Atomic) & BOOST_SERIALIZATION_NVP(recording_start) & BOOST_SERIALIZATION_NVP(recording_end); } - Observation(){} // For serialization boost::posix_time::ptime recording_start; boost::posix_time::ptime recording_end; --- 130,309 ---- void serialize(Archive & ar, const unsigned int version) { ! ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Experiment); } }; ! template<class Realism, ! class Dynamics, ! class I, /* type of independent variable */ ! class D> /* type of dependent variable */ ! class Action : public Atomic<Realism, Dynamics> { public: ! Action() {}; virtual ~Action() {}; virtual void perform() {}; + // RTTI + const Loki::TypeInfo get_independent_type() const + { + Loki::TypeInfo info = typeid(I); + return info; + } + const Loki::TypeInfo get_dependent_type() const + { + Loki::TypeInfo info = typeid(D); + return info; + } + const Loki::TypeInfo get_result_type() const + { + Loki::TypeInfo info = typeid(Loki::EmptyType); + return info; + } private: + typedef Atomic<Realism, Dynamics> AtomicBase; friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ! ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(AtomicBase) & BOOST_SERIALIZATION_NVP(execution_start) & BOOST_SERIALIZATION_NVP(execution_end); + // TODO: serialize exc_func } boost::posix_time::ptime execution_start; boost::posix_time::ptime execution_end; ExcitationFunctions::DIExcitationFunction<I,D> exc_func; }; ! template<class Realism, ! class Dynamics, ! class I, /* type of independent variable */ ! class D, /* type of dependent variable */ ! class R> /* type of result variable */ ! class Induced : public Atomic<Realism, Dynamics> { public: ! Induced() {}; ! virtual ~Induced() {}; ! virtual void perform() {}; ! // RTTI ! const Loki::TypeInfo get_independent_type() const ! { ! Loki::TypeInfo info = typeid(I); ! return info; ! } ! const Loki::TypeInfo get_dependent_type() const ! { ! Loki::TypeInfo info = typeid(D); ! return info; ! } ! const Loki::TypeInfo get_result_type() const ! { ! Loki::TypeInfo info = typeid(R); ! return info; ! } ! private: ! typedef Atomic<Realism, Dynamics> AtomicBase; ! friend class boost::serialization::access; ! template<class Archive> ! void serialize(Archive & ar, const unsigned int version) ! { ! ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(AtomicBase) ! & BOOST_SERIALIZATION_NVP(induction_start) ! & BOOST_SERIALIZATION_NVP(induction_end); ! // TODO: serialize exc_func ! } ! boost::posix_time::ptime induction_start; ! boost::posix_time::ptime induction_end; ! ExcitationFunctions::DIExcitationFunction<I,D> exc_func; ! // TODO: MeasurementData ? ! R result; ! }; ! ! template<class Realism, ! class Dynamics, ! class I, /* type of independent variable */ ! class R> /* type of result variable */ ! class Observation : public Atomic<Realism, Dynamics> {}; ! ! // partial template specialization to enforce constraint, ! // that only dynamic Observations contain R,I and static ! // observation only R ! template<class Realism, ! class I, ! class R> ! class Observation<Realism, dynamics::Dynamic, I, R> ! : public Atomic<Realism, dynamics::Dynamic> ! { ! public: ! Observation() {}; virtual ~Observation() {}; virtual void perform() {}; + // RTTI + const Loki::TypeInfo get_independent_type() const + { + Loki::TypeInfo info = typeid(I); + return info; + } + const Loki::TypeInfo get_dependent_type() const + { + Loki::TypeInfo info = typeid(Loki::EmptyType); + return info; + } + const Loki::TypeInfo get_result_type() const + { + Loki::TypeInfo info = typeid(R); + return info; + } private: + typedef Atomic<Realism, dynamics::Dynamic> AtomicBase; friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ! ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(AtomicBase) ! & BOOST_SERIALIZATION_NVP(recording_start) ! & BOOST_SERIALIZATION_NVP(recording_end); ! } ! boost::posix_time::ptime recording_start; ! boost::posix_time::ptime recording_end; ! // TODO: insert Conditions, StateData ! }; ! ! template<class Realism, ! class R> ! class Observation<Realism, dynamics::Static, Loki::EmptyType, R> ! : public Atomic<Realism, dynamics::Static> ! { ! public: ! Observation() {}; ! virtual ~Observation() {}; ! virtual void perform() {}; ! // RTTI ! const Loki::TypeInfo get_independent_type() const ! { ! Loki::TypeInfo info = typeid(Loki::EmptyType); ! return info; ! } ! const Loki::TypeInfo get_dependent_type() const ! { ! Loki::TypeInfo info = typeid(Loki::EmptyType); ! return info; ! } ! const Loki::TypeInfo get_result_type() const ! { ! Loki::TypeInfo info = typeid(R); ! return info; ! } ! private: ! typedef Atomic<Realism, dynamics::Static> AtomicBase; ! friend class boost::serialization::access; ! template<class Archive> ! void serialize(Archive & ar, const unsigned int version) ! { ! ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(AtomicBase) & BOOST_SERIALIZATION_NVP(recording_start) & BOOST_SERIALIZATION_NVP(recording_end); } boost::posix_time::ptime recording_start; boost::posix_time::ptime recording_end; *************** *** 185,188 **** --- 338,397 ---- return elements.begin(); } + // RTTI + const Loki::TypeInfo get_realism_type() const + { + Loki::TypeInfo info; + if(empty()) + { + info = typeid(Loki::EmptyType); + return info; + } + Experiment *ep = *begin(); + return ep->get_realism_type(); + } + const Loki::TypeInfo get_dynamics_type() const + { + Loki::TypeInfo info; + if(empty()) + { + info = typeid(Loki::EmptyType); + return info; + } + Experiment *ep = *begin(); + return ep->get_dynamics_type(); + } + const Loki::TypeInfo get_independent_type() const + { + Loki::TypeInfo info; + if(empty()) + { + info = typeid(Loki::EmptyType); + return info; + } + Experiment *ep = *begin(); + return ep->get_independent_type(); + } + const Loki::TypeInfo get_dependent_type() const + { + Loki::TypeInfo info; + if(empty()) + { + info = typeid(Loki::EmptyType); + return info; + } + Experiment *ep = *begin(); + return ep->get_dependent_type(); + } + const Loki::TypeInfo get_result_type() const + { + Loki::TypeInfo info; + if(empty()) + { + info = typeid(Loki::EmptyType); + return info; + } + Experiment *ep = *begin(); + return ep->get_result_type(); + } private: friend class boost::serialization::access; *************** *** 202,205 **** --- 411,415 ---- virtual ~Collection() {}; // No restricton on add, just inherit the one from Compound + private: friend class boost::serialization::access; *************** *** 215,249 **** public: virtual ~Homogeneous() {}; - // Exploit Homogeneous invariant, that all elements - // have the same dynamics - const int dynamics_kind() const - { - if(Compound::empty()) - throw ExperimentException("No dynamics type for empty Homogeneous"); - Experiment *e = *Compound::begin(); - return e->dynamics_kind(); - } - const int realism_kind() const - { - if(Compound::empty()) - throw ExperimentException("No realism type for empty Homogeneous"); - Experiment *e = *Compound::begin(); - return e->realism_kind(); - } virtual void add(Experiment* e) ! { std::cout << "Homogeneous::add called!" << std::endl; - // Check that e is atomic - if(!dynamic_cast<Atomic*>(e)) - throw ExperimentException("Cannot build Homogeneous with non-atomic elements!"); - // Check if this is the first inserted element if(Compound::empty()) return Compound::add(e); ! // Do element's type match? ! Experiment *ep = *Compound::begin(); ! if(ep->dynamics_kind() == e->dynamics_kind() && ! ep->realism_kind() == e->realism_kind()) ! return Compound::add(e); ! throw ExperimentException("All elements added to a Homogeneous compound should be of the same Experiment type!"); } private: --- 425,444 ---- public: virtual ~Homogeneous() {}; virtual void add(Experiment* e) ! { std::cout << "Homogeneous::add called!" << std::endl; if(Compound::empty()) return Compound::add(e); ! if(get_realism_type() != e->get_realism_type()) ! throw ExperimentException("Cannot add element because realism type does not match!"); ! if(get_dynamics_type() != e->get_dynamics_type()) ! throw ExperimentException("Cannot add element because dynamics type does not match!"); ! if(get_independent_type() != e->get_independent_type()) ! throw ExperimentException("Cannot add element because types of independent variable are not equal!"); ! if(get_dependent_type() != e->get_dependent_type()) ! throw ExperimentException("Cannot add element because types of dependent variable are not equal!"); ! if(get_result_type() != e->get_result_type()) ! throw ExperimentException("Cannot add element because result types do not match!"); ! return Compound::add(e); } private: *************** *** 283,295 **** }; ! typedef Action<quantity::ElectricPotential, quantity::Time> MyAction; } // end namespace experiment BOOST_IS_ABSTRACT(experiment::Experiment) ! BOOST_IS_ABSTRACT(experiment::Atomic) ! BOOST_CLASS_EXPORT_GUID(experiment::Atomic, "experiment::Atomic") BOOST_CLASS_EXPORT_GUID(experiment::MyAction, "experiment::MyAction") ! BOOST_CLASS_EXPORT_GUID(experiment::Observation, "experiment::Observation") BOOST_CLASS_EXPORT_GUID(experiment::Compound, "experiment::Compound") BOOST_CLASS_EXPORT_GUID(experiment::Homogeneous, "experiment::Homogeneous") --- 478,492 ---- }; ! typedef Action<realism::Real, dynamics::Dynamic, quantity::ElectricPotential, quantity::Time> MyAction; ! typedef Observation<realism::Real, dynamics::Dynamic, quantity::ElectricPotential, quantity::Time> MyObservation; ! typedef Atomic<realism::Real, dynamics::Dynamic> MyAtomic; } // end namespace experiment BOOST_IS_ABSTRACT(experiment::Experiment) ! BOOST_IS_ABSTRACT(experiment::MyAtomic) ! BOOST_CLASS_EXPORT_GUID(experiment::MyAtomic, "experiment::MyAtomic") BOOST_CLASS_EXPORT_GUID(experiment::MyAction, "experiment::MyAction") ! BOOST_CLASS_EXPORT_GUID(experiment::MyObservation, "experiment::MyObservation") BOOST_CLASS_EXPORT_GUID(experiment::Compound, "experiment::Compound") BOOST_CLASS_EXPORT_GUID(experiment::Homogeneous, "experiment::Homogeneous") |
|
From: beeblbrox <bee...@us...> - 2007-04-06 10:15:54
|
Update of /cvsroot/echempp/Experiment/Experiment/test In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv14349/test Modified Files: Makefile.am Log Message: Added LD directives for linking with boost. Index: Makefile.am =================================================================== RCS file: /cvsroot/echempp/Experiment/Experiment/test/Makefile.am,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** Makefile.am 14 Jan 2006 22:12:23 -0000 1.12 --- Makefile.am 6 Apr 2007 10:15:51 -0000 1.13 *************** *** 1,8 **** check_PROGRAMS = ExperimentTest ! ExperimentTest_SOURCES = ExperimentTest.cc ! ExperimentTest_LDADD = ../libeppExperiment.la \ ! -leppExcitationFunction \ -leppData \ -L$(QUANTITIESLIB) -lGeneralQuantities \ --- 1,10 ---- check_PROGRAMS = ExperimentTest ! ExperimentTest_SOURCES = ExperimentTest.cpp ! ExperimentTest_LDADD = -lboost_unit_test_framework \ ! -lboost_serialization \ ! -lboost_date_time \ ! -leppExcitationFunction \ -leppData \ -L$(QUANTITIESLIB) -lGeneralQuantities \ *************** *** 12,15 **** --- 14,19 ---- -L$(LOKILIB) -lloki + # ../libeppExperiment.la + INCLUDES = -I../../../Experiment \ -I$(LOKISRC) \ *************** *** 17,19 **** -I$(QUANTITIESSRC) ! ExperimentTest_CXXFLAGS = -Wall -Werror -pedantic-errors -DTIXML_USE_STL=YES --- 21,23 ---- -I$(QUANTITIESSRC) ! ExperimentTest_CXXFLAGS = -Wall -Werror -pedantic-errors \ -DTIXML_USE_STL=YES |
|
From: beeblbrox <bee...@us...> - 2007-04-06 10:13:43
|
Update of /cvsroot/echempp/Experiment/Experiment/test In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv13546/test Added Files: ExperimentTest.cpp Log Message: Initial version. So far only minor checks for construction + serialization. --- NEW FILE: ExperimentTest.cpp --- // Boost includes #include <boost/test/unit_test.hpp> using namespace boost::unit_test; #include <boost/archive/text_oarchive.hpp> #include <boost/archive/text_iarchive.hpp> #include <boost/archive/xml_iarchive.hpp> #include <boost/archive/xml_oarchive.hpp> // local includes #include "../Experiment.hpp" using namespace experiment; // Note: Compile and link with: // g++ -o ExperimentTest ExperimentTest.cpp -lboost_unit_test_framework // TODO: Enter this in Makefile.am void test_creation_destruction() { Experiment *ep; ep = new experiment::MyAction(Dynamic,Real); delete ep; ep = new Observation(Dynamic,Real); delete ep; // ep = new Collection(); // delete ep; ep = new Homogeneous(); delete ep; // ep = new Sequential(); // delete ep; // ep = new Simultaneous(); // delete ep; } void test_serialization() { const Experiment *cep; { // Action serialization experiment::MyAction *act; act = new experiment::MyAction(Dynamic, Real); std::ofstream ofs_txt("/tmp/action.txt"); boost::archive::text_oarchive oa_txt(ofs_txt); std::ofstream ofs_xml("/tmp/action.xml"); boost::archive::xml_oarchive oa_xml(ofs_xml); const experiment::MyAction a(Dynamic, Real); cep = act; // oa_txt << *cep; oa_txt << a; oa_xml << BOOST_SERIALIZATION_NVP(a); ofs_txt.close(); ofs_xml.close(); } // Homogeneous serialization Homogeneous hg; hg.add(new experiment::MyAction(Dynamic,Real)); hg.add(new Observation(Dynamic,Real)); hg.add(new experiment::MyAction(Dynamic,Real)); std::ofstream ofs_txt("/tmp/exp.txt"); boost::archive::text_oarchive oa_txt(ofs_txt); std::ofstream ofs_xml("/tmp/exp.xml"); boost::archive::xml_oarchive oa_xml(ofs_xml); //cep = hg; const Homogeneous& hgc = hg; oa_txt << hgc; oa_xml << BOOST_SERIALIZATION_NVP(hgc); // oa_xml << BOOST_SERIALIZATION_NVP(*cep); ofs_txt.close(); ofs_xml.close(); std::ifstream ifs_txt("/tmp/exp.txt"); boost::archive::text_iarchive ia_txt(ifs_txt); Homogeneous hg2; ia_txt >> hg2; ifs_txt.close(); } test_suite* init_unit_test_suite( int argc, char * argv[] ) { test_suite* test= BOOST_TEST_SUITE( "Experiment unit test" ); test->add( BOOST_TEST_CASE( &test_creation_destruction ) ); test->add( BOOST_TEST_CASE( &test_serialization ) ); // test->add( BOOST_TEST_CASE( &infinite_loop ), 0, /* timeout */ 2 ); return test; } |
|
From: beeblbrox <bee...@us...> - 2007-04-06 10:12:14
|
Update of /cvsroot/echempp/Experiment/Experiment In directory sc8-pr-cvs5.sourceforge.net:/tmp/cvs-serv13087 Added Files: Experiment.hpp Log Message: Initial version. Still needs template parameters for realism, dynamics and checking of invariants for containers. --- NEW FILE: Experiment.hpp --- #ifndef __EXPERIMENT_HPP__ #define __EXPERIMENT_HPP__ // STL includes #include <vector> #include <iostream> #include <algorithm> #include <functional> #include <fstream> // Boost includes #include <boost/serialization/serialization.hpp> #include <boost/serialization/export.hpp> #include <boost/serialization/base_object.hpp> #include <boost/serialization/is_abstract.hpp> #include <boost/serialization/nvp.hpp> #include <boost/serialization/utility.hpp> #include <boost/serialization/vector.hpp> #include <boost/date_time/posix_time/posix_time.hpp> #include <boost/date_time/posix_time/time_serialize.hpp> // Local includes #include "ExcitationFunction/excitationFunction.hpp" namespace experiment { // Unary functor for deletion template<typename Obj> class functor_delete { public: typedef Obj argument_type; typedef void result_type; result_type operator()(argument_type obj) { delete obj; } }; // Unary functor to call perform template<typename Obj> class functor_perform { public: typedef Obj argument_type; typedef void result_type; result_type operator()(argument_type obj) { obj->perform(); } }; enum Realism{ Simulated, Real, Dual }; enum Dynamics{ Dynamic, Static }; class ExperimentException { public: ExperimentException(const std::string &msg) : msg_(msg) {}; const std::string what() { return msg_; } private: std::string msg_; }; class Experiment { public: virtual ~Experiment() {} virtual void perform() = 0; virtual const int dynamics_kind() const = 0; virtual const int realism_kind() const = 0; private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version){} }; class Atomic : public Experiment { public: Atomic(int dynamics, int realism) : dynamics_(dynamics), realism_(realism) {} virtual ~Atomic() {}; const int dynamics_kind() const { return dynamics_; } const int realism_kind() const { return realism_; } private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Experiment) & BOOST_SERIALIZATION_NVP(dynamics_) & BOOST_SERIALIZATION_NVP(realism_); } int dynamics_; int realism_; // TODO: insert ExcitationFunction protected: Atomic() {} // For serialization }; template<class I, class D> class Action : public Atomic { public: Action(int dynamics, int realism) : Atomic(dynamics, realism){} virtual ~Action() {}; virtual void perform() {}; private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Atomic) & BOOST_SERIALIZATION_NVP(execution_start) & BOOST_SERIALIZATION_NVP(execution_end); } Action(){} // For serialization boost::posix_time::ptime execution_start; boost::posix_time::ptime execution_end; // TODO: insert ExcitationFunc ExcitationFunctions::DIExcitationFunction<I,D> exc_func; }; class Observation : public Atomic { public: Observation(int dynamics, int realism) : Atomic(dynamics, realism){} virtual ~Observation() {}; virtual void perform() {}; private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Atomic) & BOOST_SERIALIZATION_NVP(recording_start) & BOOST_SERIALIZATION_NVP(recording_end); } Observation(){} // For serialization boost::posix_time::ptime recording_start; boost::posix_time::ptime recording_end; // TODO: insert Conditions, StateData }; class Compound : public Experiment { public: virtual ~Compound() { std::for_each(elements.begin(), elements.end(), functor_delete<Experiment* >() ); } virtual void perform() { std::for_each(elements.begin(), elements.end(), functor_perform<Experiment* >() ); } virtual void add(Experiment* e) { std::cout << "Compound::add called!" << std::endl; elements.push_back(e); } bool empty() const { return elements.empty(); } typedef std::vector<Experiment*>::const_iterator const_iterator; const_iterator begin() const { return elements.begin(); } private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { std::cout << "Compound::serialize called!" << std::endl; ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Experiment) & BOOST_SERIALIZATION_NVP(elements); } std::vector<Experiment* > elements; }; class Collection : public Compound { public: virtual ~Collection() {}; // No restricton on add, just inherit the one from Compound private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Compound); } }; class Homogeneous : public Compound { public: virtual ~Homogeneous() {}; // Exploit Homogeneous invariant, that all elements // have the same dynamics const int dynamics_kind() const { if(Compound::empty()) throw ExperimentException("No dynamics type for empty Homogeneous"); Experiment *e = *Compound::begin(); return e->dynamics_kind(); } const int realism_kind() const { if(Compound::empty()) throw ExperimentException("No realism type for empty Homogeneous"); Experiment *e = *Compound::begin(); return e->realism_kind(); } virtual void add(Experiment* e) { std::cout << "Homogeneous::add called!" << std::endl; // Check that e is atomic if(!dynamic_cast<Atomic*>(e)) throw ExperimentException("Cannot build Homogeneous with non-atomic elements!"); // Check if this is the first inserted element if(Compound::empty()) return Compound::add(e); // Do element's type match? Experiment *ep = *Compound::begin(); if(ep->dynamics_kind() == e->dynamics_kind() && ep->realism_kind() == e->realism_kind()) return Compound::add(e); throw ExperimentException("All elements added to a Homogeneous compound should be of the same Experiment type!"); } private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { std::cout << "Homogeneous::serialize called!" << std::endl; ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Compound); } }; class Sequential : public Compound { public: virtual ~Sequential() {}; private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Compound); } }; class Simultaneous : public Compound { public: virtual ~Simultaneous() {}; private: friend class boost::serialization::access; template<class Archive> void serialize(Archive & ar, const unsigned int version) { ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Compound); } }; typedef Action<quantity::ElectricPotential, quantity::Time> MyAction; } // end namespace experiment BOOST_IS_ABSTRACT(experiment::Experiment) BOOST_IS_ABSTRACT(experiment::Atomic) BOOST_CLASS_EXPORT_GUID(experiment::Atomic, "experiment::Atomic") BOOST_CLASS_EXPORT_GUID(experiment::MyAction, "experiment::MyAction") BOOST_CLASS_EXPORT_GUID(experiment::Observation, "experiment::Observation") BOOST_CLASS_EXPORT_GUID(experiment::Compound, "experiment::Compound") BOOST_CLASS_EXPORT_GUID(experiment::Homogeneous, "experiment::Homogeneous") BOOST_CLASS_EXPORT_GUID(experiment::Sequential, "experiment::Sequential") BOOST_CLASS_EXPORT_GUID(experiment::Simultaneous, "experiment::Simultaneous") #endif |