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 generic parameter with dual naming
13 // ***************************************************************************
14 
15 #ifndef BOOST_RT_CLA_DUAL_NAME_PARAMETER_HPP_062604GER
16 #define BOOST_RT_CLA_DUAL_NAME_PARAMETER_HPP_062604GER
17 
18 // Boost.Runtime.Parameter
19 #include <boost/test/utils/runtime/config.hpp>
20 
21 #include <boost/test/utils/runtime/cla/named_parameter.hpp>
22 #include <boost/test/utils/runtime/cla/char_parameter.hpp>
23 
24 namespace boost {
25 
26 namespace BOOST_RT_PARAM_NAMESPACE {
27 
28 namespace cla {
29 
30 // ************************************************************************** //
31 // **************               dual_name_policy               ************** //
32 // ************************************************************************** //
33 
34 class dual_name_policy : public dual_id_policy<dual_name_policy,string_name_policy,char_name_policy> {
35 public:
36     dual_name_policy();
37 
38     // Accept modifier
39     template<typename Modifier>
accept_modifier(Modifier const & m)40     void    accept_modifier( Modifier const& m )
41     {
42         if( m.has( prefix ) ) {
43             set_prefix( m[prefix] );
44             m.erase( prefix );
45         }
46 
47         if( m.has( name ) ) {
48             set_name( m[name] );
49             m.erase( name );
50         }
51 
52         if( m.has( separator ) ) {
53             set_separator( m[separator] );
54             m.erase( separator );
55         }
56 
57         dual_id_policy<dual_name_policy,string_name_policy,char_name_policy>::accept_modifier( m );
58     }
59 private:
60     void    set_prefix( cstring );
61     void    set_name( cstring );
62     void    set_separator( cstring );
63 };
64 
65 // ************************************************************************** //
66 // **************       runtime::cla::dual_name_parameter      ************** //
67 // ************************************************************************** //
68 
69 template<typename T>
70 class dual_name_parameter_t : public basic_parameter<T,dual_name_policy> {
71     typedef basic_parameter<T,dual_name_policy> base;
72 public:
73     // Constructors
dual_name_parameter_t(cstring name)74     explicit    dual_name_parameter_t( cstring name ) : base( name ) {}
75 };
76 
77 //____________________________________________________________________________//
78 
79 BOOST_RT_CLA_NAMED_PARAM_GENERATORS( dual_name_parameter )
80 
81 //____________________________________________________________________________//
82 
83 } // namespace cla
84 
85 } // namespace BOOST_RT_PARAM_NAMESPACE
86 
87 } // namespace boost
88 
89 #ifndef BOOST_RT_PARAM_OFFLINE
90 
91 #  define BOOST_RT_PARAM_INLINE inline
92 #  include <boost/test/utils/runtime/cla/dual_name_parameter.ipp>
93 
94 #endif
95 
96 #endif // BOOST_RT_CLA_DUAL_NAME_PARAMETER_HPP_062604GER
97