Mercurial > hg > orthanc
changeset 772:31cc399c7762
RemoteModalityParameters
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 30 Apr 2014 14:51:43 +0200 |
parents | 537837f50fbb |
children | 3bd0589af992 |
files | OrthancServer/DicomProtocol/DicomUserConnection.cpp OrthancServer/DicomProtocol/DicomUserConnection.h OrthancServer/DicomProtocol/RemoteModalityParameters.h OrthancServer/DicomProtocol/ReusableDicomUserConnection.cpp OrthancServer/DicomProtocol/ReusableDicomUserConnection.h OrthancServer/OrthancInitialization.cpp OrthancServer/OrthancInitialization.h OrthancServer/OrthancMoveRequestHandler.cpp |
diffstat | 8 files changed, 183 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancServer/DicomProtocol/DicomUserConnection.cpp Wed Apr 30 14:15:26 2014 +0200 +++ b/OrthancServer/DicomProtocol/DicomUserConnection.cpp Wed Apr 30 14:51:43 2014 +0200 @@ -619,6 +619,16 @@ Close(); } + + void DicomUserConnection::Connect(const RemoteModalityParameters& parameters) + { + SetDistantApplicationEntityTitle(parameters.GetApplicationEntityTitle()); + SetDistantHost(parameters.GetHost()); + SetDistantPort(parameters.GetPort()); + SetDistantManufacturer(parameters.GetManufacturer()); + } + + void DicomUserConnection::SetLocalApplicationEntityTitle(const std::string& aet) { if (localAet_ != aet)
--- a/OrthancServer/DicomProtocol/DicomUserConnection.h Wed Apr 30 14:15:26 2014 +0200 +++ b/OrthancServer/DicomProtocol/DicomUserConnection.h Wed Apr 30 14:51:43 2014 +0200 @@ -34,6 +34,7 @@ #include "DicomFindAnswers.h" #include "../ServerEnumerations.h" +#include "RemoteModalityParameters.h" #include <stdint.h> #include <boost/shared_ptr.hpp> @@ -87,6 +88,8 @@ ~DicomUserConnection(); + void Connect(const RemoteModalityParameters& parameters); + void SetLocalApplicationEntityTitle(const std::string& aet); const std::string& GetLocalApplicationEntityTitle() const
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OrthancServer/DicomProtocol/RemoteModalityParameters.h Wed Apr 30 14:51:43 2014 +0200 @@ -0,0 +1,112 @@ +/** + * Orthanc - A Lightweight, RESTful DICOM Store + * Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege, + * Belgium + * + * This program is free software: you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * In addition, as a special exception, the copyright holders of this + * program give permission to link the code of its release with the + * OpenSSL project's "OpenSSL" library (or with modified versions of it + * that use the same license as the "OpenSSL" library), and distribute + * the linked executables. You must obey the GNU General Public License + * in all respects for all of the code used other than "OpenSSL". If you + * modify file(s) with this exception, you may extend this exception to + * your version of the file(s), but you are not obligated to do so. If + * you do not wish to do so, delete this exception statement from your + * version. If you delete this exception statement from all source files + * in the program, then also delete it here. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + **/ + + +#pragma once + +#include "../ServerEnumerations.h" + +#include <string> + +namespace Orthanc +{ + class RemoteModalityParameters + { + // TODO Use the flyweight pattern for this class + + private: + std::string symbolicName_; + std::string aet_; + std::string host_; + int port_; + ModalityManufacturer manufacturer_; + + public: + RemoteModalityParameters() : + symbolicName_(""), + aet_(""), + host_(""), + port_(104), + manufacturer_(ModalityManufacturer_Generic) + { + } + + RemoteModalityParameters(const std::string& symbolic, + const std::string& aet, + const std::string& host, + int port, + ModalityManufacturer manufacturer) : + symbolicName_(symbolic), + aet_(aet), + host_(host), + port_(port), + manufacturer_(manufacturer) + { + } + + RemoteModalityParameters(const std::string& aet, + const std::string& host, + int port, + ModalityManufacturer manufacturer) : + symbolicName_(""), + aet_(aet), + host_(host), + port_(port), + manufacturer_(manufacturer) + { + } + + const std::string& GetSymbolicName() const + { + return symbolicName_; + } + + const std::string& GetApplicationEntityTitle() const + { + return aet_; + } + + const std::string& GetHost() const + { + return host_; + } + + int GetPort() const + { + return port_; + } + + ModalityManufacturer GetManufacturer() const + { + return manufacturer_; + } + }; +}
--- a/OrthancServer/DicomProtocol/ReusableDicomUserConnection.cpp Wed Apr 30 14:15:26 2014 +0200 +++ b/OrthancServer/DicomProtocol/ReusableDicomUserConnection.cpp Wed Apr 30 14:51:43 2014 +0200 @@ -101,18 +101,28 @@ } } - ReusableDicomUserConnection::Connection::Connection - (ReusableDicomUserConnection& that, - const std::string& aet, - const std::string& address, - int port, - ModalityManufacturer manufacturer) : + ReusableDicomUserConnection::Connection::Connection(ReusableDicomUserConnection& that, + const std::string& aet, + const std::string& address, + int port, + ModalityManufacturer manufacturer) : Locker(that) { that.Open(aet, address, port, manufacturer); connection_ = that.connection_; } + + ReusableDicomUserConnection::Connection::Connection(ReusableDicomUserConnection& that, + const RemoteModalityParameters& remote) : + Locker(that) + { + that.Open(remote.GetApplicationEntityTitle(), remote.GetHost(), + remote.GetPort(), remote.GetManufacturer()); + connection_ = that.connection_; + } + + DicomUserConnection& ReusableDicomUserConnection::Connection::GetConnection() { if (connection_ == NULL)
--- a/OrthancServer/DicomProtocol/ReusableDicomUserConnection.h Wed Apr 30 14:15:26 2014 +0200 +++ b/OrthancServer/DicomProtocol/ReusableDicomUserConnection.h Wed Apr 30 14:51:43 2014 +0200 @@ -73,6 +73,9 @@ public: Connection(ReusableDicomUserConnection& that, + const RemoteModalityParameters& remote); + + Connection(ReusableDicomUserConnection& that, const std::string& aet, const std::string& address, int port,
--- a/OrthancServer/OrthancInitialization.cpp Wed Apr 30 14:15:26 2014 +0200 +++ b/OrthancServer/OrthancInitialization.cpp Wed Apr 30 14:51:43 2014 +0200 @@ -585,4 +585,34 @@ return LookupDicomModalityUsingAETitle(aet, symbolicName, address, port, manufacturer); } + + + + RemoteModalityParameters GetModalityUsingSymbolicName(const std::string& name) + { + std::string aet, address; + int port; + ModalityManufacturer manufacturer; + + GetDicomModalityUsingSymbolicName(name, aet, address, port, manufacturer); + + return RemoteModalityParameters(name, aet, address, port, manufacturer); + } + + RemoteModalityParameters GetModalityUsingAet(const std::string& aet) + { + std::string name, address; + int port; + ModalityManufacturer manufacturer; + + if (LookupDicomModalityUsingAETitle(aet, name, address, port, manufacturer)) + { + return RemoteModalityParameters(name, aet, address, port, manufacturer); + } + else + { + throw OrthancException("Unknown modality for AET: " + aet); + } + + } }
--- a/OrthancServer/OrthancInitialization.h Wed Apr 30 14:15:26 2014 +0200 +++ b/OrthancServer/OrthancInitialization.h Wed Apr 30 14:51:43 2014 +0200 @@ -93,4 +93,8 @@ bool IsSameAETitle(const std::string& aet1, const std::string& aet2); + + RemoteModalityParameters GetModalityUsingSymbolicName(const std::string& name); + + RemoteModalityParameters GetModalityUsingAet(const std::string& aet); }
--- a/OrthancServer/OrthancMoveRequestHandler.cpp Wed Apr 30 14:15:26 2014 +0200 +++ b/OrthancServer/OrthancMoveRequestHandler.cpp Wed Apr 30 14:51:43 2014 +0200 @@ -33,7 +33,6 @@ #include <glog/logging.h> -#include "DicomProtocol/DicomUserConnection.h" #include "OrthancInitialization.h" namespace Orthanc @@ -48,18 +47,14 @@ ServerContext& context_; std::vector<std::string> instances_; size_t position_; - - std::string aet_, address_; - int port_; - ModalityManufacturer manufacturer_; + RemoteModalityParameters remote_; public: OrthancMoveRequestIterator(ServerContext& context, const std::string& aet, const std::string& publicId) : context_(context), - position_(0), - aet_(aet) + position_(0) { LOG(INFO) << "Sending resource " << publicId << " to modality \"" << aet << "\""; @@ -72,11 +67,7 @@ instances_.push_back(*it); } - std::string symbolicName; - if (!LookupDicomModalityUsingAETitle(aet_, symbolicName, address_, port_, manufacturer_)) - { - throw OrthancException("Unknown modality: " + aet_); - } + remote_ = GetModalityUsingAet(aet); } virtual unsigned int GetSubOperationCount() const @@ -97,8 +88,8 @@ context_.ReadFile(dicom, id, FileContentType_Dicom); { - ReusableDicomUserConnection::Connection connection(context_.GetReusableDicomUserConnection(), - aet_, address_, port_, manufacturer_); + ReusableDicomUserConnection::Connection connection + (context_.GetReusableDicomUserConnection(), remote_); connection.GetConnection().Store(dicom); }