blob: 3adbb854595f37eb9b5700d128c7800bb06c8158 [file] [log] [blame]
Jeff Thompsonef2d5a42013-08-22 19:09:24 -07001// (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 <ndnboost/test/utils/runtime/config.hpp>
20
21#include <ndnboost/test/utils/runtime/cla/named_parameter.hpp>
22#include <ndnboost/test/utils/runtime/cla/char_parameter.hpp>
23
24namespace ndnboost {
25
26namespace BOOST_RT_PARAM_NAMESPACE {
27
28namespace cla {
29
30// ************************************************************************** //
31// ************** dual_name_policy ************** //
32// ************************************************************************** //
33
34class dual_name_policy : public dual_id_policy<dual_name_policy,string_name_policy,char_name_policy> {
35public:
36 dual_name_policy();
37
38 // Accept modifier
39 template<typename Modifier>
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 }
59private:
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
69template<typename T>
70class dual_name_parameter_t : public basic_parameter<T,dual_name_policy> {
71 typedef basic_parameter<T,dual_name_policy> base;
72public:
73 // Constructors
74 explicit dual_name_parameter_t( cstring name ) : base( name ) {}
75};
76
77//____________________________________________________________________________//
78
79BOOST_RT_CLA_NAMED_PARAM_GENERATORS( dual_name_parameter )
80
81//____________________________________________________________________________//
82
83} // namespace cla
84
85} // namespace BOOST_RT_PARAM_NAMESPACE
86
87} // namespace ndnboost
88
89#ifndef BOOST_RT_PARAM_OFFLINE
90
91# define BOOST_RT_PARAM_INLINE inline
92# include <ndnboost/test/utils/runtime/cla/dual_name_parameter.ipp>
93
94#endif
95
96#endif // BOOST_RT_CLA_DUAL_NAME_PARAMETER_HPP_062604GER