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/dcmnet/assoc.h>
17 
18 #include "dcmtkpp/Association.h"
19 #include "dcmtkpp/DataSet.h"
20 #include "dcmtkpp/Message.h"
21 #include "dcmtkpp/Network.h"
22 
23 namespace dcmtkpp
24 {
25 
28 {
29 public:
31  typedef std::function<void(void *, unsigned long)> ProgressCallback;
32 
34  ServiceRole();
35 
37  ServiceRole(ServiceRole const & other);
38 
40  ServiceRole const & operator=(ServiceRole const & other);
41 
43  virtual ~ServiceRole();
44 
46  Network * get_network() const;
48  void set_network(Network * network);
49 
51  Association * get_association() const;
53  void set_association(Association * association);
54 
55 protected:
58  {
60  ProgressCallback callback;
61 
63  void * data;
64  };
65 
68 
71 
73  static void _progress_callback_wrapper(void * data, unsigned long bytes_count);
74 
76  T_ASC_PresentationContextID _find_presentation_context(
77  std::string const & abstract_syntax) const;
78 
80  void _send(
81  Message const & message, std::string const & abstract_syntax,
82  ProgressCallback callback=NULL, void* callback_data=NULL) const;
83 
85  Message _receive(ProgressCallback callback=NULL, void* callback_data=NULL) const;
86 
92  template<typename TMessage>
93  TMessage _receive(ProgressCallback callback=NULL, void* callback_data=NULL) const;
94 
95 private:
96  void _send(
97  DataSet const & obj, T_ASC_PresentationContextID presID,
98  std::string const & transfer_syntax, DUL_DATAPDV pdvType,
99  ProgressCallback callback, void *callbackContext) const;
100 
101  std::pair<DataSet, DUL_DATAPDV> _receive_dataset(
102  ProgressCallback callback, void *callbackContext) const;
103 
104  DUL_PDV _read_next_pdv() const;
105 
106  void _check_dimse_ready() const;
107 };
108 
109 }
110 
111 #include "ServiceRole.txx"
112 
113 #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:42
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:113
std::function< void(void *, unsigned long)> ProgressCallback
Progress callback, following the semantics of DCMTK.
Definition: ServiceRole.h:31
Message _receive(ProgressCallback callback=NULL, void *callback_data=NULL) const
Receive a generic DIMSE message.
Definition: ServiceRole.cpp:136
virtual ~ServiceRole()
Destructor, network and association are not modified.
Definition: ServiceRole.cpp:54
Base class for all Service Class Users and Providers.
Definition: ServiceRole.h:27
static void _progress_callback_wrapper(void *data, unsigned long bytes_count)
Wrapper from ProgressCallback to DIMSE_ProgressCallback.
Definition: ServiceRole.cpp:89
void set_association(Association *association)
Set the association used by the ServiceRole.
Definition: ServiceRole.cpp:82
T_ASC_PresentationContextID _find_presentation_context(std::string const &abstract_syntax) const
Find an accepted presentation context.
Definition: ServiceRole.cpp:98
Association * get_association() const
Return the association used by the ServiceRole.
Definition: ServiceRole.cpp:75
DICOM Data set.
Definition: DataSet.h:66
Network * _network
Network used by the ServiceRole.
Definition: ServiceRole.h:67
void * data
Callback data.
Definition: ServiceRole.h:63
Association * _association
Association used by the ServiceRole.
Definition: ServiceRole.h:70
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:27
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:68
Wrapper class for DMCTK progress callbacks.
Definition: ServiceRole.h:57
Network * get_network() const
Return the network used by the ServiceRole.
Definition: ServiceRole.cpp:61
ProgressCallback callback
Callback function.
Definition: ServiceRole.h:60