AAO DRAMA/DRAMA2 C++ Interface
DRAMA C++11 and later interface
gitarg.hh
Go to the documentation of this file.
1#ifndef DRAMA2_GITARG_INC
2#define DRAMA2_GITARG_INC
20/*
21 * History:
22 04-Jul-2014 - TJF - Original version
23 23-Mar-2018 - TJF - Ensure that in any case where we are throwing but might
24 have ERS reports, that we create the exception the
25 long way and add any ERS reports to the exception.
26
27 * The above ID is for Doxygen, this one has the format ACMM is looking for.
28 * "@(#) $Id$"
29 */
30
31#include "drama.hh"
32#include "drama/thread.hh"
33#include "Git.h"
34#include <string>
35#include <limits.h>
36#include <type_traits>
37namespace drama {
44 namespace gitarg {
45
56 enum class Flags {
57 NoFlagSet=0,
70 };
80 constexpr Flags operator|(Flags f1, Flags f2) {
81 return Flags(unsigned(f1)|unsigned(f2));
82 }
96 inline bool IsFlagSet(const Flags f1, const Flags f2) {
97 if ((unsigned int)(f1) & (unsigned int)(f2))
98 return true;
99 else
100 return false;
101 }
102
103 /*
104 * This method invokes the drama::Task static equivalent, but
105 * catches the exception and provides a more precise message.
106 */
107 inline void ___CheckLockTaken(
108 const std::string & func,
109 const std::string & file,
110 const int lineNum) {
111
112 try
113 {
114 drama::Task::CheckLockTaken(__func__, __FILE__, __LINE__);
115 }
116 catch (const drama::Exception &e)
117 {
118 if (e.dramaStatus() == DRAMA2__LOCK_ERR)
119 {
121 "Programming error - the program invoked a gitarg::Get() method (or constructor) without having taken the DRAMA lock. Please copy stack trace above to support.",
122 DRAMA2__LOCK_ERR, true);
124 throw;
125
126 }
127
128 }
129 /* Method for internal use only, used to add Enum value possibilities to
130 * and exception.
131 *
132 * @param flags Which GIT Flags apply. Interested in if "Upper",
133 * "Lower" and/or "Abbrev" are set.
134 * @param strings A pointer to a array of pointer to char, which
135 * is a character array to be passed to
136 * DCF(GitArgGetS). This array contains the
137 * list of strings to be accepted with a
138 * terminating null.
139 * @param except The exception to add the enum values too.
140 */
141 extern void __AddEnumPossiblities(const Flags flags,
142 const char **strings,
159 class EnumLookupClass {
160 public:
169 virtual unsigned int GetMaxValue() const = 0;
185 virtual const char ** GetStringArray() const = 0;
188 virtual ~EnumLookupClass() {}
189 };
190
218 template <typename LookupClass, typename EnumType> class Enum {
219 private:
220 EnumType _value; // The underlying value and the only memory used by the class.
221 LookupClass lookupObject; // allows us to invoke the methods of this class.
222
223 /*
224 * Set the value of the object from an int. If out of range,
225 * set to GetMaxValue + 1 (the invalid value).
226 */
227 void SetValue(const unsigned int i) {
228 if (i > lookupObject.GetMaxValue())
229 _value = InvalidValue();
230 else
231 _value = (EnumType)i;
232 }
233 /*
234 * Simply return the invalid value converted to int.
235 */
236 EnumType InvalidValue() const {
237 return (EnumType)(lookupObject.GetMaxValue()+1);
238 }
239 protected:
240 public:
247 Enum() {
248 _value = InvalidValue();
249 }
257
286 Enum(const sds::Id& Id,
287 const std::string & Name="Argument1",
288 const int Position=1,
289 const std::string & Default="",
291 :_value(InvalidValue()) {
292 Get(Id, Name, Position, Default, flags);
293 }
294
295
324 Enum(
326 const sds::Id& Id,
327 const std::string & Name="Argument1",
328 const int Position=1,
329 const std::string & Default="",
331 :_value(InvalidValue()) {
332
334 Get(Id, Name, Position, Default, flags);
335 }
336
337
338
339
367 void Get(const sds::Id& Id,
368 const std::string & Name="Argument1",
369 const int Position=1,
370 const std::string & Default="",
372
373
374
375
376 // We must have the DRAMA lock - otherwise ERS causes problems.
377 gitarg::___CheckLockTaken(__func__, __FILE__, __LINE__);
378
379
380 char string[100];
381 int index;
382 const char *myDef;
383 if (Default == "")
384 myDef = 0;
385 else
386 myDef = Default.c_str();
388 GitArgGetS((SdsIdType)Id,Name.c_str(),Position,
389 lookupObject.GetStringArray(),
390 myDef,
391 (int)(flags),sizeof(string),string,&index,&status);
392
393 if (status != STATUS__OK)
396 "Failed to fetch Enumerated Argument from SDS",
397 status);
398 //__AddEnumPossiblities(flags, lookupObject.GetStringArray(), status);
399 except.AddErs();
400 __AddEnumPossiblities(flags, lookupObject.GetStringArray(), &except);
401 throw except;
402 }
403
404 SetValue(index);
405 };
408 operator EnumType() const {
409 return _value;
410 }
413 operator std::string() const {
414 return lookupObject.GetStringArray()[int(_value)];
415 }
426 Enum& operator=(const EnumType &rhs) {
427 _value = rhs;
428 return *this;
429 }
430
433 virtual ~Enum() {};
434
435 }; // Class Enum;
436
437
438
466 template <long int MinVal,long int MaxVal, long int DefaultVal=0> class Real {
467 private:
468 // Return the range we need.
469 virtual const double * Range() {
470 static const double range[] = { MinVal, MaxVal };
471 return range;
472 }
473 double _value;
474 public:
480 Real(const double def = (double)DefaultVal) : _value(def) {
481 }
512 Real ( /*Constructor with automatic Get */
513 const sds::Id& Id,
514 const std::string & Name="Argument1",
515 const int Position=1,
516 const double Default = (double)DefaultVal,
517 const Flags flags = Flags::KeepErr) : _value(Default) {
518
520 }
521
552 Real ( /*Constructor with automatic Get */
554 const sds::Id& Id,
555 const std::string & Name="Argument1",
556 const int Position=1,
557 const double Default = (double)DefaultVal,
558 const Flags flags = Flags::KeepErr) : _value(Default) {
559
562 }
563
599 Real ( /*Constructor with automatic Get */
600 const sds::Id& Id,
601 const double Min,
602 const double Max,
603 const std::string & Name="Argument1",
604 const int Position=1,
605 const double Default = (double)DefaultVal,
606 const Flags flags = Flags::KeepErr) : _value(Default) {
607
609 }
610
647 Real ( /*Constructor with automatic Get */
649 const sds::Id& Id,
650 const double Min,
651 const double Max,
652 const std::string & Name="Argument1",
653 const int Position=1,
654 const double Default = (double)DefaultVal,
655 const Flags flags = Flags::KeepErr) : _value(Default) {
656
659 }
660
661
662 virtual ~Real() {}
663
689 virtual void Get( /* Get value from Sds structure */
690 const sds::Id& Id,
691 const std::string & Name="Argument1",
692 const int Position=1,
693 const double Default = (double)(DefaultVal),
694 const Flags flags = Flags::KeepErr) {
695
696 // We must have the DRAMA lock - otherwise ERS causes problems.
697 gitarg::___CheckLockTaken(__func__, __FILE__, __LINE__);
698
699
701 GitArgGetD((SdsIdType)Id,Name.c_str(),
702 Position,Range(),Default,
703 (int)(flags),&_value,&status);
704
705 if (status != STATUS__OK)
706 {
708 "Failed to fetch real number Argument from SDS",
709 status);
710
711 except.AddErs();
712 throw except;
713 }
714 }
715
747 virtual void Get( /* Get value from Sds structure */
748 const sds::Id& Id,
749 const double Min,
750 const double Max,
751 const std::string & Name="Argument1",
752 const int Position=1,
753 const double Default = (double)(DefaultVal),
754 const Flags flags = Flags::KeepErr) {
755
756 // We must have the DRAMA lock - otherwise ERS causes problems.
757 gitarg::___CheckLockTaken(__func__, __FILE__, __LINE__);
758
759
760 const double range[] = { Min, Max };
761
763 GitArgGetD((SdsIdType)Id,Name.c_str(),
765 (int)(flags),&_value,&status);
766
767 if (status != STATUS__OK)
768 {
770 "Failed to fetch real number Argument from SDS",
771 status);
772
773 except.AddErs();
774 throw except;
775 }
776 }
777
780 operator double() const {
781 return (_value);
782 }
783 }; // Class Real.
784
809 template <long int MinVal=LONG_MIN,
810 long int MaxVal=LONG_MAX,
811 long int DefaultVal=0> class Int {
812 private:
813 // Return the range we need.
814 virtual const long int * Range() {
815 static const long int range[] = { MinVal, MaxVal };
816 return range;
817 }
818 long _value;
819 public:
825 Int(const long def = DefaultVal) : _value(def) { }
826
856 Int ( /*Constructor with automatic Get */
857 const sds::Id& Id,
858 const std::string & Name = "Argument1",
859 const int Position=1,
860 const long Default = DefaultVal,
861 const Flags flags = Flags::KeepErr) : _value(Default) {
862
864 }
865
895 Int ( /*Constructor with automatic Get */
897 const sds::Id& Id,
898 const std::string & Name = "Argument1",
899 const int Position=1,
900 const long Default = DefaultVal,
901 const Flags flags = Flags::KeepErr) : _value(Default) {
902
905 }
906
942 Int ( /*Constructor with automatic Get */
943 const sds::Id& Id,
944 const long Min,
945 const long Max,
946 const std::string & Name = "Argument1",
947 const int Position=1,
948 const long Default = DefaultVal,
949 const Flags flags = Flags::KeepErr) : _value(Default) {
950
952 }
953
985 Int ( /*Constructor with automatic Get */
987 const sds::Id& Id,
988 const long Min,
989 const long Max,
990 const std::string & Name = "Argument1",
991 const int Position=1,
992 const long Default = DefaultVal,
993 const Flags flags = Flags::KeepErr) : _value(Default) {
994
997 }
998
999
1000
1001 virtual ~Int() {}
1027 virtual void Get( /* Get value from Sds structure */
1028 const sds::Id& Id,
1029 const std::string & Name="Argument1",
1030 const int Position=1,
1031 const long int Default = DefaultVal,
1032 const Flags flags = Flags::KeepErr) {
1033
1034 // We must have the DRAMA lock - otherwise ERS causes problems.
1035 gitarg::___CheckLockTaken(__func__, __FILE__, __LINE__);
1036
1037
1039 GitArgGetI((SdsIdType)Id,Name.c_str(),Position,Range(),Default,
1040 (int)(flags),&_value,&status);
1041
1042 if (status != STATUS__OK)
1043 {
1045 "Failed to fetch integer Argument from SDS",
1046 status);
1047
1048 except.AddErs();
1049 throw except;
1050 }
1051
1052 }
1053
1085 virtual void Get( /* Get value from Sds structure */
1086 const sds::Id& Id,
1087 const long Min,
1088 const long Max,
1089 const std::string & Name="Argument1",
1090 const int Position=1,
1091 const long int Default = DefaultVal,
1092 const Flags flags = Flags::KeepErr) {
1093
1094 // We must have the DRAMA lock - otherwise ERS causes problems.
1095 gitarg::___CheckLockTaken(__func__, __FILE__, __LINE__);
1096
1097 const long range[] = { Min, Max };
1098
1099
1102 (int)(flags),&_value,&status);
1103
1104 if (status != STATUS__OK)
1105 {
1107 "Failed to fetch integer Argument from SDS",
1108 status);
1109
1110 except.AddErs();
1111 throw except;
1113
1114 }
1115
1117 operator long int() const {
1118 return (_value);
1119 }
1120
1121
1122 }; // class Int.
1123
1137 class String : public std::string {
1138 using std::string::string; // Inherit constructors.
1139 private:
1140 // Enough space for conversion of doubles/long ints.
1141 static const unsigned _DefaultStringLength = 100;
1142
1143 void RawGet (const sds::Id& Id, const std::string &Name,
1144 int Position, const std::string &Default,
1146
1147 public:
1176 String( const sds::Id& Id,
1177 const std::string &Name = "Argument1",
1178 const int Position = 1,
1179 const std::string &Default = "",
1180 const Flags flags = Flags::KeepErr) {
1181 this->Get(Id, Name, Position, Default, flags);
1182 }
1183
1213 String(
1215 const sds::Id& Id,
1216 const std::string &Name = "Argument1",
1217 const int Position = 1,
1218 const std::string &Default = "",
1219 const Flags flags = Flags::KeepErr) {
1220
1222 this->Get(Id, Name, Position, Default, flags);
1223 }
1227 String(const String&) = default;
1228
1229 String(String&&) = default;
1234 /*
1235 * From:
1236 * http://codexpert.ro/blog/2013/08/26/inherited-constructors-in-cpp11/
1237 * If in the derived class you add a new specific constructor
1238 * after you use the using directive, you lost the possibility
1239 * of using the default constructor (even though it is in the
1240 * base class). So, if it is needed a specific constructor, you
1241 * need to add a default one, even one using that no-parameter
1242 * base constructor:
1243 */
1244 String() {
1245 }
1272 * Implementation of this method is in gitarg.cpp.
1273 */
1274 virtual void Get (const sds::Id& Id,
1275 const std::string &Name = "Argument1",
1276 const int Position = 1,
1277 const std::string &Default = "",
1278 const Flags flags = Flags::KeepErr);
1279
1285 String operator=(const std::string &str) {
1286 this->std::string::operator=(str);
1287 return *this;
1288 }
1294 String operator=(const String &str) {
1295 this->std::string::operator=(str);
1296 return *this;
1297 }
1303 String operator=(const char *s) {
1304 this->std::string::operator=(s);
1305 return *this;
1306 }
1313 String& operator=(char c) {
1314 this->std::string::operator=(c);
1315 return *this;
1316 }
1317
1318
1319 }; /* String */
1320
1343 class Bool {
1344 private:
1345 bool _value;
1346 static const GitLogStrType lookupTable[];
1347 protected:
1360 virtual const GitLogStrType * Lookup() {
1361 return lookupTable;
1362 }
1363 public:
1368 Bool(bool initVal=false) : _value(initVal) { }
1369
1404 Bool ( /*Constructor with automatic Get */
1405 const sds::Id& Id,
1406 const std::string &Name="Argument1",
1407 const int Position=1,
1408 const bool Default = false,
1410 {
1412 }
1413
1448 Bool ( /*Constructor with automatic Get */
1450 const sds::Id& Id,
1451 const std::string &Name="Argument1",
1452 const int Position=1,
1453 const bool Default = false,
1455 {
1458 }
1459
1462 virtual ~Bool() {}; /* Destructor for inheritors */
1487 virtual void Get( /* Get value from Sds structure */
1488 const sds::Id& Id,
1489 const std::string &Name="Argument1",
1490 const int Position=1,
1491 const bool Default = false,
1493
1494 // We must have the DRAMA lock - otherwise ERS causes problems.
1495 gitarg::___CheckLockTaken(__func__, __FILE__, __LINE__);
1496
1497
1498 long int actValue = 0;
1501 (int)(flags),&actValue,&status);
1502
1503 if (status != STATUS__OK)
1504 {
1506 "Failed to fetch boolean Argument from SDS",
1507 status);
1508 except.AddErs();
1509 throw except;
1510 }
1511
1512 _value = actValue ? true : false;
1513 };
1516 operator bool() const {
1517 return _value;
1518 };
1524 Bool operator=(const bool src) {
1525 _value = src;
1526 return *this;
1527 }
1528
1529
1530 }; // class Bool
1531
1532
1545 class Id : public sds::Id {
1546 private:
1547 bool _readFromFile = false; // Was this read from a file.
1548 bool _defaultUsed = false; // Was this read from the default.
1549 std::string _actualName; // Actual name of file or structure.
1550
1551 void UseDefaultIfReq(const std::string &name,
1552 int position,
1553 const std::string &fileName,
1554 Flags flags,
1556 const std::string &mess);
1557
1558 public:
1563 Id() : sds::Id() { }
1564
1565
1621 Id(
1622 const sds::Id& Id,
1623 const std::string &Name="Argument1",
1624 const int Position=1,
1625 const std::string Default = "",
1626 const Flags flags = Flags::KeepErr)
1627 {
1629 }
1630
1631
1632
1688 Id(
1690 const sds::Id& Id,
1691 const std::string &Name="Argument1",
1692 const int Position=1,
1693 const std::string Default = "",
1694 const Flags flags = Flags::KeepErr)
1695 {
1698 }
1699
1702 virtual ~Id();
1703
1755 virtual void Get( /* Get value from Sds structure */
1756 const sds::Id& Id,
1757 const std::string &Name="Argument1",
1758 const int Position=1,
1759 const std::string Default = "",
1760 const Flags flags = (Flags::KeepErr));
1761
1762
1771 virtual std::string ActualName() const;
1776 virtual bool WasReadFromFile() const;
1777
1783 virtual bool WasReadFromDefault() const;
1784
1785
1786 }; // class Id
1787
1788
1797 class Filename : public String {
1798 //String::String; // Inherit constructors.
1799 public:
1833 Filename( const sds::Id& Id,
1834 const std::string &Name = "Argument1",
1835 const int Position = 1,
1836 const std::string &Default = "",
1837 const Flags flags = Flags::KeepErr) {
1838 this->Get(Id, Name, Position, Default, flags);
1839 }
1840
1875 Filename(
1877 const sds::Id& Id,
1878 const std::string &Name = "Argument1",
1879 const int Position = 1,
1880 const std::string &Default = "",
1881 const Flags flags = Flags::KeepErr) {
1882
1883
1885 this->Get(Id, Name, Position, Default, flags);
1886 }
1887
1888
1892 /*
1893 * From:
1894 * http://codexpert.ro/blog/2013/08/26/inherited-constructors-in-cpp11/
1895 * If in the derived class you add a new specific constructor
1896 * after you use the using directive, you lost the possibility
1897 * of using the default constructor (even though it is in the
1898 * base class). So, if it is needed a specific constructor, you
1899 * need to add a default one, even one using that no-parameter
1900 * base constructor:
1901 */
1903 }
1904
1905
1937 virtual void Get (const sds::Id& Id,
1938 const std::string &Name = "Argument1",
1939 const int Position = 1,
1940 const std::string &Default = "",
1941 const Flags flags = Flags::KeepErr);
1942
1943
1944 }; // class Filename
1945
1946
1947
1954 struct ArgFlagVal {
1955 std::string name;
1956 unsigned flag;
1957 };
1964 using ArgFlagValVector = std::vector<ArgFlagVal>;
1965
1966
1967
1968 /*
1969 * Internal method only.
1970 *
1971 * Used by ArgFlags::Get() to get a given argument as a string, converting
1972 * it to upper case if requested.
1973 *
1974 * Returns the value of the string (converted to upper case if
1975 * requested) or an empty string if the value does not exist. Does
1976 * not throw an exception if the value does not exist.
1977 *
1978 * @param Id The SDS structure to read the flags from
1979 * @param pos Position of the argument to read.
1980 * @param toUpper Do we convert the result to upper case. If
1981 * false, leave as found.
1982 *
1983 * @return The value found. If no value was found, return an empty
1984 * string (does not throw for no value found!)
1985 */
1986 extern std::string _GetString(const sds::Id& Id, unsigned pos, bool toUpper);
1987
1988
1989
1990
2012 template<class ContainerType,
2013 /*
2014 * This complicated bit of code is about ensuring that only containers containing
2015 * a sub-class of "ArgFlagVal" are considered when trying to determine if
2016 * this template function is a valid specialization to use.
2017 *
2018 * A relevant reference is SFINAE ("Substitution Failure Is Not An Error")
2019 * E.g. http://en.cppreference.com/w/cpp/language/sfinae
2020 *
2021 * The problem we are tying to solve is that without this, any type
2022 * could trigger this specialization. Compilation
2023 * would then fail late with a poor error message.
2024 *
2025 * std::enable_if is being used to this template is only used when the
2026 * ContainerType value is a sub-class of ArgFlagVal. The following
2027 * references will help explain this:
2028 * http://www.cplusplus.com/reference/type_traits/enable_if/?kw=enable_if
2029 * http://www.boost.org/doc/libs/1_45_0/libs/utility/enable_if.html
2030 *
2031 * In addition, the use of "typename ContainerType::value_type" is to ensure
2032 * we refer to the actual type of the ContainerType template argument.
2033 * This should also trigger a failure if the container does not have a
2034 * value_type member. Here typename can be used to declare that a
2035 * dependent name is a type.
2036 */
2037 typename std::enable_if<std::is_base_of<ArgFlagVal,
2038 typename ContainerType::value_type>::value>::type* = nullptr>
2039
2040
2041 class ArgFlags {
2042 const ContainerType _validFlags; // Container with set of valid flags
2043 const bool _ignoreCase; // Do we ignore case?
2044 unsigned _theValue = 0; // The mask of flag values.
2045
2046 public:
2061 ArgFlags(const ContainerType &validFlagVals, bool ignoreCase=true) :
2062 _validFlags(validFlagVals), _ignoreCase(ignoreCase) {
2063 }
2093 const sds::Id& Id,
2094 const unsigned First = 1,
2095 const unsigned Last = 0,
2096 const bool FailOnInvalid = true,
2097 const bool IgnoreCase=true) :
2098 _validFlags(validFlagVals), _ignoreCase(IgnoreCase) {
2100 }
2126 unsigned Get(const sds::Id& Id,
2127 const unsigned First = 1,
2128 unsigned Last = 0,
2129 const bool FailOnInvalid = true) {
2130
2131 _theValue = 0; // Clear the value on entry.
2132
2133 if (Last == 0) Last = UINT_MAX;
2134
2135 /*
2136 * Validate arguments.
2137 */
2138 if (First < 1)
2139 {
2141 "ArgFlags First argument position value of % is less then min of 1",
2142 First);
2143 }
2144 if (Last < First)
2145 {
2147 "ArgFlags Last argument position value of % is less then First of %",
2148 Last, First);
2149
2150 }
2151 /*
2152 * If no argument was supplied, then just return 0.
2154 if (!Id) return 0;
2155 /*
2156 * Work through arguments.
2157 */
2158 for (unsigned arg = First; arg < Last ; arg++)
2159 {
2160 /*
2161 * Use this static method to get the actual string
2162 * value - not dependent on the template so
2163 * more efficient compilation.
2164 */
2165 auto thisVal = _GetString(Id, arg, _ignoreCase);
2166
2167 /*
2168 * If this is a null value, we are done.
2169 */
2170 if (thisVal == "")
2171 return _theValue;
2172
2173 /*
2174 * Work through the possible values. If we find
2175 * it, add the relevant flag value to the set of
2176 * values.
2177 */
2178 bool found = false;
2179 for (auto & flag : _validFlags)
2180 {
2181 if (flag.name == thisVal)
2182 {
2183 _theValue |= flag.flag;
2184 found = true;
2185 break;
2186 }
2187 }
2188 if ((!found)&&(FailOnInvalid))
2189 {
2191 "Argument value at position %, %, is not an acceptable flag value",
2192 arg, thisVal);
2193 }
2194
2195 }
2196
2197 return _theValue;
2198
2199 }
2200
2201
2211 unsigned GetVal() {
2212 return _theValue;
2213 }
2214 }; // class Flags
2215
2216
2217
2218 } // namespace gitarg
2219
2220} // namespace drama
2221
2222#endif /* define DRAMA2_GITARG_INC */
An Exception class for exceptions thrown by DRAMA V2 classes.
Definition exception.hh:164
unsigned GetVal()
Return the flags value - the mask of set bits.
Definition gitarg.hh:2238
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:2153
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:2119
ArgFlags(const ContainerType &validFlagVals, bool ignoreCase=true)
Constructor.
Definition gitarg.hh:2088
This class is used to check for the existence of one or more flags in an SDS structure.
Definition gitarg.hh:2068
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:1475
Bool operator=(const bool src)
Assign a bool to this gitarg::Bool item.
Definition gitarg.hh:1551
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:1431
virtual const GitLogStrType * Lookup()
Return a pointer to an array of enum strings equivalents.
Definition gitarg.hh:1387
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:1514
virtual ~Bool()
Destructor.
Definition gitarg.hh:1489
Bool(bool initVal=false)
Simple constructor with a default value of false.
Definition gitarg.hh:1395
A class which reads Boolean values from SDS argument structures.
Definition gitarg.hh:1370
virtual ~EnumLookupClass()
Destructor.
Definition gitarg.hh:215
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:186
virtual ~Enum()
Destructor.
Definition gitarg.hh:460
Enum(EnumType InitialValue)
Constructor with initial value supplied.
Definition gitarg.hh:283
Enum(const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, const std::string &Default="", const Flags flags=Flags::Upper|Flags::Abbrev|Flags::KeepErr)
Constructor which constructs the value from an item in an SDS structure.
Definition gitarg.hh:313
Enum & operator=(const EnumType &rhs)
Allow an item of the underlying EnumType to be assigned to this object.
Definition gitarg.hh:453
void Get(const sds::Id &Id, const std::string &Name="Argument1", const int Position=1, 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:394
Enum()
Default contructor for the object.
Definition gitarg.hh:274
Enum(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::Upper|Flags::Abbrev|Flags::KeepErr)
Constructor which constructs the value from an item in an SDS structure.
Definition gitarg.hh:351
A class which reads Enumerated values from a SDS argument structures.
Definition gitarg.hh:245
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:1902
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:1860
Filename()
Default constructor.
Definition gitarg.hh:1929
A class which reads a file name from an SDS Command argument structures.
Definition gitarg.hh:1824
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:1648
virtual ~Id()
Destructor.
Id()
Default constructor.
Definition gitarg.hh:1590
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:1715
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:1572
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:883
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:1112
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:1054
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:922
Int(const long def=DefaultVal)
Simple constructor with a default value specified.
Definition gitarg.hh:852
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:969
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:1012
A class which reads integer values from an SDS argument structure.
Definition gitarg.hh:838
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:579
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:774
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:539
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:674
Real(const double def=(double) DefaultVal)
Simple constructor with a default value specified.
Definition gitarg.hh:507
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:716
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:626
A class which reads real values from an SDS argument structure.
Definition gitarg.hh:493
String operator=(const std::string &str)
Assign a std::string to this gitarg::String.
Definition gitarg.hh:1312
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:1240
String(const String &)=default
Copy constructor Default is sufficent.
String()
Default constructor.
Definition gitarg.hh:1271
String operator=(const String &str)
Assign a const std::string to this gitarg::String.
Definition gitarg.hh:1321
String & operator=(char c)
Set this gitarg::String to a string containing a single character.
Definition gitarg.hh:1340
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:1203
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:1330
A class which reads a string item from an SDS structure.
Definition gitarg.hh:1164
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:110
Flags
The various flags used in GIT operations.
Definition gitarg.hh:83
@ Upper
Convert strings to upper case.
@ KeepErr
Keep error status on return
@ 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
@ 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:107
std::vector< ArgFlagVal > ArgFlagValVector
Declare a vector for ArgFlagVal items.
Definition gitarg.hh:1991
bool IsFlagSet(const Flags f1, const Flags f2)
Operator to allow determination of if a Flag enum value set.
Definition gitarg.hh:123
@ Default
System default type.
void CreateRunDramaTask()
Create and run a DRAMA task, with standard exception handling.
Definition task.hh:1322
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:1981
DRAMA 2 include file - Code common to DRAMA 2 features supporting threading.