GDCM 2.2.0

- Main Page
- Related Pages
- Namespaces
- Classes
- Files
- Directories
- Examples

- File List
- File Members

gdcmULConnectionManager.h
Go to the documentation of this file.

    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 GDCMULCONNECTIONMANAGER_H
    00019 #define GDCMULCONNECTIONMANAGER_H
    00020
    00021 #include "gdcmULTransitionTable.h"
    00022 #include "gdcmULConnection.h"
    00023 #include "gdcmULConnectionInfo.h"
    00024 #include "gdcmPresentationDataValue.h"
    00025 #include "gdcmULConnectionCallback.h"
    00026 #include "gdcmSubject.h"
    00027 #include "gdcmPresentationContext.h"
    00028
    00029 namespace gdcm {
    00030   class File;
    00031   class BaseRootQuery;
    00032
    00033   namespace network {
    00034
    00044   class GDCM_EXPORT ULConnectionManager : public Subject
    00045   {
    00046     private:
    00047       ULConnection* mConnection;
    00048       ULConnection* mSecondaryConnection;
    00049       ULTransitionTable mTransitions;
    00050
    00051       //no copying
    00052       ULConnectionManager(const ULConnectionManager& inCM);
    00053
    00054       //event handler loop.
    00055       //will just keep running until the current event is nonexistent.
    00056       //at which point, it will return the current state of the connection
    00057       //this starts by initiating an action, but can be put into a passive mode
    00058       //for a cmove/cstore combination by setting startWaiting to true
    00059       EStateID RunEventLoop(ULEvent& inEvent, ULConnection* inWhichConnection,
    00060         ULConnectionCallback* inCallback, const bool& startWaiting);
    00061
    00062       //like the above, but will manage the event loop for a move event (which
    00063       //is basically two simultaneous connections interwoven, one inbound and
    00064       //the other outbound.  Note, for instance, that cmoversp's can be sent back
    00065       //during the other connection's operation.
    00066       EStateID RunMoveEventLoop(ULEvent& inEvent, ULConnectionCallback* inCallback);
    00067
    00068     public:
    00069       ULConnectionManager();
    00070       ~ULConnectionManager();
    00071
    00072       // NOTE: (MM) The following two functions are difficults to use, therefore marking
    00073       // them as internal for now.
    00074
    00075       // \internal
    00083       bool EstablishConnection(const std::string& inAETitle,
    00084         const std::string& inConnectAETitle,
    00085         const std::string& inComputerName, long inIPAddress,
    00086         uint16_t inConnectPort, double inTimeout,
    00087         std::vector<PresentationContext> const & pcVector );
    00088
    00091       bool EstablishConnectionMove(const std::string& inAETitle,
    00092         const std::string& inConnectAETitle,
    00093         const std::string& inComputerName, long inIPAddress,
    00094         uint16_t inConnectPort, double inTimeout,
    00095         uint16_t inReturnPort,
    00096         std::vector<PresentationContext> const & pcVector);
    00097       // \endinternal
    00098
    00099
    00100       //bool ReestablishConnection(const EConnectionType& inConnectionType,
    00101       //  const DataSet& inDS);
    00102
    00103       //allows for a connection to be broken, but waits for an acknowledgement
    00104       //of the breaking for a certain amount of time.  Returns true of the
    00105       //other side acknowledges the break
    00106       bool BreakConnection(const double& inTimeout);
    00107
    00108       //severs the connection, if it's open, without waiting for any kind of response.
    00109       //typically done if the program is going down.
    00110       void BreakConnectionNow();
    00111
    00112       //This function will send a given piece of data
    00113       //across the network connection.  It will return true if the
    00114       //sending worked, false otherwise.
    00115       //note that sending is asynchronous; as such, there's
    00116       //also a 'receive' option, but that requires a callback function.
    00117       //bool SendData();
    00118
    00119       //send the Data PDU associated with Echo (ie, a default DataPDU)
    00120       //this lets the user confirm that the connection is alive.
    00121       //the user should look to cout to see the response of the echo command
    00122       //returns the PresentationDataValue that was returned by the remote
    00123       //host.  Note that the PDV can be uninitialized, which would indicate failure.
    00124       //Echo does not use a callback for results.
    00125       std::vector<PresentationDataValue> SendEcho();
    00126
    00127       // \internal
    00128       // API will change...
    00129       std::vector<DataSet> SendStore(const File &file);
    00130       std::vector<DataSet> SendFind(const BaseRootQuery* inRootQuery);
    00131       std::vector<DataSet> SendMove(const BaseRootQuery* inRootQuery);
    00132       // \endinternal
    00133
    00135       void SendStore(const File & file, ULConnectionCallback* inCallback);
    00136       void SendFind(const BaseRootQuery* inRootQuery, ULConnectionCallback* inCallback);
    00137       void SendMove(const BaseRootQuery* inRootQuery, ULConnectionCallback* inCallback);
    00138
    00139     };
    00140   }
    00141 }
    00142
    00143 #endif // GDCMULCONNECTIONMANAGER_H