dcmtkpp
ServiceRole.h
1 /*************************************************************************
2  * dcmtkpp - Copyright (C) Universite de Strasbourg
3  * Distributed under the terms of the CeCILL-B license, as published by
4  * the CEA-CNRS-INRIA. Refer to the LICENSE file or to
5  * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
6  * for details.
7  ************************************************************************/
8 
9 #ifndef _fa7d372a_dd27_4a1e_9b29_be9d5fbe602a
10 #define _fa7d372a_dd27_4a1e_9b29_be9d5fbe602a
11 
12 #include <functional>
13 #include <utility>
14 
15 #include <dcmtk/config/osconfig.h>
16 #include <dcmtk/dcmdata/dcdatset.h>
17 #include <dcmtk/dcmnet/assoc.h>
18 
19 #include "dcmtkpp/Association.h"
20 #include "dcmtkpp/DataSet.h"
21 #include "dcmtkpp/Message.h"
22 #include "dcmtkpp/Network.h"
23 
24 namespace dcmtkpp
25 {
26 
29 {
30 public:
32  typedef std::function<void(void *, unsigned long)> ProgressCallback;
33 
35  ServiceRole();
36 
38  ServiceRole(ServiceRole const & other);
39 
41  ServiceRole const & operator=(ServiceRole const & other);
42 
44  virtual ~ServiceRole();
45 
47  Network * get_network() const;
49  void set_network(Network * network);
50 
52  Association * get_association() const;
54  void set_association(Association * association);
55 
56 protected:
59  {
61  ProgressCallback callback;
62 
64  void * data;
65  };
66 
69 
72 
74  static void _progress_callback_wrapper(void * data, unsigned long bytes_count);
75 
77  T_ASC_PresentationContextID _find_presentation_context(
78  std::string const & abstract_syntax) const;
79 
81  void _send(
82  Message const & message, std::string const & abstract_syntax,
83  ProgressCallback callback=NULL, void* callback_data=NULL) const;
84 
86  Message _receive(ProgressCallback callback=NULL, void* callback_data=NULL) const;
87 
93  template<typename TMessage>
94  TMessage _receive(ProgressCallback callback=NULL, void* callback_data=NULL) const;
95 
96 private:
97  OFCondition _send(
98  DcmDataset *obj, T_ASC_PresentationContextID presID,
99  E_TransferSyntax xferSyntax, DUL_DATAPDV pdvType,
100  ProgressCallback callback, void *callbackContext) const;
101 
102  std::pair<DcmDataset, DUL_DATAPDV> _receive_dataset(
103  ProgressCallback callback, void *callbackContext) const;
104 
105  DUL_PDV _read_next_pdv() const;
106 
107  void _check_dimse_ready() const;
108 };
109 
110 }
111 
112 #include "ServiceRole.txx"
113 
114 #endif // _fa7d372a_dd27_4a1e_9b29_be9d5fbe602a
Wrapper around the T_ASC_Network class.
Definition: Network.h:23
ServiceRole const & operator=(ServiceRole const &other)
Copy the other service role.
Definition: ServiceRole.cpp:48
Definition: Association.cpp:22
void _send(Message const &message, std::string const &abstract_syntax, ProgressCallback callback=NULL, void *callback_data=NULL) const
Send a DIMSE message.
Definition: ServiceRole.cpp:119
std::function< void(void *, unsigned long)> ProgressCallback
Progress callback, following the semantics of DCMTK.
Definition: ServiceRole.h:32
Message _receive(ProgressCallback callback=NULL, void *callback_data=NULL) const
Receive a generic DIMSE message.
Definition: ServiceRole.cpp:150
virtual ~ServiceRole()
Destructor, network and association are not modified.
Definition: ServiceRole.cpp:60
Base class for all Service Class Users and Providers.
Definition: ServiceRole.h:28
static void _progress_callback_wrapper(void *data, unsigned long bytes_count)
Wrapper from ProgressCallback to DIMSE_ProgressCallback.
Definition: ServiceRole.cpp:95
void set_association(Association *association)
Set the association used by the ServiceRole.
Definition: ServiceRole.cpp:88
T_ASC_PresentationContextID _find_presentation_context(std::string const &abstract_syntax) const
Find an accepted presentation context.
Definition: ServiceRole.cpp:104
Association * get_association() const
Return the association used by the ServiceRole.
Definition: ServiceRole.cpp:81
Network * _network
Network used by the ServiceRole.
Definition: ServiceRole.h:68
void * data
Callback data.
Definition: ServiceRole.h:64
Association * _association
Association used by the ServiceRole.
Definition: ServiceRole.h:71
Base class for all DIMSE messages.
Definition: Message.h:72
ServiceRole()
Create a default Service Role with no network and no association.
Definition: ServiceRole.cpp:33
Wrapper around the T_ASC_Association class.
Definition: Association.h:39
void set_network(Network *network)
Set the network used by the ServiceRole.
Definition: ServiceRole.cpp:74
Wrapper class for DMCTK progress callbacks.
Definition: ServiceRole.h:58
Network * get_network() const
Return the network used by the ServiceRole.
Definition: ServiceRole.cpp:67
ProgressCallback callback
Callback function.
Definition: ServiceRole.h:61