[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[lmi-commits] [4798] Use CRTP, preferring nonvirtual inheritance
From: |
Greg Chicares |
Subject: |
[lmi-commits] [4798] Use CRTP, preferring nonvirtual inheritance |
Date: |
Sun, 21 Mar 2010 12:40:31 +0000 |
Revision: 4798
http://svn.sv.gnu.org/viewvc/?view=rev&root=lmi&revision=4798
Author: chicares
Date: 2010-03-21 12:40:30 +0000 (Sun, 21 Mar 2010)
Log Message:
-----------
Use CRTP, preferring nonvirtual inheritance
Modified Paths:
--------------
lmi/trunk/Makefile.am
lmi/trunk/antediluvian_stubs.cpp
lmi/trunk/input.cpp
lmi/trunk/input.hpp
lmi/trunk/input_xml_io.cpp
lmi/trunk/mec_input.cpp
lmi/trunk/mec_input.hpp
lmi/trunk/mec_state.cpp
lmi/trunk/mec_state.hpp
lmi/trunk/objects.make
lmi/trunk/xml_serializable.hpp
Added Paths:
-----------
lmi/trunk/xml_serializable.tpp
Removed Paths:
-------------
lmi/trunk/xml_serializable.cpp
Modified: lmi/trunk/Makefile.am
===================================================================
--- lmi/trunk/Makefile.am 2010-03-21 11:33:49 UTC (rev 4797)
+++ lmi/trunk/Makefile.am 2010-03-21 12:40:30 UTC (rev 4798)
@@ -286,7 +286,6 @@
system_command.cpp \
timer.cpp \
xml_lmi.cpp \
- xml_serializable.cpp \
yare_input.cpp
libmain_auxiliary_common_la_SOURCES = \
@@ -612,7 +611,6 @@
single_cell_document.cpp \
tn_range_types.cpp \
xml_lmi.cpp \
- xml_serializable.cpp \
yare_input.cpp
test_input_CXXFLAGS = $(AM_CXXFLAGS) $(XMLWRAPP_CFLAGS)
@@ -1012,6 +1010,7 @@
xml_lmi_fwd.hpp \
xml_lmi.hpp \
xml_serializable.hpp \
+ xml_serializable.tpp \
xml_serialize.hpp \
yare_input.hpp \
zero.hpp
Modified: lmi/trunk/antediluvian_stubs.cpp
===================================================================
--- lmi/trunk/antediluvian_stubs.cpp 2010-03-21 11:33:49 UTC (rev 4797)
+++ lmi/trunk/antediluvian_stubs.cpp 2010-03-21 12:40:30 UTC (rev 4798)
@@ -28,10 +28,10 @@
#include "authenticity.hpp"
#include "mec_server.hpp"
+#include "xml_serializable.tpp"
void authenticate_system()
-{
-}
+{}
std::string const& timestamp_of_production_release()
{
@@ -40,40 +40,35 @@
}
mec_server::mec_server(mcenum_emission)
-{
-}
+{}
mec_server::~mec_server()
-{
-}
+{}
bool mec_server::operator()(fs::path const&)
{
return false;
}
+template class xml_serializable<mec_state>;
+
mec_state::mec_state()
-{
-}
+{}
mec_state::mec_state(mec_state const&)
- :obstruct_slicing<mec_state>()
- ,xml_serializable()
- ,MemberSymbolTable<mec_state>()
-{
-}
+ :obstruct_slicing <mec_state>()
+ ,xml_serializable <mec_state>()
+ ,MemberSymbolTable <mec_state>()
+{}
mec_state::~mec_state()
-{
-}
+{}
void mec_state::read(xml::element const&)
-{
-}
+{}
void mec_state::write(xml::element&) const
-{
-}
+{}
int mec_state::class_version() const
{
Modified: lmi/trunk/input.cpp
===================================================================
--- lmi/trunk/input.cpp 2010-03-21 11:33:49 UTC (rev 4797)
+++ lmi/trunk/input.cpp 2010-03-21 12:40:30 UTC (rev 4798)
@@ -252,10 +252,10 @@
}
Input::Input(Input const& z)
- :obstruct_slicing<Input>()
- ,xml_serializable()
- ,MvcModel()
- ,MemberSymbolTable<Input>()
+ :obstruct_slicing <Input>()
+ ,xml_serializable <Input>()
+ ,MvcModel ()
+ ,MemberSymbolTable <Input>()
{
AscribeMembers();
std::vector<std::string>::const_iterator i;
Modified: lmi/trunk/input.hpp
===================================================================
--- lmi/trunk/input.hpp 2010-03-21 11:33:49 UTC (rev 4797)
+++ lmi/trunk/input.hpp 2010-03-21 12:40:30 UTC (rev 4798)
@@ -125,11 +125,11 @@
/// for them, readability overcomes the usual convention.
class LMI_SO Input
- :virtual private obstruct_slicing<Input>
- ,virtual public xml_serializable
- ,public MvcModel
- ,public MemberSymbolTable<Input>
- ,private boost::equality_comparable<Input>
+ :virtual private obstruct_slicing <Input>
+ , public xml_serializable <Input>
+ , public MvcModel
+ , public MemberSymbolTable <Input>
+ , private boost::equality_comparable <Input>
{
friend class input_test;
friend class yare_input;
Modified: lmi/trunk/input_xml_io.cpp
===================================================================
--- lmi/trunk/input_xml_io.cpp 2010-03-21 11:33:49 UTC (rev 4797)
+++ lmi/trunk/input_xml_io.cpp 2010-03-21 12:40:30 UTC (rev 4798)
@@ -27,6 +27,7 @@
#endif // __BORLANDC__
#include "input.hpp"
+#include "xml_serializable.tpp"
#include "alert.hpp"
#include "calendar_date.hpp"
@@ -40,6 +41,8 @@
#include <algorithm> // std::find()
#include <stdexcept>
+template class xml_serializable<Input>;
+
namespace
{
std::string full_name
Modified: lmi/trunk/mec_input.cpp
===================================================================
--- lmi/trunk/mec_input.cpp 2010-03-21 11:33:49 UTC (rev 4797)
+++ lmi/trunk/mec_input.cpp 2010-03-21 12:40:30 UTC (rev 4798)
@@ -27,6 +27,7 @@
#endif // __BORLANDC__
#include "mec_input.hpp"
+#include "xml_serializable.tpp"
#include "alert.hpp"
#include "database.hpp"
@@ -46,6 +47,8 @@
#include <string>
#include <vector>
+template class xml_serializable<mec_input>;
+
namespace
{
template<typename T>
@@ -119,10 +122,10 @@
}
mec_input::mec_input(mec_input const& z)
- :obstruct_slicing<mec_input>()
- ,xml_serializable()
- ,MvcModel()
- ,MemberSymbolTable<mec_input>()
+ :obstruct_slicing <mec_input>()
+ ,xml_serializable <mec_input>()
+ ,MvcModel ()
+ ,MemberSymbolTable <mec_input>()
{
AscribeMembers();
std::vector<std::string>::const_iterator i;
Modified: lmi/trunk/mec_input.hpp
===================================================================
--- lmi/trunk/mec_input.hpp 2010-03-21 11:33:49 UTC (rev 4797)
+++ lmi/trunk/mec_input.hpp 2010-03-21 12:40:30 UTC (rev 4798)
@@ -73,11 +73,11 @@
/// calculations are rewritten.
class LMI_SO mec_input
- :virtual private obstruct_slicing<mec_input>
- ,virtual public xml_serializable
- ,public MvcModel
- ,public MemberSymbolTable<mec_input>
- ,private boost::equality_comparable<mec_input>
+ :virtual private obstruct_slicing <mec_input>
+ , public xml_serializable <mec_input>
+ , public MvcModel
+ , public MemberSymbolTable <mec_input>
+ , private boost::equality_comparable <mec_input>
{
public:
mec_input();
Modified: lmi/trunk/mec_state.cpp
===================================================================
--- lmi/trunk/mec_state.cpp 2010-03-21 11:33:49 UTC (rev 4797)
+++ lmi/trunk/mec_state.cpp 2010-03-21 12:40:30 UTC (rev 4798)
@@ -27,6 +27,7 @@
#endif // __BORLANDC__
#include "mec_state.hpp"
+#include "xml_serializable.tpp"
#include "alert.hpp"
#include "miscellany.hpp" // htmlize(), lmi_array_size()
@@ -43,6 +44,8 @@
#include <sstream>
#include <vector>
+template class xml_serializable<mec_state>;
+
/// Initialize all ascribed members to zero.
mec_state::mec_state()
@@ -56,9 +59,9 @@
}
mec_state::mec_state(mec_state const& z)
- :obstruct_slicing<mec_state>()
- ,xml_serializable()
- ,MemberSymbolTable<mec_state>()
+ :obstruct_slicing <mec_state>()
+ ,xml_serializable <mec_state>()
+ ,MemberSymbolTable <mec_state>()
{
AscribeMembers();
std::vector<std::string>::const_iterator i;
Modified: lmi/trunk/mec_state.hpp
===================================================================
--- lmi/trunk/mec_state.hpp 2010-03-21 11:33:49 UTC (rev 4797)
+++ lmi/trunk/mec_state.hpp 2010-03-21 12:40:30 UTC (rev 4798)
@@ -48,10 +48,10 @@
/// 'A*_' is reserved in case it's wanted later--e.g., for arguments.
class LMI_SO mec_state
- :virtual private obstruct_slicing<mec_state>
- ,virtual public xml_serializable
- ,public MemberSymbolTable<mec_state>
- ,private boost::equality_comparable<mec_state>
+ :virtual private obstruct_slicing <mec_state>
+ , public xml_serializable <mec_state>
+ , public MemberSymbolTable <mec_state>
+ , private boost::equality_comparable <mec_state>
{
friend class Irc7702A;
Modified: lmi/trunk/objects.make
===================================================================
--- lmi/trunk/objects.make 2010-03-21 11:33:49 UTC (rev 4797)
+++ lmi/trunk/objects.make 2010-03-21 12:40:30 UTC (rev 4798)
@@ -237,7 +237,6 @@
timer.o \
tn_range_types.o \
xml_lmi.o \
- xml_serializable.o \
yare_input.o \
################################################################################
@@ -422,7 +421,6 @@
tn_range_types.o \
timer.o \
xml_lmi.o \
- xml_serializable.o \
yare_input.o \
libgpt.a libgpt$(SHREXT): EXTRA_LDFLAGS =
@@ -672,7 +670,6 @@
timer.o \
tn_range_types.o \
xml_lmi.o \
- xml_serializable.o \
yare_input.o \
irc7702a_test$(EXEEXT): \
@@ -685,7 +682,6 @@
miscellany.o \
stratified_algorithms.o \
xml_lmi.o \
- xml_serializable.o \
istream_to_string_test$(EXEEXT): \
$(common_test_objects) \
Deleted: lmi/trunk/xml_serializable.cpp
===================================================================
--- lmi/trunk/xml_serializable.cpp 2010-03-21 11:33:49 UTC (rev 4797)
+++ lmi/trunk/xml_serializable.cpp 2010-03-21 12:40:30 UTC (rev 4798)
@@ -1,34 +0,0 @@
-// Mixin for xml serialization.
-//
-// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Gregory W. Chicares.
-//
-// This program is free software; you can redistribute it and/or modify
-// it under the terms of the GNU General Public License version 2 as
-// published by the Free Software Foundation.
-//
-// This program 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
-//
-// http://savannah.nongnu.org/projects/lmi
-// email: <address@hidden>
-// snail: Chicares, 186 Belle Woods Drive, Glastonbury CT 06033, USA
-
-// $Id$
-
-#ifdef __BORLANDC__
-# include "pchfile.hpp"
-# pragma hdrstop
-#endif // __BORLANDC__
-
-#include "xml_serializable.hpp"
-
-xml_serializable::~xml_serializable()
-{
-}
-
Modified: lmi/trunk/xml_serializable.hpp
===================================================================
--- lmi/trunk/xml_serializable.hpp 2010-03-21 11:33:49 UTC (rev 4797)
+++ lmi/trunk/xml_serializable.hpp 2010-03-21 12:40:30 UTC (rev 4798)
@@ -32,26 +32,32 @@
#include <string>
/// Derive from this mixin class to use its xml serialization.
+///
+/// Implicitly-declared special member functions do the right thing.
+template<typename T>
class LMI_SO xml_serializable
{
public:
- virtual ~xml_serializable() = 0;
+ virtual ~xml_serializable();
virtual void read (xml::element const&) = 0;
virtual void write(xml::element&) const = 0;
+ private:
virtual int class_version() const = 0;
virtual std::string xml_root_name() const = 0;
};
-inline xml::element const& operator>>(xml::element const& x, xml_serializable&
z)
+template<typename T>
+inline xml::element const& operator>>(xml::element const& x,
xml_serializable<T>& z)
{
z.read(x);
return x;
}
-inline xml::element& operator<<(xml::element& x, xml_serializable const& z)
+template<typename T>
+inline xml::element& operator<<(xml::element& x, xml_serializable<T> const& z)
{
z.write(x);
return x;
Added: lmi/trunk/xml_serializable.tpp
===================================================================
--- lmi/trunk/xml_serializable.tpp (rev 0)
+++ lmi/trunk/xml_serializable.tpp 2010-03-21 12:40:30 UTC (rev 4798)
@@ -0,0 +1,35 @@
+// Mixin for xml serialization.
+//
+// Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Gregory W. Chicares.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2 as
+// published by the Free Software Foundation.
+//
+// This program 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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
+//
+// http://savannah.nongnu.org/projects/lmi
+// email: <address@hidden>
+// snail: Chicares, 186 Belle Woods Drive, Glastonbury CT 06033, USA
+
+// $Id$
+
+#ifdef __BORLANDC__
+# include "pchfile.hpp"
+# pragma hdrstop
+#endif // __BORLANDC__
+
+#include "xml_serializable.hpp"
+
+template<typename T>
+xml_serializable<T>::~xml_serializable()
+{
+}
+
Property changes on: lmi/trunk/xml_serializable.tpp
___________________________________________________________________
Added: svn:keywords
+ Id
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [lmi-commits] [4798] Use CRTP, preferring nonvirtual inheritance,
Greg Chicares <=