blob: d95b95b0a638f7003eec962dd13b575356dd5639 [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 parameter with single char name
13// ***************************************************************************
14
15#ifndef BOOST_RT_CLA_CHAR_PARAMETER_HPP_062604GER
16#define BOOST_RT_CLA_CHAR_PARAMETER_HPP_062604GER
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
25namespace ndnboost {
26
27namespace BOOST_RT_PARAM_NAMESPACE {
28
29namespace cla {
30
31// ************************************************************************** //
32// ************** char_name_policy ************** //
33// ************************************************************************** //
34
35class char_name_policy : public basic_naming_policy {
36public:
37 // Constructor
38 char_name_policy();
39 BOOST_RT_PARAM_UNNEEDED_VIRTUAL ~char_name_policy() {}
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
50 BOOST_RT_PARAM_VALIDATE_LOGIC( p_name->size() <= 1, "Invalid parameter name " << p_name );
51 }
52};
53
54// ************************************************************************** //
55// ************** runtime::cla::char_parameter ************** //
56// ************************************************************************** //
57
58template<typename T>
59class char_parameter_t : public basic_parameter<T,char_name_policy> {
60 typedef basic_parameter<T,char_name_policy> base;
61public:
62 // Constructors
63 explicit char_parameter_t( char_type name ) : base( cstring( &name, 1 ) ) {}
64};
65
66//____________________________________________________________________________//
67
68template<typename T>
69inline shared_ptr<char_parameter_t<T> >
70char_parameter( char_type name )
71{
72 return shared_ptr<char_parameter_t<T> >( new char_parameter_t<T>( name ) );
73}
74
75//____________________________________________________________________________//
76
77inline shared_ptr<char_parameter_t<cstring> >
78char_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
87} // namespace BOOST_RT_PARAM_NAMESPACE
88
89} // namespace ndnboost
90
91#ifndef BOOST_RT_PARAM_OFFLINE
92
93# define BOOST_RT_PARAM_INLINE inline
94# include <ndnboost/test/utils/runtime/cla/char_parameter.ipp>
95
96#endif
97
98#endif // BOOST_RT_CLA_CHAR_PARAMETER_HPP_062604GER