1 /*=========================================================================
2 *
3 * Copyright Insight Software Consortium
4 *
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 *
9 * http://www.apache.org/licenses/LICENSE-2.0.txt
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 *
17 *=========================================================================*/
18 /*
19 This file contains the implementation for the classes for the AA Actions,
20 Association Abort Related Actions (Table 9-9 of ps 3.8-2009).
21
22 Since each class is essentially a placeholder for a function pointer, I'm breaking with having
23 each class have its own file for the sake of brevity of the number of files.
24
25 */
26
27 #include "gdcmULActionAA.h"
28 #include "gdcmARTIMTimer.h"
29 #include "gdcmAAbortPDU.h"
30 #include <socket++/echo.h>
31
32 namespace gdcm
33 {
34 namespace network
35 {
36
37 //Send A-ABORT PDU (service-user source) and start (or restart if already started) ARTIM timer
PerformAction(Subject *,ULEvent &,ULConnection & inConnection,bool &,EEventID &)38 EStateID ULActionAA1::PerformAction(Subject *, ULEvent& , ULConnection& inConnection,
39 bool& , EEventID& ){
40
41 AAbortPDU thePDU;
42 thePDU.Write(*inConnection.GetProtocol());
43 inConnection.GetTimer().Start();
44
45 return eSta13AwaitingClose;
46 }
47
48 //Stop ARTIM timer if running. Close transport connection.
PerformAction(Subject *,ULEvent &,ULConnection & inConnection,bool &,EEventID &)49 EStateID ULActionAA2::PerformAction(Subject *, ULEvent& , ULConnection& inConnection,
50 bool& , EEventID& ){
51
52
53 inConnection.GetTimer().Stop();
54 inConnection.StopProtocol();
55
56 return eSta1Idle;
57 }
58
59 //If (service-user initiated abort)
60 //- issue A-ABORT indication and close transport connection
61 //otherwise (service-provider initiated abort):
62 //- issue A-P-ABORT indication and close transport connection
PerformAction(Subject *,ULEvent &,ULConnection &,bool &,EEventID &)63 EStateID ULActionAA3::PerformAction(Subject *, ULEvent& , ULConnection& ,
64 bool& , EEventID& ){
65
66 return eSta1Idle;
67 }
68
69 //Issue A-P-ABORT indication primitive
PerformAction(Subject *,ULEvent &,ULConnection &,bool &,EEventID &)70 EStateID ULActionAA4::PerformAction(Subject *, ULEvent& , ULConnection& ,
71 bool& , EEventID& ){
72
73 return eSta1Idle;
74 }
75
76 //Stop ARTIM timer
PerformAction(Subject *,ULEvent &,ULConnection & inConnection,bool &,EEventID &)77 EStateID ULActionAA5::PerformAction(Subject *, ULEvent& , ULConnection& inConnection,
78 bool& , EEventID& ){
79
80 inConnection.GetTimer().Stop();
81
82 return eSta1Idle;
83 }
84
85 //Ignore PDU
PerformAction(Subject *,ULEvent &,ULConnection &,bool &,EEventID &)86 EStateID ULActionAA6::PerformAction(Subject *, ULEvent& , ULConnection& ,
87 bool& , EEventID& ){
88 //do nothing, I guess.
89 return eSta13AwaitingClose;
90 }
91
92 //Send A-ABORT PDU
PerformAction(Subject *,ULEvent &,ULConnection & inConnection,bool &,EEventID &)93 EStateID ULActionAA7::PerformAction(Subject *, ULEvent& , ULConnection& inConnection,
94 bool& , EEventID& ){
95
96 AAbortPDU thePDU;//for now, use Matheiu's default values
97 thePDU.Write(*inConnection.GetProtocol());
98
99 return eSta13AwaitingClose;
100 }
101
102 //Send A-ABORT PDU (service-provider source), issue an A-P-ABORT indication, and start ARTIM timer
PerformAction(Subject *,ULEvent &,ULConnection & inConnection,bool &,EEventID &)103 EStateID ULActionAA8::PerformAction(Subject *, ULEvent& , ULConnection& inConnection,
104 bool& , EEventID& ){
105
106
107 AAbortPDU thePDU;//for now, use Matheiu's default values
108 thePDU.Write(*inConnection.GetProtocol());
109 inConnection.GetTimer().Start();
110
111 return eSta13AwaitingClose;
112 }
113 } // end namespace network
114 } // end namespace gdcm
115