GDCM
2.2.3
|
00001 /*========================================================================= 00002 * 00003 * Copyright Insight Software Consortium 00004 * 00005 * Licensed under the Apache License, Version 2.0 (the "License"); 00006 * you may not use this file except in compliance with the License. 00007 * You may obtain a copy of the License at 00008 * 00009 * http://www.apache.org/licenses/LICENSE-2.0.txt 00010 * 00011 * Unless required by applicable law or agreed to in writing, software 00012 * distributed under the License is distributed on an "AS IS" BASIS, 00013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00014 * See the License for the specific language governing permissions and 00015 * limitations under the License. 00016 * 00017 *=========================================================================*/ 00018 #ifndef GDCMULTRANSITIONTABLE_H 00019 #define GDCMULTRANSITIONTABLE_H 00020 00021 #include "gdcmNetworkStateID.h" 00022 #include "gdcmNetworkEvents.h" 00023 #include "gdcmULAction.h" 00024 00025 #include <cstdlib> // NULL 00026 00027 namespace gdcm { 00028 class Subject; 00029 namespace network{ 00030 class ULConnection; 00031 class ULAction; 00032 class ULEvent; 00033 00034 //The transition dictates the action that should be taken from the start state to the end state 00035 struct Transition { 00036 int mEnd; 00037 ULAction* mAction; 00038 Transition(){ 00039 mEnd = eStaDoesNotExist; 00040 mAction = NULL; 00041 } 00042 ~Transition(){ 00043 if (mAction != NULL){ 00044 delete mAction; 00045 mAction = NULL; 00046 } 00047 } 00048 Transition(int inEndState, ULAction* inAction){ 00049 mEnd = inEndState; 00050 mAction = inAction; 00051 } 00052 static Transition* MakeNew(int inEndState, ULAction* inAction){ 00053 return new Transition(inEndState, inAction); 00054 } 00055 }; 00056 00057 //used to define a row in table 9-10 of 3.8 2009 00058 //the transition table is events, then state, 00059 //then the transition itself (which has the event 00060 //and start state implied by their starting locations) 00061 //don't need to store the event; that's implicitly defined in the Table itself by location 00062 class TableRow{ 00063 public: 00064 TableRow() { 00065 for(int stateIndex = 0; stateIndex < cMaxStateID; ++stateIndex) 00066 { 00067 transitions[stateIndex] = NULL; 00068 } 00069 } 00070 ~TableRow() { 00071 for(int stateIndex = 0; stateIndex < cMaxStateID; ++stateIndex) 00072 { 00073 Transition *t = transitions[stateIndex]; 00074 delete t; 00075 } 00076 } 00077 Transition *transitions[cMaxStateID]; 00078 00079 //copy constructor for stl additions into the transition table below. 00080 }; 00081 00098 class ULTransitionTable 00099 { 00100 private: 00101 TableRow mTable[cMaxEventID]; 00102 public: 00103 ULTransitionTable(); 00104 00105 void HandleEvent(Subject*s,ULEvent& inEvent, ULConnection& inConnection, 00106 bool& outWaitingForEvent, EEventID& outRaisedEvent) const; 00107 00108 void PrintTable() const; //so that the table can be printed and verified against the DICOM standard 00109 }; 00110 } 00111 } 00112 #endif // GDCMULTRANSITIONTABLE_H