C12Adapter Opensource C++ Interface
|
Version that has multiple fraction (subversion) numbers, up to a certain limit. More...
Public Types | |
enum | { VersionMaximumNumberOfEntries = 5 } |
Public Member Functions | |
MVersion () | |
Construct an empty version object. More... | |
MVersion (const MStdString &s, bool readonly=false) | |
Construct Version object from a string representation of version. More... | |
MVersion (const MStdString &s, const MStdString &format) | |
Construct Version object from a string. More... | |
MVersion (const MVersion &other) | |
Construct a new version object from a given version object. More... | |
virtual | ~MVersion () |
Destroy the Version object. More... | |
MVersion & | operator= (const MVersion &other) |
Assignment operator that takes variable of type MVersion. More... | |
MVersion & | operator= (const MStdString &s) |
Assignment operator that takes variable of type MStdString. More... | |
bool | operator== (const MVersion &other) const |
Equality boolean operator. More... | |
bool | operator!= (const MVersion &other) const |
Inequality boolean operator. More... | |
bool | operator< (const MVersion &other) const |
Less-than boolean operator. More... | |
bool | operator> (const MVersion &other) const |
Greater-than boolean operator. More... | |
bool | operator<= (const MVersion &other) const |
Less-than or equal-to boolean operator. More... | |
bool | operator>= (const MVersion &other) const |
Greater-than or equal-to boolean operator. More... | |
bool | IsEmpty () const |
Whether the version number is empty, has no subversions. More... | |
void | SetEmpty () |
Discard the value of the version, make it empty. More... | |
void | Assign (const MVersion &other) |
Assignment method. More... | |
void | AssignVariant (const MVariant &versionOrString) |
Most generic reflected version of assignment operator. More... | |
int | CompareWhole (const MVariant &other) const |
unsigned | Item (unsigned index) const |
Returns the numeric value of the specified zero indexed fraction. More... | |
void | SetItem (unsigned index, unsigned value) |
Sets the fraction with the given index to a value specified. More... | |
virtual unsigned | GetEmbeddedSizeof () const |
Version is an embedded object type, therefore return its size in bytes. More... | |
bool | IsReadOnly () const |
void | SetIsReadOnly (bool readonly) |
int | GetCount () const |
void | SetCount (int newCount) |
MStdString | AsString () const |
void | SetAsString (const MStdString &) |
MStdString | GetFormat () const |
void | SetFormat (const MStdString &) |
bool | Matches (const MVariant &other) const |
bool | MatchesVersion (const MVersion &other) const |
int | Compare (const MVariant &other, int precision=0) const |
int | CompareVersion (const MVersion &other, int precision=0) const |
![]() | |
virtual | ~MObject () |
Object destructor. | |
virtual const MClass * | GetClass () const =0 |
Get the final class of the object. More... | |
bool | IsEmbeddedObject () const |
Tell if the object is of embedded kind. More... | |
SHOW_INTERNAL MVariant | Call (const MStdString &name, const MVariant ¶ms) |
Call the object service with parameters, given as variant. More... | |
MVariant | Call0 (const MStdString &name) |
Call the object service with no parameters. More... | |
MVariant | Call1 (const MStdString &name, const MVariant &p1) |
Call the object service with one parameter. More... | |
MVariant | Call2 (const MStdString &name, const MVariant &p1, const MVariant &p2) |
Call the object service with two parameter. More... | |
MVariant | Call3 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3) |
Call the object service with three parameter. More... | |
MVariant | Call4 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3, const MVariant &p4) |
Call the object service with four parameter. More... | |
MVariant | Call5 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3, const MVariant &p4, const MVariant &p5) |
Call the object service with five parameter. More... | |
MVariant | Call6 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3, const MVariant &p4, const MVariant &p5, const MVariant &p6) |
Call the object service with six parameter. More... | |
virtual MVariant | CallV (const MStdString &name, const MVariant::VariantVector ¶ms) |
Call the object service with parameters, given as variant vector. More... | |
virtual bool | IsPropertyPresent (const MStdString &name) const |
Tell if the property with the given name exists. | |
virtual bool | IsServicePresent (const MStdString &name) const |
Tell if the service with the given name exists. | |
virtual MVariant | GetProperty (const MStdString &name) const |
Get the property value using name of the property. More... | |
virtual void | SetProperty (const MStdString &name, const MVariant &value) |
Set the property using name of the property, and value. More... | |
virtual MStdStringVector | GetAllPropertyNames () const |
Return the list of publicly available properties, persistent or not. More... | |
virtual MStdStringVector | GetAllPersistentPropertyNames () const |
Return the list of persistent properties. More... | |
virtual void | SetPersistentPropertiesToDefault () |
Set the persistent properties of the object to their default values. More... | |
virtual MVariant | GetPersistentPropertyDefaultValue (const MStdString &name) const |
Get the default value of persistent property with the name given. More... | |
virtual void | SetPersistentPropertyToDefault (const MStdString &name) |
Set the persistent property with the name given to default value. More... | |
virtual const char * | GetType () const |
Get the name of the type for the object (could be the same as class name). | |
virtual void | SetType (const MStdString &) |
Intentionally, it will set the name of the type for the object, but the service will not allow setting the name to anything other than the current name. More... | |
virtual void | Validate () |
Validate internal structures of the object. More... | |
Additional Inherited Members | |
![]() | |
static const MClass * | GetStaticClass () |
Get the declared class of this particular object. More... | |
static bool | IsClassPresent (const MStdString &name) |
Tells if the given class name is available. More... | |
![]() | |
static const MClass | s_class |
Class of MObject. | |
![]() | |
MObject () | |
Object constructor, protected as the class is abstract. | |
void | DoSetPersistentPropertiesToDefault (const MClass *staticClass) |
Set the persistent properties to their default values for one object provided the class for that object. More... | |
Version that has multiple fraction (subversion) numbers, up to a certain limit.
This is to represent a version of a software or firmware release. Restrictions apply on what version can be, as the number of fractions cannot exceed five, and each fraction shall be an unsigned number limited to value 65535. Version is a value type object that can be stored within Variant as is.
Version can be read-only (IsReadOnly is true), which means it cannot be modified by software unless it explicitly changes IsReadOnly into false. This attribute is not a security measure but an easy way of catching software errors.
Version can have a format that defines a number of fractions, their range, and whether the version is read-only. The format is a string consisting of the following case insensitive characters:
By default, the format is an empty string for read-write version, and "r" for IsReadOnly version. In either case such default format will mean the version can have any number of fractions from 0 to 5, and each fraction can be in range 0 to 65535. Other examples of format string are:
MVersion::MVersion | ( | ) |
Construct an empty version object.
MVersion::MVersion | ( | const MStdString & | s, |
bool | readonly = false |
||
) |
Construct Version object from a string representation of version.
s | String representation of a version such as "3.1". The string should comprise of a correct representation of a version, such that it shall have numbers separated by periods. |
readonly | Whether the result version object will be read-only, means the object cannot be changed unless read-only flag is cleared. |
MVersion::MVersion | ( | const MStdString & | s, |
const MStdString & | format | ||
) |
Construct Version object from a string.
s | String representation of a version such as "3.1". The string should comprise of a correct representation of a version, such that it shall have numbers separated by periods. |
format | Version format. |
MVersion::MVersion | ( | const MVersion & | other | ) |
Construct a new version object from a given version object.
An exact same object is constructed. That includes both the set of subversions (fractions) and attributes such as format.
other | Version object from which a copy shall be made. |
|
inlinevirtual |
Destroy the Version object.
Following value type object rules, this destructor does nothing.
void MVersion::Assign | ( | const MVersion & | other | ) |
Assignment method.
The value of this object will be exactly like one given. That includes both the set of subversions (fractions) and attributes such as format.
other | Version object which whole value is to be copied. |
void MVersion::AssignVariant | ( | const MVariant & | versionOrString | ) |
Most generic reflected version of assignment operator.
The behavior of this method depends on the type of the given parameter.
versionOrString | Parameter from which the assignment shall be made. Depending on the type, the behavior is as follows:
|
MStdString MVersion::AsString | ( | ) | const |
String representation of version, accessible as read/write property.
If Count is zero, then AsString returns an empty string, "". Not all versions are writable, use IsReadOnly to determine if AsString is writable. When assigned, the given string should comprise a correct version representation. If the format is specified, the string should correspond to such format.
int MVersion::Compare | ( | const MVariant & | other, |
int | precision = 0 |
||
) | const |
Compare version with the given other version object.
The comparison of two versions is very similar to string comparison, except that each fraction is compared not each character of a string. The result of the comparison is an integer value that will be zero for equal versions, minus one for the case when this version is smaller than the one given, and one if this version is bigger. The second optional parameter allows for comparison to ignore less significant fractions, which is convenient for cases when the comparison has to check major releases.
other | Version with which this version has to be compared. |
precision | When comparing, whether to take into consideration a limited set of version fractions. The values are:
|
Examples:
int MVersion::CompareVersion | ( | const MVersion & | other, |
int | precision = 0 |
||
) | const |
Compare version with the given other version object.
The comparison of two versions is very similar to string comparison, except that each fraction is compared not each character of a string. The result of the comparison is an integer value that will be zero for equal versions, minus one for the case when this version is smaller than the one given, and one if this version is bigger. The second optional parameter allows for comparison to ignore less significant fractions, which is convenient for cases when the comparison has to check major releases.
other | Version with which this version has to be compared. |
precision | When comparing, whether to take into consideration a limited set of version fractions. The values are:
|
Examples:
|
inline |
Count of subversions (fractions) in version.
For example, Count = 3 is for version "10.20.30". If the referenced object IsEmpty then Count returns zero. When setting Count property, the existing version is either truncated or extended with zeros.
|
virtual |
MStdString MVersion::GetFormat | ( | ) | const |
Version format property.
The format is described in detail in version class description
|
inline |
Whether the version number is empty, has no subversions.
This is a test that returns true if the version has no fractions (subversions). Flags such as IsReadOnly or Format are not taken into consideration. A string representation of an empty MVersion object is an empty string, "". When the version has a fixed format it can never be empty.
|
inline |
Indicates if the version object is writable.
Read-only objects cannot be modified in any way until IsReadOnly is set to false.
unsigned MVersion::Item | ( | unsigned | index | ) | const |
Returns the numeric value of the specified zero indexed fraction.
The numeric value of each sub version can be retrieved using the Item method. Assuming the version is "10.20.30.40", the following are fractions:
index | The index of the sub version to retrieve. The valid range is 0 to Count - 1. |
bool MVersion::Matches | ( | const MVariant & | other | ) | const |
Check whether this version matches the one given.
This is a convenience method that determines whether the given version number is a subset of a more generic major version (5.0.0.123 is a subset of 5.0). This method is similar to Compare except that it behaves differently when the peer versions have a different number of fractions. If this version has a smaller number of fractions, then true is returned when all existing fractions of this version are equal to those in the other version. Here are the examples:
The operation is not commutative and v1.Matches(v2)
is not necessarily the same result as v2.Matches(v1)
. In fact, they will give different results if and only if v1 and v2 have a different number of fractions. Therefore:
other | Version with which this version has to be matched. |
bool MVersion::MatchesVersion | ( | const MVersion & | other | ) | const |
Check whether this version matches the one given.
This is a convenience method that determines whether the given version number is a subset of a more generic major version (5.0.0.123 is a subset of 5.0). This method is similar to Compare except that it behaves differently when the peer versions have a different number of fractions. If this version has a smaller number of fractions, then true is returned when all existing fractions of this version are equal to those in the other version. Here are the examples:
The operation is not commutative and v1.Matches(v2)
is not necessarily the same result as v2.Matches(v1)
. In fact, they will give different results if and only if v1 and v2 have a different number of fractions. Therefore:
other | Version with which this version has to be matched. |
|
inline |
Inequality boolean operator.
Versions are considered not equal if their number of fractions are different, or any fraction has a different value as the corresponding fraction in the other version. Read-only and format flags do not participate in comparison.
other | Other version object with which to make the comparison. |
Examples of true inequality (string representation of version is used):
|
inline |
Less-than boolean operator.
The comparison of two versions is very similar to string comparison, except that each fraction is compared, not each character of a string. The comparison proceeds from left to right, fraction by fraction, until not matching fractions are found, or one of the versions does not have the corresponding fraction because its Count is smaller.
other | Other version object with which to make the comparison. |
Examples of comparison:
|
inline |
Less-than or equal-to boolean operator.
The comparison of two versions is very similar to string comparison, except that each fraction is compared, not each character of a string. The comparison proceeds from left to right, fraction by fraction, until not matching fractions are found, or one of the versions does not have the corresponding fraction because its Count is smaller.
other | Other version object with which to make the comparison. |
Examples of comparison:
Assignment operator that takes variable of type MVersion.
The value of this object will be exactly like one given. That includes both the set of subversions (fractions) and attributes such as format.
other | Version object which whole value is to be copied. |
|
inline |
Assignment operator that takes variable of type MStdString.
Only the value of the string is copied while the read-only status and format remain as they were prior to the assignment.
s | String representation of a version such as "3.1". The string should comprise a correct representation of a version, such as it shall have numbers separated by periods. |
|
inline |
Equality boolean operator.
Versions are considered equal if their number of fractions are the same, and each fraction has the same value. Read-only and format flags do not participate in comparison.
other | Other version object with which to make the comparison. |
Examples of true equality (string representation of version is used):
|
inline |
Greater-than boolean operator.
The comparison of two versions is very similar to string comparison, except that each fraction is compared, not each character of a string. The comparison proceeds from left to right, fraction by fraction, until not matching fractions are found, or one of the versions does not have the corresponding fraction because its Count is smaller.
other | Other version object with which to make the comparison. |
Examples of comparison:
|
inline |
Greater-than or equal-to boolean operator.
The comparison of two versions is very similar to string comparison, except that each fraction is compared, not each character of a string. The comparison proceeds from left to right, fraction by fraction, until not matching fractions are found, or one of the versions does not have the corresponding fraction because its Count is smaller.
other | Other version object with which to make the comparison. |
Examples of comparison:
void MVersion::SetAsString | ( | const MStdString & | ) |
String representation of version, accessible as read/write property.
If Count is zero, then AsString returns an empty string, "". Not all versions are writable, use IsReadOnly to determine if AsString is writable. When assigned, the given string should comprise a correct version representation. If the format is specified, the string should correspond to such format.
void MVersion::SetCount | ( | int | newCount | ) |
Count of subversions (fractions) in version.
For example, Count = 3 is for version "10.20.30". If the referenced object IsEmpty then Count returns zero. When setting Count property, the existing version is either truncated or extended with zeros.
void MVersion::SetEmpty | ( | ) |
Discard the value of the version, make it empty.
void MVersion::SetFormat | ( | const MStdString & | ) |
Version format property.
The format is described in detail in version class description
|
inline |
Indicates if the version object is writable.
Read-only objects cannot be modified in any way until IsReadOnly is set to false.
void MVersion::SetItem | ( | unsigned | index, |
unsigned | value | ||
) |
Sets the fraction with the given index to a value specified.
index | The index of the sub version to set. The valid range is 0 to Count - 1. |
value | The value to which the fraction has to be set. For byte size format "b" this is 0 to 255. Otherwise the allowed range is 0 to 65535. |