From 187d265680ebb0b0593952731f3148bd3158445f Mon Sep 17 00:00:00 2001 From: Jens Luedicke Date: Sun, 23 Jan 2011 23:58:26 +0100 Subject: [PATCH] Splitted up library headers. --- src/abstract_attribute.hpp | 49 ++++++++++++++++++++++ src/attribute.hpp | 77 ++++++++++++++++++++++++++++++++++ src/attributes.hpp | 84 +------------------------------------- 3 files changed, 127 insertions(+), 83 deletions(-) create mode 100644 src/abstract_attribute.hpp create mode 100644 src/attribute.hpp diff --git a/src/abstract_attribute.hpp b/src/abstract_attribute.hpp new file mode 100644 index 0000000..783c6cf --- /dev/null +++ b/src/abstract_attribute.hpp @@ -0,0 +1,49 @@ +//! \file abstract_attribute.hpp +//! \brief C++ Library (header-only). + +// abstract_attribute.hpp ----------------------------------------------------------// + +// +// Copyright Jens Luedicke 2010 +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +//----------------------------------------------------------------------------// + +#ifndef ABSTRACT_ATTRIBUTE_HPP +#define ABSTRACT_ATTRIBUTE_HPP + +#include + +//! +//! \class abstract_attribute +//! \brief Abstract base class for attributes. +//! +//! The class can't be instantiated. +//! +class abstract_attribute { +public: + + //! + //! \brief Constructor. + //! + abstract_attribute() {} + + //! + //! \brief Destructor. + //! + virtual ~abstract_attribute() {} + + //! + //! \brief Pure virtual method. + //! + //! This method needs to be implemented in classes derived from + //! \e abstract_attribute. + //! + //! + virtual void set_value(const std::string &value) = 0; +}; + +#endif /* ABSTRACT_ATTRIBUTE_HPP */ + diff --git a/src/attribute.hpp b/src/attribute.hpp new file mode 100644 index 0000000..823d3f2 --- /dev/null +++ b/src/attribute.hpp @@ -0,0 +1,77 @@ +//! \file attribute.hpp +//! \brief C++ Library (header-only). + +// attribute.hpp ----------------------------------------------------------// + +// +// Copyright Jens Luedicke 2010 +// +// Distributed under the Boost Software License, Version 1.0. (See accompanying +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + +//----------------------------------------------------------------------------// + +#ifndef ATTRIBUTE_HPP +#define ATTRIBUTE_HPP + +#include "abstract_attribute.hpp" +#include "string2type.hpp" + +#include +#include +#include + +//! +//! \class attribute +//! \brief attribute class. +//! +//! Wraps a reference to an object of type T. +//! +//! \tparam T Assignable type. +//! +template +class attribute : public abstract_attribute { +public: + //! + //! \brief Constructor + //! + //! Constructs an attribute object for \e object. \e object needs to + //! be an Assignable type. + //! + //! \param object Reference to object of type T. + //! + explicit attribute(T &object) + : abstract_attribute() + , reference(object) { + BOOST_CONCEPT_ASSERT((boost::Assignable)); + } + + //! + //! \brief Destructor + //! + virtual ~attribute() { + } + + //! + //! \brief Implementation of set_value method. + //! + //! This method assigns \e value to \e this. + //! + //! \param value String + //! + virtual void set_value(const std::string &value) { + reference = string2type::convert(value); + } + + //! + //! \brief Implementation of get_value method. + //! + virtual T& get_value() const { + return reference; + } + +private: + T &reference; //!< Reference to T object. +}; + +#endif /* ATTRIBUTE_HPP */ diff --git a/src/attributes.hpp b/src/attributes.hpp index fc88494..6f87fb1 100644 --- a/src/attributes.hpp +++ b/src/attributes.hpp @@ -14,7 +14,7 @@ #ifndef SETTABLE_HPP #define SETTABLE_HPP -#include "string2type.hpp" +#include "attribute.hpp" #include #include @@ -23,88 +23,6 @@ #include #include -//! -//! \class abstract_attribute -//! \brief Abstract base class for attributes. -//! -//! The class can't be instantiated. -//! -class abstract_attribute { -public: - - //! - //! \brief Constructor. - //! - abstract_attribute() {} - - //! - //! \brief Destructor. - //! - virtual ~abstract_attribute() {} - - //! - //! \brief Pure virtual method. - //! - //! This method needs to be implemented in classes derived from - //! \e abstract_attribute. - //! - //! - virtual void set_value(const std::string &value) = 0; -}; - -//! -//! \class attribute -//! \brief attribute class. -//! -//! Wraps a reference to an object of type T. -//! -//! \tparam T Assignable type. -//! -template -class attribute : public abstract_attribute { -public: - //! - //! \brief Constructor - //! - //! Constructs an attribute object for \e object. \e object needs to - //! be an Assignable type. - //! - //! \param object Reference to object of type T. - //! - explicit attribute(T &object) - : abstract_attribute() - , reference(object) { - BOOST_CONCEPT_ASSERT((boost::Assignable)); - } - - //! - //! \brief Destructor - //! - virtual ~attribute() { - } - - //! - //! \brief Implementation of set_value method. - //! - //! This method assigns \e value to \e this. - //! - //! \param value String - //! - virtual void set_value(const std::string &value) { - reference = string2type::convert(value); - } - - //! - //! \brief Implementation of get_value method. - //! - virtual T& get_value() const { - return reference; - } - -private: - T &reference; //!< Reference to T object. -}; - //! //! \brief Convenience macro for attribute registration. //!