Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 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 | |
| 6 | // See http://www.boost.org/libs/test for the library home page. |
| 7 | // |
| 8 | // File : $RCSfile$ |
| 9 | // |
| 10 | // Version : $Revision: 54633 $ |
| 11 | // |
| 12 | // Description : defines model of parameter with single char name |
| 13 | // *************************************************************************** |
| 14 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 15 | #ifndef NDNBOOST_RT_CLA_CHAR_PARAMETER_HPP_062604GER |
| 16 | #define NDNBOOST_RT_CLA_CHAR_PARAMETER_HPP_062604GER |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 17 | |
| 18 | // Boost.Runtime.Parameter |
| 19 | #include <ndnboost/test/utils/runtime/config.hpp> |
| 20 | #include <ndnboost/test/utils/runtime/validation.hpp> |
| 21 | |
| 22 | #include <ndnboost/test/utils/runtime/cla/basic_parameter.hpp> |
| 23 | #include <ndnboost/test/utils/runtime/cla/id_policy.hpp> |
| 24 | |
| 25 | namespace ndnboost { |
| 26 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 27 | namespace NDNBOOST_RT_PARAM_NAMESPACE { |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 28 | |
| 29 | namespace cla { |
| 30 | |
| 31 | // ************************************************************************** // |
| 32 | // ************** char_name_policy ************** // |
| 33 | // ************************************************************************** // |
| 34 | |
| 35 | class char_name_policy : public basic_naming_policy { |
| 36 | public: |
| 37 | // Constructor |
| 38 | char_name_policy(); |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 39 | NDNBOOST_RT_PARAM_UNNEEDED_VIRTUAL ~char_name_policy() {} |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 40 | |
| 41 | // policy interface |
| 42 | virtual bool conflict_with( identification_policy const& ) const; |
| 43 | |
| 44 | // Accept modifier |
| 45 | template<typename Modifier> |
| 46 | void accept_modifier( Modifier const& m ) |
| 47 | { |
| 48 | basic_naming_policy::accept_modifier( m ); |
| 49 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 50 | NDNBOOST_RT_PARAM_VALIDATE_LOGIC( p_name->size() <= 1, "Invalid parameter name " << p_name ); |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 51 | } |
| 52 | }; |
| 53 | |
| 54 | // ************************************************************************** // |
| 55 | // ************** runtime::cla::char_parameter ************** // |
| 56 | // ************************************************************************** // |
| 57 | |
| 58 | template<typename T> |
| 59 | class char_parameter_t : public basic_parameter<T,char_name_policy> { |
| 60 | typedef basic_parameter<T,char_name_policy> base; |
| 61 | public: |
| 62 | // Constructors |
| 63 | explicit char_parameter_t( char_type name ) : base( cstring( &name, 1 ) ) {} |
| 64 | }; |
| 65 | |
| 66 | //____________________________________________________________________________// |
| 67 | |
| 68 | template<typename T> |
| 69 | inline shared_ptr<char_parameter_t<T> > |
| 70 | char_parameter( char_type name ) |
| 71 | { |
| 72 | return shared_ptr<char_parameter_t<T> >( new char_parameter_t<T>( name ) ); |
| 73 | } |
| 74 | |
| 75 | //____________________________________________________________________________// |
| 76 | |
| 77 | inline shared_ptr<char_parameter_t<cstring> > |
| 78 | char_parameter( char_type name ) |
| 79 | { |
| 80 | return shared_ptr<char_parameter_t<cstring> >( new char_parameter_t<cstring>( name ) ); |
| 81 | } |
| 82 | |
| 83 | //____________________________________________________________________________// |
| 84 | |
| 85 | } // namespace cla |
| 86 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 87 | } // namespace NDNBOOST_RT_PARAM_NAMESPACE |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 88 | |
| 89 | } // namespace ndnboost |
| 90 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 91 | #ifndef NDNBOOST_RT_PARAM_OFFLINE |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 92 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 93 | # define NDNBOOST_RT_PARAM_INLINE inline |
Jeff Thompson | ef2d5a4 | 2013-08-22 19:09:24 -0700 | [diff] [blame] | 94 | # include <ndnboost/test/utils/runtime/cla/char_parameter.ipp> |
| 95 | |
| 96 | #endif |
| 97 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 98 | #endif // NDNBOOST_RT_CLA_CHAR_PARAMETER_HPP_062604GER |