ctkServiceEvent.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) 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. #include "ctkServiceEvent.h"
  16. class ctkServiceEventData : public QSharedData
  17. {
  18. public:
  19. ctkServiceEventData(ctkServiceEvent::Type type, const ctkServiceReference& reference)
  20. : type(type), reference(reference)
  21. {
  22. }
  23. ctkServiceEventData(const ctkServiceEventData& other)
  24. : QSharedData(other), type(other.type), reference(other.reference)
  25. {
  26. }
  27. const ctkServiceEvent::Type type;
  28. const ctkServiceReference reference;
  29. };
  30. ctkServiceEvent::ctkServiceEvent()
  31. : d(0)
  32. {
  33. }
  34. ctkServiceEvent::~ctkServiceEvent()
  35. {
  36. }
  37. bool ctkServiceEvent::isNull() const
  38. {
  39. return !d;
  40. }
  41. ctkServiceEvent::ctkServiceEvent(Type type, const ctkServiceReference& reference)
  42. : d(new ctkServiceEventData(type, reference))
  43. {
  44. }
  45. ctkServiceEvent::ctkServiceEvent(const ctkServiceEvent& other)
  46. : d(other.d)
  47. {
  48. }
  49. ctkServiceReference ctkServiceEvent::getServiceReference() const
  50. {
  51. return d->reference;
  52. }
  53. ctkServiceEvent::Type ctkServiceEvent::getType() const
  54. {
  55. return d->type;
  56. }
  57. QDebug operator<<(QDebug dbg, ctkServiceEvent::Type type)
  58. {
  59. switch(type)
  60. {
  61. case ctkServiceEvent::MODIFIED:
  62. dbg.nospace() << "MODIFIED";
  63. break;
  64. case ctkServiceEvent::MODIFIED_ENDMATCH:
  65. dbg.nospace() << "MODIFIED_ENDMATCH";
  66. break;
  67. case ctkServiceEvent::REGISTERED:
  68. dbg.nospace() << "REGISTERED";
  69. break;
  70. case ctkServiceEvent::UNREGISTERING:
  71. dbg.nospace() << "UNREGISTERING";
  72. break;
  73. default:
  74. dbg.nospace() << "unknown event type " << static_cast<int>(type);
  75. }
  76. return dbg.maybeSpace();
  77. }