blob: ff9abca77b4e3aebe230cbbd5b83b7f3b0bb8c5d [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
Jeff Thompson3d613fd2013-10-15 15:39:04 -070015#ifndef NDNBOOST_RT_CLA_CHAR_PARAMETER_HPP_062604GER
16#define NDNBOOST_RT_CLA_CHAR_PARAMETER_HPP_062604GER
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070017
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
Jeff Thompson3d613fd2013-10-15 15:39:04 -070027namespace NDNBOOST_RT_PARAM_NAMESPACE {
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070028
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();
Jeff Thompson3d613fd2013-10-15 15:39:04 -070039 NDNBOOST_RT_PARAM_UNNEEDED_VIRTUAL ~char_name_policy() {}
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070040
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 Thompson3d613fd2013-10-15 15:39:04 -070050 NDNBOOST_RT_PARAM_VALIDATE_LOGIC( p_name->size() <= 1, "Invalid parameter name " << p_name );
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070051 }
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
Jeff Thompson3d613fd2013-10-15 15:39:04 -070087} // namespace NDNBOOST_RT_PARAM_NAMESPACE
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070088
89} // namespace ndnboost
90
Jeff Thompson3d613fd2013-10-15 15:39:04 -070091#ifndef NDNBOOST_RT_PARAM_OFFLINE
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070092
Jeff Thompson3d613fd2013-10-15 15:39:04 -070093# define NDNBOOST_RT_PARAM_INLINE inline
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070094# include <ndnboost/test/utils/runtime/cla/char_parameter.ipp>
95
96#endif
97
Jeff Thompson3d613fd2013-10-15 15:39:04 -070098#endif // NDNBOOST_RT_CLA_CHAR_PARAMETER_HPP_062604GER