NCBI C++ ToolKit
PluginCommand.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: PluginCommand.cpp 14666 2007-07-09 13:40:22Z dicuccio $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Author: Mike DiCuccio, Denis Vakatov, Anatoliy Kuznetsov
27  *
28  * File Description:
29  * CPluginCommand -- defines an interface for managing a single command
30  * passed in to a plugin
31  *
32  * Remark:
33  * This code was originally generated by application DATATOOL
34  * using specifications from the data definition file
35  * 'plugin.asn'.
36  */
37 
38 // standard includes
39 
40 // generated includes
41 #include <ncbi_pch.hpp>
44 
45 // generated classes
46 
48 
49 BEGIN_objects_SCOPE // namespace ncbi::objects::
50 
51 // destructor
53 {
54 }
55 
56 
58 {
60 }
61 
62 
63 // operator[] for indexing based on named argument
64 // this will throw if the named argument isn't found
65 const CPluginArg& CPluginCommand::operator[](const string& name) const
66 {
67  return GetArgs()[ name ];
68 }
69 
71 {
72  return SetArgs()[ name ];
73 }
74 
75 
76 // verify whether a named argument exists
77 bool CPluginCommand::HasArgument(const string& name) const
78 {
79  return GetArgs().HasArgument(name);
80 }
81 
82 /// Delete an existing argument
83 void CPluginCommand::RemoveArgument(const string& arg_name)
84 {
85  SetArgs().RemoveArgument(arg_name);
86 }
87 
88 
89 
90 // add a named argument. This argument is required, and has no default
91 // value. Attempts to access the value without setting the value will
92 // result in an exception being thrown.
94  const string& desc,
96  CPluginArg::TData::E_Choice single_or_array)
97 {
98  return SetArgs().AddArgument(name, desc, type, single_or_array);
99 }
100 
101 
102 // add a named argument. This argument is required, and has no default
103 // value. Attempts to access the value without setting the value will
104 // result in an exception being thrown.
106  const string& desc,
107  const CTypeInfo* type,
108  CPluginArg::TData::E_Choice single_or_array)
109 {
110  return SetArgs().AddArgument(name, desc, type, single_or_array);
111 }
112 
113 
115  const string& desc)
116 {
117  return SetArgs().AddFlag(name, desc);
118 }
119 
120 
121 // Add a default argument to the set of arguments. This function creates a
122 // named argument with a default value of type string.
124  const string& desc,
126  const string& val)
127 {
128  return SetArgs().AddDefaultArgument(name, desc, type, val);
129 }
130 
131 
133  const string& desc,
134  bool val)
135 {
136  return SetArgs().AddDefaultFlag(name, desc, val);
137 }
138 
139 
140 // add an optional argument to the set of arguments. This supports an
141 // optional default value argument. For non-built-in types, the default
142 // value is ignored.
144  const string& desc,
147 {
148  return SetArgs().AddOptionalArgument(name, desc, type, s_or_a);
149 }
150 
151 
153  const string& desc,
154  const CTypeInfo* type,
156 {
157  return SetArgs().AddOptionalArgument(name, desc, type, s_or_a);
158 }
159 
160 
161 // add a constraint to a named argument
162 void CPluginCommand::SetConstraint(const string& name,
163  CPluginValueConstraint& constraint)
164 {
165  SetArgs().SetConstraint(name, constraint);
166 }
167 
168 
169 void CPluginCommand::AddConstraint(const string& name,
170  CPluginValueConstraint& constraint)
171 {
172  SetArgs().AddConstraint(name, constraint);
173 }
174 
175 
176 END_objects_SCOPE // namespace ncbi::objects::
177 
179 
180 /* Original file checksum: lines: 64, chars: 1885, CRC32: 56e32803 */
CPluginArg & AddFlag(const string &name, const string &desc)
Add a flag value.
void RemoveArgument(const string &arg_name)
Delete an existing argument.
void SetConstraint(const string &name, CPluginValueConstraint &constraint)
Set the constraint of a named argument.
bool HasArgument(const string &name) const
HasArgument() verifies that an argument exists.
CPluginArg & AddArgument(const string &name, const string &desc, CPluginArg::EType type, CPluginArg::TData::E_Choice single_or_array=CPluginArg::TData::e_Single)
add a named argument.
void AddConstraint(const string &name, CPluginValueConstraint &constraint)
Add a constraint to a named argument.
void ClearObjects()
Clear all objects from object-based arguments.
CPluginArg & AddOptionalArgument(const string &name, const string &description, CPluginArg::EType type, CPluginArg::TData::E_Choice single_or_array=CPluginArg::TData::e_Single)
add an optional argument to the set of arguments.
CPluginArg & AddDefaultArgument(const string &name, const string &description, CPluginArg::EType type, const string &val)
Add a default argument to the set of arguments.
CPluginArg & AddDefaultFlag(const string &name, const string &desc, bool val)
Add a flag argument with a default value.
EType
enumerated list of types we support
Definition: PluginArg.hpp:69
CPluginArg & AddDefaultArgument(const string &name, const string &desc, CPluginArg::EType type, const string &val)
Add a default argument to the set of arguments.
void AddConstraint(const string &name, CPluginValueConstraint &constraint)
add a constraint to a named argument.
CPluginArg & AddFlag(const string &name, const string &desc)
Add a flag value. This is a helper API.
CPluginArg & AddDefaultFlag(const string &name, const string &desc, bool val)
Add a flag argument with a default value. This is a helper API.
bool HasArgument(const string &name) const
HasArgument() can be used to verify whether a named argument exists.
void RemoveArgument(const string &arg_name)
Delete an existing argument.
void ClearObjects()
Clear all objects from object-based arguments.
const CPluginArg & operator[](const string &name) const
operator[] for indexing based on named argument this will throw if the named argument isn't found
~CPluginCommand(void)
destructor
void SetConstraint(const string &name, CPluginValueConstraint &constraint)
set the constraint for a named argument, removing all previous constraints
CPluginArg & AddOptionalArgument(const string &name, const string &desc, CPluginArg::EType type, CPluginArg::TData::E_Choice single_or_array=CPluginArg::TData::e_Single)
add an optional argument to the set of arguments.
CPluginArg & AddArgument(const string &name, const string &desc, CPluginArg::EType type, CPluginArg::TData::E_Choice single_or_array=CPluginArg::TData::e_Single)
add a named argument.
CTypeInfo class contains all information about C++ types (both basic and classes): members and layout...
Definition: typeinfo.hpp:76
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
TArgs & SetArgs(void)
Assign a value to Args data member.
E_Choice
Choice variants.
Definition: PluginArg_.hpp:115
const TArgs & GetArgs(void) const
Get the Args member data.
Definition: type.c:6
Modified on Thu Apr 25 08:20:32 2024 by modify_doxy.py rev. 669887