ctkVersionRange_p.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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. /**
  19. * Class representing CTK version ranges.
  20. */
  21. class ctkVersionRange
  22. {
  23. private:
  24. ctkVersion* low;
  25. ctkVersion* high;
  26. bool lowIncluded;
  27. bool highIncluded;
  28. public:
  29. /**
  30. * The empty version range "[0.0.0,inf)".
  31. */
  32. static const ctkVersionRange& defaultVersionRange();
  33. /**
  34. * Construct a ctkVersionRange object.
  35. * Format for a range:
  36. * ( "(" | "[" ) LOW_VERSION "," HIGH_VERSION ( ")" | "]" )
  37. * Format for at least a version:
  38. * VERSION
  39. *
  40. * @param vr Input string.
  41. */
  42. ctkVersionRange(const QString& vr);
  43. /**
  44. * Construct the default ctkVersionRange object.
  45. *
  46. */
  47. ctkVersionRange();
  48. ~ctkVersionRange();
  49. bool isSpecified() const;
  50. /**
  51. * Check if specified version is within our range.
  52. *
  53. * @param ver ctkVersion to compare to.
  54. * @return Return true if within range, otherwise false.
  55. */
  56. bool withinRange(const ctkVersion& ver) const;
  57. /**
  58. * Check if objects range is within another ctkVersionRange.
  59. *
  60. * @param range ctkVersionRange to compare to.
  61. * @return Return true if within range, otherwise false.
  62. */
  63. bool withinRange(const ctkVersionRange& range) const;
  64. /**
  65. * Compare object to another ctkVersionRange. VersionRanges are compared on the
  66. * lower bound.
  67. *
  68. * @param obj ctkVersionRange to compare to.
  69. * @return Return 0 if equals, negative if this object is less than obj
  70. * and positive if this object is larger then obj.
  71. * @exception ClassCastException if object is not a ctkVersionRange object.
  72. */
  73. int compare(const ctkVersionRange& obj) const;
  74. /**
  75. * String with version number. If version is not specified return
  76. * an empty string.
  77. *
  78. * @return QString.
  79. */
  80. QString toString() const;
  81. /**
  82. * Check if object is equal to this object.
  83. *
  84. * @param obj Package entry to compare to.
  85. * @return true if equal, otherwise false.
  86. */
  87. bool operator==(const ctkVersionRange& r) const;
  88. };
  89. #endif // CTKVERSIONRANGE_H