basic_parameter.hpp 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. // (C) Copyright Gennadiy Rozental 2005-2008.
  2. // Use, modification, and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  5. // See http://www.boost.org/libs/test for the library home page.
  6. //
  7. // File : $RCSfile$
  8. //
  9. // Version : $Revision: 54633 $
  10. //
  11. // Description : generic custom parameter generator
  12. // ***************************************************************************
  13. #ifndef BOOST_RT_CLA_BASIC_PARAMETER_HPP_062604GER
  14. #define BOOST_RT_CLA_BASIC_PARAMETER_HPP_062604GER
  15. // Boost.Runtime.Parameter
  16. #include <boost/test/utils/runtime/config.hpp>
  17. #include <boost/test/utils/runtime/cla/typed_parameter.hpp>
  18. // Boost.Test
  19. #include <boost/test/utils/rtti.hpp>
  20. // Boost
  21. #include <boost/utility/base_from_member.hpp>
  22. namespace boost {
  23. namespace BOOST_RT_PARAM_NAMESPACE {
  24. namespace cla {
  25. // ************************************************************************** //
  26. // ************** runtime::cla::basic_parameter ************** //
  27. // ************************************************************************** //
  28. template<typename T, typename IdPolicy>
  29. class basic_parameter : private base_from_member<IdPolicy>, public typed_parameter<T> {
  30. public:
  31. // Constructors
  32. explicit basic_parameter( cstring n )
  33. : base_from_member<IdPolicy>()
  34. , typed_parameter<T>( base_from_member<IdPolicy>::member )
  35. {
  36. this->accept_modifier( name = n );
  37. }
  38. // parameter properties modification
  39. template<typename Modifier>
  40. void accept_modifier( Modifier const& m )
  41. {
  42. typed_parameter<T>::accept_modifier( m );
  43. base_from_member<IdPolicy>::member.accept_modifier( m );
  44. }
  45. };
  46. //____________________________________________________________________________//
  47. #define BOOST_RT_CLA_NAMED_PARAM_GENERATORS( param_type ) \
  48. template<typename T> \
  49. inline shared_ptr<param_type ## _t<T> > \
  50. param_type( cstring name = cstring() ) \
  51. { \
  52. return shared_ptr<param_type ## _t<T> >( new param_type ## _t<T>( name ) ); \
  53. } \
  54. \
  55. inline shared_ptr<param_type ## _t<cstring> > \
  56. param_type( cstring name = cstring() ) \
  57. { \
  58. return shared_ptr<param_type ## _t<cstring> >( new param_type ## _t<cstring>( name ) ); \
  59. } \
  60. /**/
  61. //____________________________________________________________________________//
  62. } // namespace cla
  63. } // namespace BOOST_RT_PARAM_NAMESPACE
  64. } // namespace boost
  65. #endif // BOOST_RT_CLA_BASIC_PARAMETER_HPP_062604GER