1#ifndef DRAMA2_GITARG_INC
2#define DRAMA2_GITARG_INC
33#include "drama/fmt/format.h"
102 if ((
unsigned int)(
f1) & (
unsigned int)(
f2))
112 inline void ___CheckLockTaken(
113 const std::string &
func,
114 const std::string &
file,
126 "Programming error - the program invoked a gitarg::Get() method (or constructor) without having taken the DRAMA lock. Please copy stack trace above to support.",
146 extern void __AddEnumPossiblities(
const Flags flags,
164 class EnumLookupClass {
223 template <
typename LookupClass,
typename EnumType>
class Enum {
232 void SetValue(
const unsigned int i) {
233 if (
i > lookupObject.GetMaxValue())
234 _value = InvalidValue();
242 return (
EnumType)(lookupObject.GetMaxValue()+1);
255 _value = InvalidValue();
308 :_value(InvalidValue()) {
340 Enum(
const sds::Id& Id,
341 const std::string &
Name=
"Argument1",
345 :_value(InvalidValue()) {
395 :_value(InvalidValue()) {
433 const std::string &
Name=
"Argument1",
437 :_value(InvalidValue()) {
489 "drama::gitarg::Enum type - use of Default string invalid, change to non-deprecated Get()/Constructor.");
521 void Get(
const sds::Id& Id,
522 const std::string &
Name=
"Argument1",
534 lookupObject.GetStringArray(),
"" ,
535 (
int)(
flags),
sizeof(
string),
string,&index,&
status);
540 "Failed to fetch Enumerated Argument from SDS",
544 __AddEnumPossiblities(
flags, lookupObject.GetStringArray(), &
except);
549 index =
static_cast<int>(
Default);
551 SetValue(
static_cast<unsigned>(index));
560 operator std::string()
const {
561 if (_value == InvalidValue())
563 "drama::gitarg::Enum value is invalid - was not initialised to a valid enum value.");
564 return lookupObject.GetStringArray()[
int(_value)];
602 template <
typename LookupClass,
typename EnumType>
633 template <
long int MinVal,
long int MaxVal,
long int DefaultVal=0>
class Real {
636 virtual const double * Range() {
681 const std::string &
Name=
"Argument1",
722 const std::string &
Name=
"Argument1",
770 const std::string &
Name=
"Argument1",
819 const std::string &
Name=
"Argument1",
858 const std::string &
Name=
"Argument1",
875 "Failed to fetch real number Argument from SDS",
918 const std::string &
Name=
"Argument1",
937 "Failed to fetch real number Argument from SDS",
1002 virtual const long int * Range() {
1046 const std::string &
Name =
"Argument1",
1086 const std::string &
Name =
"Argument1",
1134 const std::string &
Name =
"Argument1",
1178 const std::string &
Name =
"Argument1",
1217 const std::string &
Name=
"Argument1",
1233 "Failed to fetch integer Argument from SDS",
1277 const std::string &
Name=
"Argument1",
1295 "Failed to fetch integer Argument from SDS",
1305 operator long int()
const {
1346 class String :
public std::string {
1347 using std::string::string;
1350 static const unsigned _DefaultStringLength = 100;
1386 const std::string &
Name =
"Argument1",
1388 const std::string &
Default =
"",
1425 const std::string &
Name =
"Argument1",
1427 const std::string &
Default =
"",
1484 const std::string &
Name =
"Argument1",
1486 const std::string &
Default =
"",
1495 this->std::string::operator=(
str);
1504 this->std::string::operator=(
str);
1513 this->std::string::operator=(
s);
1523 this->std::string::operator=(
c);
1542 inline auto format_as(
const String &
s) {
return std::string(
s); }
1630 const std::string &
Name=
"Argument1",
1675 const std::string &
Name=
"Argument1",
1713 const std::string &
Name=
"Argument1",
1730 "Failed to fetch boolean Argument from SDS",
1740 operator bool()
const {
1785 bool _readFromFile =
false;
1786 bool _defaultUsed =
false;
1787 std::string _actualName;
1789 void UseDefaultIfReq(
const std::string &name,
1791 const std::string &fileName,
1801 Id() : sds::
Id() { }
1861 const std::string &
Name=
"Argument1",
1863 const std::string
Default =
"",
1929 const std::string &
Name=
"Argument1",
1931 const std::string
Default =
"",
1995 const std::string &
Name=
"Argument1",
1997 const std::string
Default =
"",
2035 class Filename :
public String {
2072 const std::string &
Name =
"Argument1",
2074 const std::string &
Default =
"",
2116 const std::string &
Name =
"Argument1",
2118 const std::string &
Default =
"",
2176 const std::string &
Name =
"Argument1",
2178 const std::string &
Default =
"",
2196 inline auto format_as(
const Filename &
f) {
return std::string(
f); }
2285 typename std::enable_if<std::is_base_of<
ArgFlagVal,
2286 typename ContainerType::value_type>
::value>::type* =
nullptr>
2291 const bool _ignoreCase;
2292 unsigned _theValue = 0;
2342 const unsigned First = 1,
2343 const unsigned Last = 0,
2375 const unsigned First = 1,
2389 "ArgFlags First argument position value of {0} is less then min of 1",
2395 "ArgFlags Last argument position value of {0} is less then First of {1}",
2406 for (
unsigned arg =
First; arg <
Last ; arg++)
2413 auto thisVal = _GetString(
Id, arg, _ignoreCase);
2427 for (
auto & flag : _validFlags)
2431 _theValue |= flag.flag;
2441 except.FmtWriteF(
"Argument value at position {0}, \"{1}\", is not an acceptable flag value",
2444 AddFlagPossiblities(&
except);
2462 unsigned GetVal()
const {
2483 std::ostringstream
s;
2485 (*except) <<
"\n Accepted flags are:\n";
2487 for (
auto & flag : _validFlags)
2489 s << flag.name <<
", ";
2495 (*except) <<
str <<
'\n';
2499 (*except) <<
" Case is ignored.";
An Exception class for exceptions thrown by DRAMA V2 classes.
Definition exception.hh:183
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:2401
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:2367
ArgFlags(const ContainerType &validFlagVals, bool ignoreCase=true)
Constructor.
Definition gitarg.hh:2336
bool IsSet(unsigned flags) const
Determines whether the specified flags are set.
Definition gitarg.hh:2499
unsigned GetVal() const
Return the flags value - the mask of set bits.
Definition gitarg.hh:2489
This class is used to check for the existence of one or more flags in an SDS structure.
Definition gitarg.hh:2316
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:1699
Bool operator=(const bool src)
Assign a bool to this gitarg::Bool item.
Definition gitarg.hh:1775
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:1655
virtual const GitLogStrType * Lookup()
Return a pointer to an array of enum strings equivalents.
Definition gitarg.hh:1611
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:1738
virtual ~Bool()
Destructor.
Definition gitarg.hh:1713
Bool(bool initVal=false)
Simple constructor with a default value of false.
Definition gitarg.hh:1619
A class which reads Boolean values from SDS argument structures.
Definition gitarg.hh:1594
virtual ~EnumLookupClass()
Destructor.
Definition gitarg.hh:220
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:191
virtual ~Enum()
Destructor.
Definition gitarg.hh:610
Enum(EnumType InitialValue)
Constructor with initial value supplied.
Definition gitarg.hh:290
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:457
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:506
Enum & operator=(const EnumType &rhs)
Allow an item of the underlying EnumType to be assigned to this object.
Definition gitarg.hh:603
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:367
Enum()
Default constructor for the object.
Definition gitarg.hh:281
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:548
A class which reads Enumerated values from a SDS argument structures.
Definition gitarg.hh:250
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:2140
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:2098
Filename()
Default constructor.
Definition gitarg.hh:2167
A class which reads a file name from an SDS Command argument structures.
Definition gitarg.hh:2062
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:1886
Id()
Default constructor.
Definition gitarg.hh:1828
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:1953
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:1810
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:1071
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:1300
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:1242
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:1110
Int(const long def=DefaultVal)
Simple constructor with a default value specified.
Definition gitarg.hh:1040
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:1157
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:1200
A class which reads integer values from an SDS argument structure.
Definition gitarg.hh:1026
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:746
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:941
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:706
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:841
Real(const double def=(double) DefaultVal)
Simple constructor with a default value specified.
Definition gitarg.hh:674
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:883
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:793
A class which reads real values from an SDS argument structure.
Definition gitarg.hh:660
String operator=(const std::string &str)
Assign a std::string to this gitarg::String.
Definition gitarg.hh:1521
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:1449
String(const String &)=default
Copy constructor Default is sufficient.
String()
Default constructor.
Definition gitarg.hh:1480
String operator=(const String &str)
Assign a const std::string to this gitarg::String.
Definition gitarg.hh:1530
String & operator=(char c)
Set this gitarg::String to a string containing a single character.
Definition gitarg.hh:1549
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:1412
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:1539
A class which reads a string item from an SDS structure.
Definition gitarg.hh:1373
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:598
A class which implements a DRAMA Action with runs a thread.
Definition threadaction.hh:204
DRAMA 2 main include file.
#define DramaTHROW_F(status_, format_,...)
Throw a Drama exception with fmt::format string formatting.
Definition exception.hh:129
#define DramaTHROW(status_, message_)
Throw a Drama exception.
Definition exception.hh:90
Flags
The various flags used in GIT operations.
Definition gitarg.hh:84
@ 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.
auto format_as(const gitarg::Enum< LookupClass, EnumType > &e)
Support formatting a gitarg::Enum as per std::string.
Definition gitarg.hh:630
constexpr Flags operator|(Flags f1, Flags f2)
Operator to allow Flags values to be or-ed.
Definition gitarg.hh:112
std::vector< ArgFlagVal > ArgFlagValVector
Declare a vector for ArgFlagVal items.
Definition gitarg.hh:2242
bool IsFlagSet(const Flags f1, const Flags f2)
Operator to allow determination of if a Flag enum value set.
Definition gitarg.hh:128
@ Default
System default type.
void CreateRunDramaTask()
Create and run a DRAMA task, with standard exception handling.
Definition task.hh:1339
The drama namespace contains all the classes, types etc of the DRAMA 2 implementation.
Definition drama.hh:99
Type used to specify arg/flag relationships to ArgFlags class.
Definition gitarg.hh:2232
DRAMA 2 include file - Code common to DRAMA 2 features supporting threading.