1#ifndef DRAMA2_GITARG_INC
2#define DRAMA2_GITARG_INC
101 if ((
unsigned int)(
f1) & (
unsigned int)(
f2))
111 inline void ___CheckLockTaken(
112 const std::string &
func,
113 const std::string &
file,
111 inline void ___CheckLockTaken( {
…}
125 "Programming error - the program invoked a gitarg::Get() method (or constructor) without having taken the DRAMA lock. Please copy stack trace above to support.",
145 extern void __AddEnumPossiblities(
const Flags flags,
163 class EnumLookupClass {
222 template <
typename LookupClass,
typename EnumType>
class Enum {
231 void SetValue(
const unsigned int i) {
232 if (
i > lookupObject.GetMaxValue())
233 _value = InvalidValue();
241 return (
EnumType)(lookupObject.GetMaxValue()+1);
254 _value = InvalidValue();
307 :_value(InvalidValue()) {
339 Enum(
const sds::Id& Id,
340 const std::string &
Name=
"Argument1",
344 :_value(InvalidValue()) {
394 :_value(InvalidValue()) {
432 const std::string &
Name=
"Argument1",
436 :_value(InvalidValue()) {
488 "drama::gitarg::Enum type - use of Default string invalid, change to non-depreciated Get()/Constructor.");
520 void Get(
const sds::Id& Id,
521 const std::string &
Name=
"Argument1",
533 lookupObject.GetStringArray(),
"" ,
534 (
int)(
flags),
sizeof(
string),
string,&index,&
status);
539 "Failed to fetch Enumerated Argument from SDS",
543 __AddEnumPossiblities(
flags, lookupObject.GetStringArray(), &
except);
548 index =
static_cast<int>(
Default);
550 SetValue(
static_cast<unsigned>(index));
559 operator std::string()
const {
560 if (_value == InvalidValue())
562 "drama::gitarg::Enum value is invalid - was not initialised to a valid enum value.");
563 return lookupObject.GetStringArray()[
int(_value)];
615 template <
long int MinVal,
long int MaxVal,
long int DefaultVal=0>
class Real {
618 virtual const double * Range() {
663 const std::string &
Name=
"Argument1",
704 const std::string &
Name=
"Argument1",
752 const std::string &
Name=
"Argument1",
801 const std::string &
Name=
"Argument1",
840 const std::string &
Name=
"Argument1",
857 "Failed to fetch real number Argument from SDS",
900 const std::string &
Name=
"Argument1",
919 "Failed to fetch real number Argument from SDS",
963 virtual const long int * Range() {
1007 const std::string &
Name =
"Argument1",
1047 const std::string &
Name =
"Argument1",
1095 const std::string &
Name =
"Argument1",
1139 const std::string &
Name =
"Argument1",
1178 const std::string &
Name=
"Argument1",
1194 "Failed to fetch integer Argument from SDS",
1238 const std::string &
Name=
"Argument1",
1256 "Failed to fetch integer Argument from SDS",
1266 operator long int()
const {
1286 class String :
public std::string {
1287 using std::string::string;
1290 static const unsigned _DefaultStringLength = 100;
1292 void RawGet (
const sds::Id& Id,
const std::string &
Name,
1326 const std::string &
Name =
"Argument1",
1328 const std::string &
Default =
"",
1365 const std::string &
Name =
"Argument1",
1367 const std::string &
Default =
"",
1424 const std::string &
Name =
"Argument1",
1426 const std::string &
Default =
"",
1435 this->std::string::operator=(
str);
1444 this->std::string::operator=(
str);
1453 this->std::string::operator=(
s);
1463 this->std::string::operator=(
c);
1555 const std::string &
Name=
"Argument1",
1600 const std::string &
Name=
"Argument1",
1638 const std::string &
Name=
"Argument1",
1655 "Failed to fetch boolean Argument from SDS",
1665 operator bool()
const {
1694 class Id :
public sds::Id {
1696 bool _readFromFile =
false;
1697 bool _defaultUsed =
false;
1698 std::string _actualName;
1700 void UseDefaultIfReq(
const std::string &name,
1702 const std::string &fileName,
1700 void UseDefaultIfReq(
const std::string &name, {
…}
1705 const std::string &
mess);
1712 Id() : sds::
Id() { }
1772 const std::string &
Name=
"Argument1",
1774 const std::string
Default =
"",
1840 const std::string &
Name=
"Argument1",
1842 const std::string
Default =
"",
1906 const std::string &
Name=
"Argument1",
1908 const std::string
Default =
"",
1946 class Filename :
public String {
1983 const std::string &
Name =
"Argument1",
1985 const std::string &
Default =
"",
2027 const std::string &
Name =
"Argument1",
2029 const std::string &
Default =
"",
2087 const std::string &
Name =
"Argument1",
2089 const std::string &
Default =
"",
2186 typename std::enable_if<std::is_base_of<
ArgFlagVal,
2187 typename ContainerType::value_type>
::value>
::type* =
nullptr>
2192 const bool _ignoreCase;
2193 unsigned _theValue = 0;
2243 const unsigned First = 1,
2244 const unsigned Last = 0,
2276 const unsigned First = 1,
2290 "ArgFlags First argument position value of % is less then min of 1",
2296 "ArgFlags Last argument position value of % is less then First of %",
2307 for (
unsigned arg =
First; arg <
Last ; arg++)
2314 auto thisVal = _GetString(
Id, arg, _ignoreCase);
2328 for (
auto & flag : _validFlags)
2332 _theValue |= flag.flag;
2347 except.FmtWrite(
"Argument value at position %, \"%\", is not an acceptable flag value",
2350 AddFlagPossiblities(&
except);
2370 unsigned GetVal()
const {
2391 std::ostringstream
s;
2393 (*except) <<
"\n Accepted flags are:\n";
2395 for (
auto & flag : _validFlags)
2397 s << flag.name <<
", ";
2397 s << flag.name <<
", "; {
…}
2403 (*except) <<
str <<
'\n';
2407 (*except) <<
" Case is ignored.";
2407 (*except) <<
" Case is ignored."; {
…}
An Exception class for exceptions thrown by DRAMA V2 classes.
Definition exception.hh:162
unsigned Get(const sds::Id &Id, const unsigned First=1, unsigned Last=0, const bool FailOnInvalid=true)
Get argument flag value set from an SDS structure.
Definition gitarg.hh:2302
ArgFlags(const ContainerType &validFlagVals, const sds::Id &Id, const unsigned First=1, const unsigned Last=0, const bool FailOnInvalid=true, const bool IgnoreCase=true)
Constructor with the initial value set from an SDS structure.
Definition gitarg.hh:2268
ArgFlags(const ContainerType &validFlagVals, bool ignoreCase=true)
Constructor.
Definition gitarg.hh:2237
bool IsSet(unsigned flags) const
Determines whether the specified flags are set.
Definition gitarg.hh:2407
unsigned GetVal() const
Return the flags value - the mask of set bits.
Definition gitarg.hh:2397
This class is used to check for the existence of one or more flags in an SDS structure.
Definition gitarg.hh:2217
Bool(drama::thread::TAction *taction, const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const bool Default=false, const Flags flags=(Flags::Upper|Flags::Abbrev|Flags::KeepErr))
Constructor which constructs the value from an item in an SDS structure.
Definition gitarg.hh:1624
Bool operator=(const bool src)
Assign a bool to this gitarg::Bool item.
Definition gitarg.hh:1700
Bool(const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const bool Default=false, const Flags flags=(Flags::Upper|Flags::Abbrev|Flags::KeepErr))
Constructor which constructs the value from an item in an SDS structure.
Definition gitarg.hh:1580
virtual const GitLogStrType * Lookup()
Return a pointer to an array of enum strings equivalents.
Definition gitarg.hh:1536
virtual void Get(const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const bool Default=false, const Flags flags=(Flags::Upper|Flags::Abbrev|Flags::KeepErr))
Get the value of the object from an SDS struture.
Definition gitarg.hh:1663
virtual ~Bool()
Destructor.
Definition gitarg.hh:1638
Bool(bool initVal=false)
Simple constructor with a default value of false.
Definition gitarg.hh:1544
A class which reads Boolean values from SDS argument structures.
Definition gitarg.hh:1519
virtual ~EnumLookupClass()
Destructor.
Definition gitarg.hh:219
virtual unsigned int GetMaxValue() const =0
This function should return the maximum normal value of the enumerated value.
virtual const char ** GetStringArray() const =0
Return a pointer to an array of enum strings equivalents.
An interface for the lookup class template arguments to drama::gitarg::Enum.
Definition gitarg.hh:190
virtual ~Enum()
Destructor.
Definition gitarg.hh:609
Enum(EnumType InitialValue)
Constructor with initial value supplied.
Definition gitarg.hh:289
Enum(drama::thread::TAction *taction, const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const EnumType Default=static_cast< EnumType >(0), const Flags flags=Flags::Upper|Flags::Abbrev|Flags::KeepErr)
Constructor which constructs the value from an item in an SDS structure.
Definition gitarg.hh:456
void Get(const sds::Id &Id, const std::string &Name, const int Position, const std::string &Default, const Flags flags=Flags::Upper|Flags::Abbrev|Flags::KeepErr)
Get the value of the object from an SDS structure.
Definition gitarg.hh:505
Enum & operator=(const EnumType &rhs)
Allow an item of the underlying EnumType to be assigned to this object.
Definition gitarg.hh:602
Enum(const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const EnumType Default=static_cast< EnumType >(0), const Flags flags=Flags::Upper|Flags::Abbrev|Flags::KeepErr)
Constructor which constructs the value from an item in an SDS structure.
Definition gitarg.hh:366
Enum()
Default constructor for the object.
Definition gitarg.hh:280
void Get(const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const EnumType Default=static_cast< EnumType >(0), const Flags flags=Flags::Upper|Flags::Abbrev|Flags::KeepErr)
Get the value of the object from an SDS structure.
Definition gitarg.hh:547
A class which reads Enumerated values from a SDS argument structures.
Definition gitarg.hh:249
Filename(drama::thread::TAction *taction, const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const std::string &Default="", const Flags flags=Flags::KeepErr)
Constructor with the initial value set from an SDS structure.
Definition gitarg.hh:2051
virtual void Get(const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const std::string &Default="", const Flags flags=Flags::KeepErr)
Fetch the value of this item from an SDS structure.
Filename(const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const std::string &Default="", const Flags flags=Flags::KeepErr)
Constructor with the initial value set from an SDS structure.
Definition gitarg.hh:2009
Filename()
Default constructor.
Definition gitarg.hh:2078
A class which reads a file name from an SDS Command argument structures.
Definition gitarg.hh:1973
Id(const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const std::string Default="", const Flags flags=Flags::KeepErr)
Constructor with the initial value set from an SDS structure or file.
Definition gitarg.hh:1797
Id()
Default constructor.
Definition gitarg.hh:1739
virtual void Get(const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const std::string Default="", const Flags flags=(Flags::KeepErr))
Get the value of the object from an SDS structure or file.
virtual bool WasReadFromFile() const
Indicates if the structure was read from a file.
virtual bool WasReadFromDefault() const
Indicates if the structure was read from the default.
Id(drama::thread::TAction *taction, const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const std::string Default="", const Flags flags=Flags::KeepErr)
Constructor with the initial value set from an SDS structure or file.
Definition gitarg.hh:1864
virtual std::string ActualName() const
Return the actual name of the file or structure.
A class which reads an SDS structure from DRAMA SDS Command argument structures.
Definition gitarg.hh:1721
Int(const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const long Default=DefaultVal, const Flags flags=Flags::KeepErr)
Constructor which contructs the value from an item in an SDS structure.
Definition gitarg.hh:1032
virtual void Get(const sds::Id &Id, const long Min, const long Max, const std::string &Name="Argument1", const int Position=1, const long int Default=DefaultVal, const Flags flags=Flags::KeepErr)
Get the value of the object from an SDS structure.
Definition gitarg.hh:1261
virtual void Get(const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const long int Default=DefaultVal, const Flags flags=Flags::KeepErr)
Get the value of the object from an SDS structure.
Definition gitarg.hh:1203
Int(drama::thread::TAction *taction, const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const long Default=DefaultVal, const Flags flags=Flags::KeepErr)
Constructor which contructs the value from an item in an SDS structure.
Definition gitarg.hh:1071
Int(const long def=DefaultVal)
Simple constructor with a default value specified.
Definition gitarg.hh:1001
Int(const sds::Id &Id, const long Min, const long Max, const std::string &Name="Argument1", const int Position=1, const long Default=DefaultVal, const Flags flags=Flags::KeepErr)
Constructor which contructs the value from an item in an SDS structure.
Definition gitarg.hh:1118
Int(drama::thread::TAction *taction, const sds::Id &Id, const long Min, const long Max, const std::string &Name="Argument1", const int Position=1, const long Default=DefaultVal, const Flags flags=Flags::KeepErr)
Constructor which contructs the value from an item in an SDS structure.
Definition gitarg.hh:1161
A class which reads integer values from an SDS argument structure.
Definition gitarg.hh:987
Real(drama::thread::TAction *taction, const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const double Default=(double) DefaultVal, const Flags flags=Flags::KeepErr)
Constructor which constructs the value from an item in an SDS structure, for use in a threaded action...
Definition gitarg.hh:728
virtual void Get(const sds::Id &Id, const double Min, const double Max, const std::string &Name="Argument1", const int Position=1, const double Default=(double)(DefaultVal), const Flags flags=Flags::KeepErr)
Get the value of the object from an SDS structure.
Definition gitarg.hh:923
Real(const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const double Default=(double) DefaultVal, const Flags flags=Flags::KeepErr)
Constructor which constructs the value from an item in an SDS structure.
Definition gitarg.hh:688
Real(drama::thread::TAction *taction, const sds::Id &Id, const double Min, const double Max, const std::string &Name="Argument1", const int Position=1, const double Default=(double) DefaultVal, const Flags flags=Flags::KeepErr)
Constructor which constructs the value from an item in an SDS structure, for use in a threaded action...
Definition gitarg.hh:823
Real(const double def=(double) DefaultVal)
Simple constructor with a default value specified.
Definition gitarg.hh:656
virtual void Get(const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const double Default=(double)(DefaultVal), const Flags flags=Flags::KeepErr)
Get the value of the object from an SDS structure.
Definition gitarg.hh:865
Real(const sds::Id &Id, const double Min, const double Max, const std::string &Name="Argument1", const int Position=1, const double Default=(double) DefaultVal, const Flags flags=Flags::KeepErr)
Constructor which constructs the value from an item in an SDS structure.
Definition gitarg.hh:775
A class which reads real values from an SDS argument structure.
Definition gitarg.hh:642
String operator=(const std::string &str)
Assign a std::string to this gitarg::String.
Definition gitarg.hh:1461
String(drama::thread::TAction *taction, const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const std::string &Default="", const Flags flags=Flags::KeepErr)
Constructor with the initial value set from an SDS structure.
Definition gitarg.hh:1389
String(const String &)=default
Copy constructor Default is sufficent.
String()
Default constructor.
Definition gitarg.hh:1420
String operator=(const String &str)
Assign a const std::string to this gitarg::String.
Definition gitarg.hh:1470
String & operator=(char c)
Set this gitarg::String to a string containing a single character.
Definition gitarg.hh:1489
String(const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const std::string &Default="", const Flags flags=Flags::KeepErr)
Constructor with the initial value set from an SDS structure.
Definition gitarg.hh:1352
virtual void Get(const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const std::string &Default="", const Flags flags=Flags::KeepErr)
Fetch the value of this item from an SDS structure.
String operator=(const char *s)
Copy contents of a C string into this gitarg::String.
Definition gitarg.hh:1479
A class which reads a string item from an SDS structure.
Definition gitarg.hh:1313
A C++ Interface to the handling SDS structures.
Definition sds.hh:428
A class used by threads to access and enable the DRAMA context of an action or of a particular UFACE ...
Definition thread.hh:562
A class which implements a DRAMA Action with runs a thread.
Definition threadaction.hh:199
DRAMA 2 main include file.
#define DramaTHROW_S(status_, format_,...)
Throw a Drama exception with safe string formatting.
Definition exception.hh:108
#define DramaTHROW(status_, message_)
Throw a Drama exception.
Definition exception.hh:87
Flags
The various flags used in GIT operations.
Definition gitarg.hh:83
@ Upper
Convert strings to upper case.
@ KeepErr
Keep error status on return - will throw instead of take the default
@ LastBit
Only consider Least significant bit of integer values when treating integers as logical.
@ Abbrev
Allow abbreviations
@ Lower
Convert strings to lower case.
@ KeepValErr
Keep error status on return for value errors, not for no value supplied errors when it will take the ...
@ NoFlagSet
Value indicating no flags set.
constexpr Flags operator|(Flags f1, Flags f2)
Operator to allow Flags values to be or-ed.
Definition gitarg.hh:111
std::vector< ArgFlagVal > ArgFlagValVector
Declare a vector for ArgFlagVal items.
Definition gitarg.hh:2140
bool IsFlagSet(const Flags f1, const Flags f2)
Operator to allow determination of if a Flag enum value set.
Definition gitarg.hh:127
@ Default
System default type.
void CreateRunDramaTask()
Create and run a DRAMA task, with standard exception handling.
Definition task.hh:1327
The drama namespace contains all the classes, types etc of the DRAMA 2 implementation.
Definition drama.hh:93
Type used to specify arg/flag relationships to ArgFlags class.
Definition gitarg.hh:2130
DRAMA 2 include file - Code common to DRAMA 2 features supporting threading.