ctkExampleDerivedWorkflowStep.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.commontk.org/LICENSE
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. // CTK includes
  15. #include "ctkExampleDerivedWorkflowStep.h"
  16. //-----------------------------------------------------------------------------
  17. class ctkExampleDerivedWorkflowStepPrivate
  18. {
  19. public:
  20. ctkExampleDerivedWorkflowStepPrivate();
  21. // counters of the number of times we have run the onEntry()
  22. // and onExit() functions
  23. int numberOfTimesRanOnEntry;
  24. int numberOfTimesRanOnExit;
  25. };
  26. //-----------------------------------------------------------------------------
  27. // ctkExampleDerivedWorkflowStepPrivate methods
  28. //-----------------------------------------------------------------------------
  29. ctkExampleDerivedWorkflowStepPrivate::ctkExampleDerivedWorkflowStepPrivate()
  30. {
  31. this->numberOfTimesRanOnEntry = 0;
  32. this->numberOfTimesRanOnExit = 0;
  33. }
  34. //-----------------------------------------------------------------------------
  35. // ctkExampleDerivedWorkflowStep methods
  36. //-----------------------------------------------------------------------------
  37. ctkExampleDerivedWorkflowStep::ctkExampleDerivedWorkflowStep(ctkWorkflow* newWorkflow, const QString& newId) :
  38. Superclass(newWorkflow, newId)
  39. , d_ptr(new ctkExampleDerivedWorkflowStepPrivate)
  40. {
  41. }
  42. //-----------------------------------------------------------------------------
  43. ctkExampleDerivedWorkflowStep::~ctkExampleDerivedWorkflowStep()
  44. {
  45. }
  46. //-----------------------------------------------------------------------------
  47. void ctkExampleDerivedWorkflowStep::validate(const QString& desiredBranchId)
  48. {
  49. // Always returns true in this simple example
  50. this->validationComplete(true,desiredBranchId);
  51. }
  52. //-----------------------------------------------------------------------------
  53. void ctkExampleDerivedWorkflowStep::onEntry(
  54. const ctkWorkflowStep* comingFrom,
  55. const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType)
  56. {
  57. Q_UNUSED(comingFrom);
  58. Q_UNUSED(transitionType);
  59. // Simply implements our counter of the number of times we have run this function
  60. Q_D(ctkExampleDerivedWorkflowStep);
  61. d->numberOfTimesRanOnEntry++;
  62. // signals that we are finished
  63. this->onEntryComplete();
  64. }
  65. //-----------------------------------------------------------------------------
  66. void ctkExampleDerivedWorkflowStep::onExit(
  67. const ctkWorkflowStep* goingTo,
  68. const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType)
  69. {
  70. Q_UNUSED(goingTo);
  71. Q_UNUSED(transitionType);
  72. // simply implements our counter of the number of times we have run
  73. // this function
  74. Q_D(ctkExampleDerivedWorkflowStep);
  75. d->numberOfTimesRanOnExit++;
  76. // signals that we are finished
  77. this->onExitComplete();
  78. }
  79. //-----------------------------------------------------------------------------
  80. CTK_GET_CPP(ctkExampleDerivedWorkflowStep, int, numberOfTimesRanOnEntry, numberOfTimesRanOnEntry);
  81. CTK_GET_CPP(ctkExampleDerivedWorkflowStep, int, numberOfTimesRanOnExit, numberOfTimesRanOnExit);