1 /* 2 * 3 * Copyright (C) 1993-2018, OFFIS e.V. 4 * All rights reserved. See COPYRIGHT file for details. 5 * 6 * This software and supporting documentation were developed by 7 * 8 * OFFIS e.V. 9 * R&D Division Health 10 * Escherweg 2 11 * D-26121 Oldenburg, Germany 12 * 13 * 14 * Module: dcmqrdb 15 * 16 * Author: Marco Eichelberg 17 * 18 * Purpose: class DcmQueryRetrieveMoveContext 19 * 20 */ 21 22 #ifndef DCMQRCBM_H 23 #define DCMQRCBM_H 24 25 #include "dcmtk/config/osconfig.h" /* make sure OS specific configuration is included first */ 26 #include "dcmtk/dcmnet/dimse.h" 27 #include "dcmtk/dcmnet/dcasccfg.h" 28 #include "dcmtk/dcmqrdb/qrdefine.h" 29 30 class DcmQueryRetrieveDatabaseHandle; 31 class DcmQueryRetrieveOptions; 32 class DcmQueryRetrieveConfig; 33 class DcmQueryRetrieveDatabaseStatus; 34 35 /** this class maintains the context information that is passed to the 36 * callback function called by DIMSE_moveProvider. 37 */ 38 class DCMTK_DCMQRDB_EXPORT DcmQueryRetrieveMoveContext 39 { 40 public: 41 /** constructor 42 * @param handle reference to database handle 43 * @param options options for the Q/R service 44 * @param cfg configuration for the Q/R service 45 * @param priorstatus prior DIMSE status 46 * @param assoc pointer to DIMSE association 47 * @param msgid DIMSE message ID 48 * @param pr DIMSE priority 49 */ DcmQueryRetrieveMoveContext(DcmQueryRetrieveDatabaseHandle & handle,const DcmQueryRetrieveOptions & options,const DcmAssociationConfiguration & associationConfiguration,const DcmQueryRetrieveConfig * cfg,DIC_US priorstatus,T_ASC_Association * assoc,DIC_US msgid,T_DIMSE_Priority pr)50 DcmQueryRetrieveMoveContext( 51 DcmQueryRetrieveDatabaseHandle& handle, 52 const DcmQueryRetrieveOptions& options, 53 const DcmAssociationConfiguration& associationConfiguration, 54 const DcmQueryRetrieveConfig *cfg, 55 DIC_US priorstatus, 56 T_ASC_Association *assoc, 57 DIC_US msgid, 58 T_DIMSE_Priority pr) 59 : dbHandle(handle) 60 , options_(options) 61 , associationConfiguration_(associationConfiguration) 62 , priorStatus(priorstatus) 63 , origAssoc(assoc) 64 , subAssoc(NULL) 65 , config(cfg) 66 , assocStarted(OFFalse) 67 , origMsgId(msgid) 68 // , origAETitle() 69 // , origHostName() 70 , priority(pr) 71 , ourAETitle() 72 // , dstAETitle() 73 , failedUIDs(NULL) 74 , nRemaining(0) 75 , nCompleted(0) 76 , nFailed(0) 77 , nWarning(0) 78 { 79 origAETitle[0] = '\0'; 80 origHostName[0] = '\0'; 81 dstAETitle[0] = '\0'; 82 } 83 84 /** callback handler called by the DIMSE_storeProvider callback function. 85 * @param cancelled (in) flag indicating whether a C-CANCEL was received 86 * @param request original move request (in) 87 * @param requestIdentifiers original move request identifiers (in) 88 * @param responseCount move response count (in) 89 * @param response move response (out) 90 * @param stDetail status detail for move response (out) 91 * @param responseIdentifiers move response identifiers (out) 92 */ 93 void callbackHandler( 94 /* in */ 95 OFBool cancelled, T_DIMSE_C_MoveRQ *request, 96 DcmDataset *requestIdentifiers, int responseCount, 97 /* out */ 98 T_DIMSE_C_MoveRSP *response, DcmDataset **stDetail, 99 DcmDataset **responseIdentifiers); 100 101 /** set the AEtitle under which this application operates 102 * @param ae AEtitle, is copied into this object. 103 */ setOurAETitle(const char * ae)104 void setOurAETitle(const char *ae) 105 { 106 if (ae) ourAETitle = ae; else ourAETitle.clear(); 107 } 108 109 private: 110 111 /// private undefined copy constructor 112 DcmQueryRetrieveMoveContext(const DcmQueryRetrieveMoveContext& other); 113 114 /// private undefined assignment operator 115 DcmQueryRetrieveMoveContext& operator=(const DcmQueryRetrieveMoveContext& other); 116 117 void addFailedUIDInstance(const char *sopInstance); 118 OFCondition performMoveSubOp(DIC_UI sopClass, DIC_UI sopInstance, char *fname); 119 OFCondition buildSubAssociation(T_DIMSE_C_MoveRQ *request); 120 OFCondition closeSubAssociation(); 121 void moveNextImage(DcmQueryRetrieveDatabaseStatus * dbStatus); 122 void failAllSubOperations(DcmQueryRetrieveDatabaseStatus * dbStatus); 123 void buildFailedInstanceList(DcmDataset ** rspIds); 124 OFBool mapMoveDestination( 125 const char *origPeer, const char *origAE, 126 const char *dstAE, char *dstPeer, size_t dstPeerLen, int *dstPort); 127 OFCondition addAllStoragePresentationContexts(T_ASC_Parameters *params); 128 129 /// reference to database handle 130 DcmQueryRetrieveDatabaseHandle& dbHandle; 131 132 /// reference to Q/R service options 133 const DcmQueryRetrieveOptions& options_; 134 135 /// reference to association configuration 136 const DcmAssociationConfiguration& associationConfiguration_; 137 138 /// prior DIMSE status 139 DIC_US priorStatus; 140 141 /// pointer to original association on which the C-MOVE-RQ was received 142 T_ASC_Association *origAssoc; /* association of requestor */ 143 144 /// pointer to sub-association for outgoing C-STORE-RQ 145 T_ASC_Association *subAssoc; /* sub-association */ 146 147 /// pointer to Q/R configuration 148 const DcmQueryRetrieveConfig *config; 149 150 /// true if the association was started 151 OFBool assocStarted; 152 153 /// message id of request 154 DIC_US origMsgId; 155 156 /// title of requestor 157 DIC_AE origAETitle; 158 159 /// hostname of move requestor 160 DIC_NODENAME origHostName; 161 162 /// priority of move request 163 T_DIMSE_Priority priority; 164 165 /// our current title 166 OFString ourAETitle; 167 168 /// destination title for move 169 DIC_AE dstAETitle; 170 171 /// instance UIDs of failed store sub-ops 172 char *failedUIDs; 173 174 /// number of remaining sub-operations 175 DIC_US nRemaining; 176 177 /// number of completed sub-operations 178 DIC_US nCompleted; 179 180 /// number of failed sub-operations 181 DIC_US nFailed; 182 183 /// number of completed sub-operations that causes warnings 184 DIC_US nWarning; 185 186 }; 187 188 #endif 189