mirror of
https://github.com/mat007/turtle.git
synced 2026-06-22 12:13:43 +00:00
Changed project layout to boost layout
git-svn-id: https://svn.code.sf.net/p/turtle/code/trunk@459 860be788-9bd5-4423-9f1e-828f051e677b
This commit is contained in:
parent
cb6204b399
commit
b22842eade
89 changed files with 353 additions and 295 deletions
68
turtle/sequence.hpp
Normal file
68
turtle/sequence.hpp
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
//
|
||||
// Copyright Mathieu Champlon 2008
|
||||
//
|
||||
// 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)
|
||||
//
|
||||
// See http://turtle.sf.net for documentation.
|
||||
|
||||
#ifndef MOCK_SEQUENCE_HPP_INCLUDED
|
||||
#define MOCK_SEQUENCE_HPP_INCLUDED
|
||||
|
||||
#include <boost/noncopyable.hpp>
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
|
||||
namespace mock
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
class sequence_impl : private boost::noncopyable
|
||||
{
|
||||
public:
|
||||
void add( void* e )
|
||||
{
|
||||
elements_.push_back( e );
|
||||
}
|
||||
void remove( void* e )
|
||||
{
|
||||
elements_.erase( std::remove( elements_.begin(),
|
||||
elements_.end(), e ), elements_.end() );
|
||||
}
|
||||
|
||||
bool is_valid( const void* e ) const
|
||||
{
|
||||
return std::find( elements_.begin(), elements_.end(), e )
|
||||
!= elements_.end();
|
||||
}
|
||||
|
||||
void invalidate( const void* e )
|
||||
{
|
||||
elements_it it =
|
||||
std::find( elements_.begin(), elements_.end(), e );
|
||||
if( it != elements_.end() )
|
||||
elements_.erase( elements_.begin(), it );
|
||||
}
|
||||
|
||||
private:
|
||||
typedef std::vector< void* > elements_type;
|
||||
typedef elements_type::iterator elements_it;
|
||||
|
||||
elements_type elements_;
|
||||
};
|
||||
}
|
||||
|
||||
class sequence
|
||||
{
|
||||
public:
|
||||
sequence()
|
||||
: impl_( new detail::sequence_impl() )
|
||||
{}
|
||||
|
||||
boost::shared_ptr< detail::sequence_impl > impl_;
|
||||
};
|
||||
}
|
||||
|
||||
#endif // MOCK_SEQUENCE_HPP_INCLUDED
|
||||
Loading…
Add table
Add a link
Reference in a new issue