00001 /*========================================================================= 00002 00003 Program: Medical Imaging & Interaction Toolkit 00004 Language: C++ 00005 Date: $Date$ 00006 Version: $Revision$ 00007 00008 Copyright (c) German Cancer Research Center, Division of Medical and 00009 Biological Informatics. All rights reserved. 00010 See MITKCopyright.txt or https://www.mitk.org/copyright.html for details. 00011 00012 This software is distributed WITHOUT ANY WARRANTY; without even 00013 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00014 PURPOSE. See the above copyright notices for more information. 00015 00016 =========================================================================*/ 00017 00018 00019 #include "mitkTransition.h" 00020 #include "mitkState.h" 00021 00022 mitk::Transition::Transition(std::string name, int nextStateId, int eventId ) 00023 : m_Name(name), m_NextState(NULL), m_NextStateId(nextStateId), m_EventId(eventId) 00024 {} 00025 00026 mitk::Transition::~Transition() 00027 { 00028 //needed for correct reference counting of mitkState 00029 m_NextState = NULL; 00030 m_Actions.clear(); 00031 } 00032 00033 void mitk::Transition::AddAction( Action* action ) 00034 { 00035 m_Actions.push_back( action ); 00036 } 00037 00038 std::string mitk::Transition::GetName() const 00039 { 00040 return m_Name; 00041 } 00042 00043 mitk::State* mitk::Transition::GetNextState() const 00044 { 00045 return m_NextState.GetPointer(); 00046 } 00047 00048 int mitk::Transition::GetNextStateId() const 00049 { 00050 return m_NextStateId; 00051 } 00052 00053 int mitk::Transition::GetEventId() const 00054 { 00055 return m_EventId; 00056 } 00057 00058 unsigned int mitk::Transition::GetActionCount() const 00059 { 00060 return static_cast<unsigned int>(m_Actions.size()); 00061 } 00062 00063 00064 mitk::Transition::ActionVectorIterator mitk::Transition::GetActionBeginIterator() const 00065 { 00066 return m_Actions.begin(); 00067 } 00068 00069 mitk::Transition::ActionVectorConstIterator mitk::Transition::GetActionEndIterator() const 00070 { 00071 return m_Actions.end(); 00072 } 00073 00074 bool mitk::Transition::IsEvent(int eventId) const 00075 { 00076 return (eventId == m_EventId); 00077 } 00078 00079 void mitk::Transition::SetNextState(State* state) 00080 { 00081 m_NextState = state; 00082 } 00083