ctkVersionRange_p.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) 2010 German Cancer Research Center,
  4. Division of Medical and Biological Informatics
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. =============================================================================*/
  15. #ifndef CTKVERSIONRANGE_H
  16. #define CTKVERSIONRANGE_H
  17. #include "ctkVersion.h"
  18. namespace ctk {
  19. /**
  20. * Class representing CTK version ranges.
  21. */
  22. class VersionRange
  23. {
  24. private:
  25. Version* low;
  26. Version* high;
  27. bool lowIncluded;
  28. bool highIncluded;
  29. public:
  30. /**
  31. * The empty version range "[0.0.0,inf)".
  32. */
  33. static const VersionRange& defaultVersionRange();
  34. /**
  35. * Construct a VersionRange object.
  36. * Format for a range:
  37. * ( "(" | "[" ) LOW_VERSION "," HIGH_VERSION ( ")" | "]" )
  38. * Format for at least a version:
  39. * VERSION
  40. *
  41. * @param vr Input string.
  42. */
  43. VersionRange(const QString& vr);
  44. /**
  45. * Construct the default VersionRange object.
  46. *
  47. */
  48. VersionRange();
  49. ~VersionRange();
  50. bool isSpecified() const;
  51. /**
  52. * Check if specified version is within our range.
  53. *
  54. * @param ver Version to compare to.
  55. * @return Return true if within range, otherwise false.
  56. */
  57. bool withinRange(const Version& ver) const;
  58. /**
  59. * Check if objects range is within another VersionRange.
  60. *
  61. * @param range VersionRange to compare to.
  62. * @return Return true if within range, otherwise false.
  63. */
  64. bool withinRange(const VersionRange& range) const;
  65. /**
  66. * Compare object to another VersionRange. VersionRanges are compared on the
  67. * lower bound.
  68. *
  69. * @param obj VersionRange to compare to.
  70. * @return Return 0 if equals, negative if this object is less than obj
  71. * and positive if this object is larger then obj.
  72. * @exception ClassCastException if object is not a VersionRange object.
  73. */
  74. int compare(const VersionRange& obj) const;
  75. /**
  76. * String with version number. If version is not specified return
  77. * an empty string.
  78. *
  79. * @return QString.
  80. */
  81. QString toString() const;
  82. /**
  83. * Check if object is equal to this object.
  84. *
  85. * @param obj Package entry to compare to.
  86. * @return true if equal, otherwise false.
  87. */
  88. bool operator==(const VersionRange& r) const;
  89. };
  90. }
  91. #endif // CTKVERSIONRANGE_H