ARC SDK
|
Used to represent software (names and version) and comparison. More...
#include <arc/compute/Software.h>
Public Types | |
enum | ComparisonOperatorEnum { NOTEQUAL = 0, EQUAL = 1, GREATERTHAN = 2, LESSTHAN = 3, GREATERTHANOREQUAL = 4, LESSTHANOREQUAL = 5 } |
Comparison operator enum. More... | |
typedef bool(Software::* | ComparisonOperator )(const Software &) const |
Definition of a comparison operator method pointer. More... | |
Public Member Functions | |
Software () | |
Dummy constructor. More... | |
Software (const std::string &name_version) | |
Create a Software object. More... | |
Software (const std::string &name, const std::string &version) | |
Create a Software object. More... | |
Software (const std::string &family, const std::string &name, const std::string &version) | |
Create a Software object. More... | |
bool | empty () const |
Indicates whether the object is empty. More... | |
bool | operator== (const Software &sw) const |
Equality operator. More... | |
bool | operator!= (const Software &sw) const |
Inequality operator. More... | |
bool | operator> (const Software &sw) const |
Greater-than operator. More... | |
bool | operator< (const Software &sw) const |
Less-than operator. More... | |
bool | operator>= (const Software &sw) const |
Greater-than or equal operator. More... | |
bool | operator<= (const Software &sw) const |
Less-than or equal operator. More... | |
std::string | operator() () const |
Get string representation. More... | |
operator std::string (void) const | |
Cast to string. More... | |
const std::string & | getFamily () const |
Get family. More... | |
const std::string & | getName () const |
Get name. More... | |
const std::string & | getVersion () const |
Get version. More... | |
const std::list< std::string > & | getOptions () const |
void | addOption (const std::string &opt) |
void | addOptions (const std::list< std::string > &opts) |
Static Public Member Functions | |
static ComparisonOperator | convert (const ComparisonOperatorEnum &co) |
Convert a ComparisonOperatorEnum value to a comparison method pointer. More... | |
static std::string | toString (ComparisonOperator co) |
Convert Software::ComparisonOperator to a string. More... | |
Static Public Attributes | |
static const std::string | VERSIONTOKENS |
Tokens used to split version string. More... | |
Friends | |
std::ostream & | operator<< (std::ostream &out, const Software &sw) |
Write Software string representation to a std::ostream. More... | |
Used to represent software (names and version) and comparison.
The Software class is used to represent the name of a piece of software internally. Generally software are identified by a name and possibly a version number. Some software can also be categorized by type or family (compilers, operating system, etc.). A software object can be compared to other software objects using the comparison operators contained in this class. The basic usage of this class is to test if some specified software requirement (SoftwareRequirement) are fulfilled, by using the comparability of the class.
Internally the Software object is represented by a family and name identifier, and the software version is tokenized at the characters defined in VERSIONTOKENS, and stored as a list of tokens.
typedef bool(Software::* Arc::Software::ComparisonOperator)(const Software &) const |
Definition of a comparison operator method pointer.
This typedef
defines a comparison operator method pointer.
Comparison operator enum.
The ComparisonOperatorEnum enumeration is a 1-1 correspondance between the defined comparison method operators (Software::ComparisonOperator), and can be used in circumstances where method pointers are not supported.
Enumerator | |
---|---|
NOTEQUAL |
see operator!= |
EQUAL |
see operator== |
GREATERTHAN |
see operator> |
LESSTHAN |
see operator< |
GREATERTHANOREQUAL |
see operator>= |
LESSTHANOREQUAL |
see operator<= |
|
inline |
Dummy constructor.
This constructor creates a empty object.
Arc::Software::Software | ( | const std::string & | name_version | ) |
Create a Software object.
Create a Software object from a single string composed of a name and a version part. The created object will contain a empty family part. The name and version part of the string will be split at the first occurence of a dash (-) which is followed by a digit (0-9). If the string does not contain such a pattern, the passed string will be taken to be the name and version will be empty.
name_version | should be a string composed of the name and version of the software to represent. |
Arc::Software::Software | ( | const std::string & | name, |
const std::string & | version | ||
) |
Arc::Software::Software | ( | const std::string & | family, |
const std::string & | name, | ||
const std::string & | version | ||
) |
|
static |
Convert a ComparisonOperatorEnum value to a comparison method pointer.
The passed ComparisonOperatorEnum will be converted to a comparison method pointer defined by the Software::ComparisonOperator typedef.
This static method is not defined in language bindings created with Swig, since method pointers are not supported by Swig.
co | a ComparisonOperatorEnum value. |
|
inline |
Indicates whether the object is empty.
true
if the name of this object is empty, otherwise false
.
|
inline |
Get family.
|
inline |
Get name.
|
inline |
Get version.
|
inline |
Cast to string.
This casting operator behaves exactly as operator()() does. The cast is used like (std::string) <software-object>.
|
inline |
Inequality operator.
The behaviour of the inequality operator is just opposite that of the equality operator (operator==()).
sw | is the RHS Software object. |
true
when the two objects are inequal, otherwise false
. std::string Arc::Software::operator() | ( | ) | const |
Get string representation.
Returns the string representation of this object, which is 'family'-'name'-'version'.
|
inline |
Less-than operator.
The behaviour of this less-than operator is equivalent to the greater-than operator (operator>()) with the LHS and RHS swapped.
sw | is the RHS object. |
true
if the LHS is less than the RHS, otherwise false
.
|
inline |
Less-than or equal operator.
The LHS object is greater than or equal to the RHS object if the LHS equal the RHS (operator==()) or if the LHS is greater than the RHS (operator>()).
sw | is the RHS object. |
true
if the LHS is less than or equal the RHS, otherwise false
.
|
inline |
Equality operator.
Two Software objects are equal only if they are of the same family, have the same name and is of same version. This operator can also be represented by the Software::EQUAL ComparisonOperatorEnum value.
sw | is the RHS Software object. |
true
when the two objects equals, otherwise false
. bool Arc::Software::operator> | ( | const Software & | sw | ) | const |
Greater-than operator.
For the LHS object to be greater than the RHS object they must first share the same family and name. If the version of the LHS is empty or the LHS and RHS versions equal then LHS is not greater than RHS. If the LHS version is not empty while the RHS is then LHS is greater than RHS. If both versions are non empty and not equal then, the first version token of each object is compared and if they are identical, the two next version tokens will be compared. If not identical, the two tokens will be parsed as integers, and if parsing fails the LHS is not greater than the RHS. If parsing succeeds and the integers equals, the two next tokens will be compared, otherwise the comparison is resolved by the integer comparison.
If the LHS contains more version tokens than the RHS, and the comparison have not been resolved at the point of equal number of tokens, then if the additional tokens contains a token which cannot be parsed to a integer the LHS is not greater than the RHS. If the parsed integer is not 0 then the LHS is greater than the RHS. If the rest of the additional tokens are 0, the LHS is not greater than the RHS.
If the RHS contains more version tokens than the LHS and comparison have not been resolved at the point of equal number of tokens, or simply if comparison have not been resolved at the point of equal number of tokens, then the LHS is not greater than the RHS.
sw | is the RHS object. |
true
if the LHS is greater than the RHS, otherwise false
.
|
inline |
Greater-than or equal operator.
The LHS object is greater than or equal to the RHS object if the LHS equal the RHS (operator==()) or if the LHS is greater than the RHS (operator>()).
sw | is the RHS object. |
true
if the LHS is greated than or equal the RHS, otherwise false
.
|
static |
Convert Software::ComparisonOperator to a string.
This method is not available in language bindings created by Swig, since method pointers are not supported by Swig.
co | is a Software::ComparisonOperator. |
|
friend |
Write Software string representation to a std::ostream.
Write the string representation of a Software object to a std::ostream.
out | is a std::ostream to write the string representation of the Software object to. |
sw | is the Software object to write to the std::ostream. |
|
static |
Tokens used to split version string.
This string constant specifies which tokens will be used to split the version string.