diff --git a/build/vc100/turtle.vcxproj b/build/vc100/turtle.vcxproj index 536b960..c358010 100644 --- a/build/vc100/turtle.vcxproj +++ b/build/vc100/turtle.vcxproj @@ -50,6 +50,7 @@ + diff --git a/build/vc100/turtle.vcxproj.filters b/build/vc100/turtle.vcxproj.filters index 4a65982..13e2769 100644 --- a/build/vc100/turtle.vcxproj.filters +++ b/build/vc100/turtle.vcxproj.filters @@ -106,5 +106,8 @@ Source Files\detail + + Source Files + \ No newline at end of file diff --git a/turtle/object.hpp b/turtle/object.hpp index c375d6a..11180b9 100644 --- a/turtle/object.hpp +++ b/turtle/object.hpp @@ -9,16 +9,14 @@ #ifndef MOCK_OBJECT_HPP_INCLUDED #define MOCK_OBJECT_HPP_INCLUDED +#include "object_impl.hpp" #include "detail/root.hpp" -#include "detail/parent.hpp" #include "detail/type_name.hpp" -#include "detail/context.hpp" -#include "detail/child.hpp" #include -#include #include #include #include +#include namespace mock { @@ -26,73 +24,13 @@ namespace mock { public: object() - : impl_( new object_impl() ) + : impl_( new detail::object_impl() ) {} - protected: ~object() {} - - private: - class object_impl : public detail::context, public detail::verifiable, - public boost::enable_shared_from_this< object_impl > - { - public: - virtual void add( const void* /*p*/, detail::verifiable& v, - boost::unit_test::const_string instance, - const boost::optional< detail::type_name >& type, - boost::unit_test::const_string name ) - { - if( children_.empty() ) - mock::detail::root.add( *this ); - children_[ &v ].update( parent_, instance, type, name ); - } - virtual void add( detail::verifiable& v ) - { - group_.add( v ); - } - virtual void remove( detail::verifiable& v ) - { - group_.remove( v ); - children_.erase( &v ); - if( children_.empty() ) - mock::detail::root.remove( *this ); - } - - virtual void serialize( std::ostream& s, - const detail::verifiable& v ) const - { - children_cit it = children_.find( &v ); - if( it != children_.end() ) - s << it->second; - else - s << "?"; - } - - virtual bool verify() const - { - return group_.verify(); - } - virtual void reset() - { - boost::shared_ptr< object_impl > guard = shared_from_this(); - group_.reset(); - } - - private: - typedef std::map< - const detail::verifiable*, - detail::child - > children_t; - typedef children_t::const_iterator children_cit; - - detail::group group_; - detail::parent parent_; - children_t children_; - }; - public: - boost::shared_ptr< object_impl > impl_; + boost::shared_ptr< detail::object_impl > impl_; }; namespace detail diff --git a/turtle/object_impl.hpp b/turtle/object_impl.hpp new file mode 100644 index 0000000..4047154 --- /dev/null +++ b/turtle/object_impl.hpp @@ -0,0 +1,85 @@ +// http://turtle.sourceforge.net +// +// Copyright Mathieu Champlon 2012 +// +// 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 MOCK_OBJECT_IMPL_HPP_INCLUDED +#define MOCK_OBJECT_IMPL_HPP_INCLUDED + +#include "detail/root.hpp" +#include "detail/parent.hpp" +#include "detail/type_name.hpp" +#include "detail/context.hpp" +#include "detail/child.hpp" +#include +#include +#include +#include + +namespace mock +{ +namespace detail +{ + class object_impl : public detail::context, public detail::verifiable, + public boost::enable_shared_from_this< object_impl > + { + public: + virtual void add( const void* /*p*/, detail::verifiable& v, + boost::unit_test::const_string instance, + const boost::optional< detail::type_name >& type, + boost::unit_test::const_string name ) + { + if( children_.empty() ) + mock::detail::root.add( *this ); + children_[ &v ].update( parent_, instance, type, name ); + } + virtual void add( detail::verifiable& v ) + { + group_.add( v ); + } + virtual void remove( detail::verifiable& v ) + { + group_.remove( v ); + children_.erase( &v ); + if( children_.empty() ) + mock::detail::root.remove( *this ); + } + + virtual void serialize( std::ostream& s, + const detail::verifiable& v ) const + { + children_cit it = children_.find( &v ); + if( it != children_.end() ) + s << it->second; + else + s << "?"; + } + + virtual bool verify() const + { + return group_.verify(); + } + virtual void reset() + { + boost::shared_ptr< object_impl > guard = shared_from_this(); + group_.reset(); + } + + private: + typedef std::map< + const detail::verifiable*, + detail::child + > children_t; + typedef children_t::const_iterator children_cit; + + detail::group group_; + detail::parent parent_; + children_t children_; + }; +} +} // mock + +#endif // MOCK_OBJECT_IMPL_HPP_INCLUDED