ignore_oprimitive.hpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // (C) Copyright 2005 Matthias Troyer
  2. // Use, modification and distribution is subject to the Boost Software
  3. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. // Authors: Matthias Troyer
  6. #ifndef BOOST_MPI_DETAIL_IGNORE_OPRIMITIVE_HPP
  7. #define BOOST_MPI_DETAIL_IGNORE_OPRIMITIVE_HPP
  8. #include <boost/config.hpp>
  9. #include <boost/mpi/datatype.hpp>
  10. #include <boost/serialization/array.hpp>
  11. namespace boost { namespace mpi { namespace detail {
  12. /// @brief a minimal output archive, which ignores any save
  13. ///
  14. /// This class implements a minimal output archive, probably an output archive
  15. /// archetype, doing nothing at any save. It's use, besides acting as an
  16. /// archetype is as a base class to implement special archives that ignore
  17. /// saving of most types
  18. class ignore_oprimitive
  19. {
  20. public:
  21. /// a trivial default constructor
  22. ignore_oprimitive()
  23. {}
  24. /// don't do anything when saving binary data
  25. void save_binary(const void *, std::size_t )
  26. {
  27. }
  28. /// don't do anything when saving arrays
  29. template<class T>
  30. void save_array(serialization::array_wrapper<T> const&, unsigned int )
  31. {
  32. }
  33. typedef is_mpi_datatype<mpl::_1> use_array_optimization;
  34. #ifndef BOOST_NO_MEMBER_TEMPLATE_FRIENDS
  35. friend class archive::save_access;
  36. protected:
  37. #else
  38. public:
  39. #endif
  40. /// don't do anything when saving primitive types
  41. template<class T>
  42. void save(const T &)
  43. {
  44. }
  45. };
  46. } } } // end namespace boost::mpi::detail
  47. #endif // BOOST_MPI_DETAIL_IGNORE_OPRIMITIVE_HPP