ctkExampleDerivedWorkflowStep.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) 2010 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 : public ctkPrivate<ctkExampleDerivedWorkflowStep>
  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. {
  40. CTK_INIT_PRIVATE(ctkExampleDerivedWorkflowStep);
  41. }
  42. //-----------------------------------------------------------------------------
  43. void ctkExampleDerivedWorkflowStep::validate(const QString& desiredBranchId)
  44. {
  45. // Always returns true in this simple example
  46. this->validationComplete(true,desiredBranchId);
  47. }
  48. //-----------------------------------------------------------------------------
  49. void ctkExampleDerivedWorkflowStep::onEntry(
  50. const ctkWorkflowStep* comingFrom,
  51. const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType)
  52. {
  53. Q_UNUSED(comingFrom);
  54. Q_UNUSED(transitionType);
  55. // Simply implements our counter of the number of times we have run this function
  56. CTK_D(ctkExampleDerivedWorkflowStep);
  57. d->numberOfTimesRanOnEntry++;
  58. // signals that we are finished
  59. this->onEntryComplete();
  60. }
  61. //-----------------------------------------------------------------------------
  62. void ctkExampleDerivedWorkflowStep::onExit(
  63. const ctkWorkflowStep* goingTo,
  64. const ctkWorkflowInterstepTransition::InterstepTransitionType transitionType)
  65. {
  66. Q_UNUSED(goingTo);
  67. Q_UNUSED(transitionType);
  68. // simply implements our counter of the number of times we have run
  69. // this function
  70. CTK_D(ctkExampleDerivedWorkflowStep);
  71. d->numberOfTimesRanOnExit++;
  72. // signals that we are finished
  73. this->onExitComplete();
  74. }
  75. //-----------------------------------------------------------------------------
  76. CTK_GET_CXX(ctkExampleDerivedWorkflowStep, int, numberOfTimesRanOnEntry, numberOfTimesRanOnEntry);
  77. CTK_GET_CXX(ctkExampleDerivedWorkflowStep, int, numberOfTimesRanOnExit, numberOfTimesRanOnExit);