# HG changeset patch # User Sebastien Jodogne # Date 1404476054 -7200 # Node ID 13e230bbd882cea26f70f4a3997218f590ba6ae8 # Parent db18c071fbd7dcc32d0e57c70f1c834f1a52a836 rename filter to command diff -r db18c071fbd7 -r 13e230bbd882 CMakeLists.txt --- a/CMakeLists.txt Fri Jul 04 14:09:53 2014 +0200 +++ b/CMakeLists.txt Fri Jul 04 14:14:14 2014 +0200 @@ -154,10 +154,10 @@ OrthancServer/OrthancMoveRequestHandler.cpp # From "lua-scripting" branch - OrthancServer/Scheduler/ServerFilterInstance.cpp + OrthancServer/Scheduler/ServerCommandInstance.cpp OrthancServer/Scheduler/ServerJob.cpp OrthancServer/Scheduler/ServerScheduler.cpp - OrthancServer/Scheduler/StoreScuFilter.cpp + OrthancServer/Scheduler/StoreScuCommand.cpp ) diff -r db18c071fbd7 -r 13e230bbd882 OrthancServer/OrthancRestApi/OrthancRestModalities.cpp --- a/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp Fri Jul 04 14:09:53 2014 +0200 +++ b/OrthancServer/OrthancRestApi/OrthancRestModalities.cpp Fri Jul 04 14:14:14 2014 +0200 @@ -37,7 +37,7 @@ #include "../../Core/HttpClient.h" #include "../FromDcmtkBridge.h" #include "../Scheduler/ServerJob.h" -#include "../Scheduler/StoreScuFilter.h" +#include "../Scheduler/StoreScuCommand.h" #include @@ -328,7 +328,7 @@ for (std::list::const_iterator it = instances.begin(); it != instances.end(); ++it) { - job.AddFilter(new StoreScuFilter(context, p)).AddInput(*it); + job.AddCommand(new StoreScuCommand(context, p)).AddInput(*it); } job.SetDescription("Store-SCU from HTTP to modality \"" + remote + "\""); diff -r db18c071fbd7 -r 13e230bbd882 OrthancServer/Scheduler/IServerCommand.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OrthancServer/Scheduler/IServerCommand.h Fri Jul 04 14:14:14 2014 +0200 @@ -0,0 +1,55 @@ +/** + * 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 . + **/ + + +#pragma once + +#include +#include +#include + +namespace Orthanc +{ + class IServerCommand : public boost::noncopyable + { + public: + typedef std::list ListOfStrings; + + virtual ~IServerCommand() + { + } + + virtual bool Apply(ListOfStrings& outputs, + const ListOfStrings& inputs) = 0; + + virtual bool SendOutputsToSink() const = 0; + }; +} diff -r db18c071fbd7 -r 13e230bbd882 OrthancServer/Scheduler/IServerFilter.h --- a/OrthancServer/Scheduler/IServerFilter.h Fri Jul 04 14:09:53 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,55 +0,0 @@ -/** - * 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 . - **/ - - -#pragma once - -#include -#include -#include - -namespace Orthanc -{ - class IServerFilter : public boost::noncopyable - { - public: - typedef std::list ListOfStrings; - - virtual ~IServerFilter() - { - } - - virtual bool Apply(ListOfStrings& outputs, - const ListOfStrings& inputs) = 0; - - virtual bool SendOutputsToSink() const = 0; - }; -} diff -r db18c071fbd7 -r 13e230bbd882 OrthancServer/Scheduler/ServerCommandInstance.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OrthancServer/Scheduler/ServerCommandInstance.cpp Fri Jul 04 14:14:14 2014 +0200 @@ -0,0 +1,82 @@ +/** + * 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 . + **/ + + +#include "ServerCommandInstance.h" + +#include "../../Core/OrthancException.h" + +namespace Orthanc +{ + bool ServerCommandInstance::Execute(IListener& listener) + { + ListOfStrings outputs; + if (!filter_->Apply(outputs, inputs_)) + { + listener.SignalFailure(jobId_); + return true; + } + + for (std::list::iterator + it = next_.begin(); it != next_.end(); it++) + { + for (ListOfStrings::const_iterator + output = outputs.begin(); output != outputs.end(); output++) + { + (*it)->AddInput(*output); + } + } + + listener.SignalSuccess(jobId_); + return true; + } + + + ServerCommandInstance::ServerCommandInstance(IServerCommand *filter, + const std::string& jobId) : + filter_(filter), + jobId_(jobId) + { + if (filter_ == NULL) + { + throw OrthancException(ErrorCode_ParameterOutOfRange); + } + } + + + ServerCommandInstance::~ServerCommandInstance() + { + if (filter_ != NULL) + { + delete filter_; + } + } +} diff -r db18c071fbd7 -r 13e230bbd882 OrthancServer/Scheduler/ServerCommandInstance.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OrthancServer/Scheduler/ServerCommandInstance.h Fri Jul 04 14:14:14 2014 +0200 @@ -0,0 +1,98 @@ +/** + * 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 . + **/ + + +#pragma once + +#include "../../Core/IDynamicObject.h" +#include "IServerCommand.h" + +namespace Orthanc +{ + class ServerCommandInstance : public IDynamicObject + { + friend class ServerScheduler; + + public: + class IListener + { + public: + virtual ~IListener() + { + } + + virtual void SignalSuccess(const std::string& jobId) = 0; + + virtual void SignalFailure(const std::string& jobId) = 0; + }; + + private: + typedef IServerCommand::ListOfStrings ListOfStrings; + + IServerCommand *filter_; + std::string jobId_; + ListOfStrings inputs_; + std::list next_; + + bool Execute(IListener& listener); + + public: + ServerCommandInstance(IServerCommand *filter, + const std::string& jobId); + + virtual ~ServerCommandInstance(); + + const std::string& GetJobId() const + { + return jobId_; + } + + void AddInput(const std::string& input) + { + inputs_.push_back(input); + } + + void ConnectNext(ServerCommandInstance& filter) + { + next_.push_back(&filter); + } + + const std::list& GetNextCommands() const + { + return next_; + } + + IServerCommand& GetCommand() const + { + return *filter_; + } + }; +} diff -r db18c071fbd7 -r 13e230bbd882 OrthancServer/Scheduler/ServerFilterInstance.cpp --- a/OrthancServer/Scheduler/ServerFilterInstance.cpp Fri Jul 04 14:09:53 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,82 +0,0 @@ -/** - * 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 . - **/ - - -#include "ServerFilterInstance.h" - -#include "../../Core/OrthancException.h" - -namespace Orthanc -{ - bool ServerFilterInstance::Execute(IListener& listener) - { - ListOfStrings outputs; - if (!filter_->Apply(outputs, inputs_)) - { - listener.SignalFailure(jobId_); - return true; - } - - for (std::list::iterator - it = next_.begin(); it != next_.end(); it++) - { - for (ListOfStrings::const_iterator - output = outputs.begin(); output != outputs.end(); output++) - { - (*it)->AddInput(*output); - } - } - - listener.SignalSuccess(jobId_); - return true; - } - - - ServerFilterInstance::ServerFilterInstance(IServerFilter *filter, - const std::string& jobId) : - filter_(filter), - jobId_(jobId) - { - if (filter_ == NULL) - { - throw OrthancException(ErrorCode_ParameterOutOfRange); - } - } - - - ServerFilterInstance::~ServerFilterInstance() - { - if (filter_ != NULL) - { - delete filter_; - } - } -} diff -r db18c071fbd7 -r 13e230bbd882 OrthancServer/Scheduler/ServerFilterInstance.h --- a/OrthancServer/Scheduler/ServerFilterInstance.h Fri Jul 04 14:09:53 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,98 +0,0 @@ -/** - * 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 . - **/ - - -#pragma once - -#include "../../Core/IDynamicObject.h" -#include "IServerFilter.h" - -namespace Orthanc -{ - class ServerFilterInstance : public IDynamicObject - { - friend class ServerScheduler; - - public: - class IListener - { - public: - virtual ~IListener() - { - } - - virtual void SignalSuccess(const std::string& jobId) = 0; - - virtual void SignalFailure(const std::string& jobId) = 0; - }; - - private: - typedef IServerFilter::ListOfStrings ListOfStrings; - - IServerFilter *filter_; - std::string jobId_; - ListOfStrings inputs_; - std::list next_; - - bool Execute(IListener& listener); - - public: - ServerFilterInstance(IServerFilter *filter, - const std::string& jobId); - - virtual ~ServerFilterInstance(); - - const std::string& GetJobId() const - { - return jobId_; - } - - void AddInput(const std::string& input) - { - inputs_.push_back(input); - } - - void ConnectNext(ServerFilterInstance& filter) - { - next_.push_back(&filter); - } - - const std::list& GetNextFilters() const - { - return next_; - } - - IServerFilter& GetFilter() const - { - return *filter_; - } - }; -} diff -r db18c071fbd7 -r 13e230bbd882 OrthancServer/Scheduler/ServerJob.cpp --- a/OrthancServer/Scheduler/ServerJob.cpp Fri Jul 04 14:09:53 2014 +0200 +++ b/OrthancServer/Scheduler/ServerJob.cpp Fri Jul 04 14:14:14 2014 +0200 @@ -40,27 +40,27 @@ { void ServerJob::CheckOrdering() { - std::map index; + std::map index; unsigned int count = 0; - for (std::list::const_iterator + for (std::list::const_iterator it = filters_.begin(); it != filters_.end(); it++) { index[*it] = count++; } - for (std::list::const_iterator + for (std::list::const_iterator it = filters_.begin(); it != filters_.end(); it++) { - const std::list& nextFilters = (*it)->GetNextFilters(); + const std::list& nextCommands = (*it)->GetNextCommands(); - for (std::list::const_iterator - next = nextFilters.begin(); next != nextFilters.end(); next++) + for (std::list::const_iterator + next = nextCommands.begin(); next != nextCommands.end(); next++) { if (index.find(*next) == index.end() || index[*next] <= index[*it]) { - // You must reorder your calls to "ServerJob::AddFilter" + // You must reorder your calls to "ServerJob::AddCommand" throw OrthancException("Bad ordering of filters in a job"); } } @@ -69,7 +69,7 @@ size_t ServerJob::Submit(SharedMessageQueue& target, - ServerFilterInstance::IListener& listener) + ServerCommandInstance::IListener& listener) { if (submitted_) { @@ -81,7 +81,7 @@ size_t size = filters_.size(); - for (std::list::iterator + for (std::list::iterator it = filters_.begin(); it != filters_.end(); it++) { target.Enqueue(*it); @@ -104,7 +104,7 @@ ServerJob::~ServerJob() { - for (std::list::iterator + for (std::list::iterator it = filters_.begin(); it != filters_.end(); it++) { delete *it; @@ -112,14 +112,14 @@ } - ServerFilterInstance& ServerJob::AddFilter(IServerFilter* filter) + ServerCommandInstance& ServerJob::AddCommand(IServerCommand* filter) { if (submitted_) { throw OrthancException(ErrorCode_BadSequenceOfCalls); } - filters_.push_back(new ServerFilterInstance(filter, jobId_)); + filters_.push_back(new ServerCommandInstance(filter, jobId_)); return *filters_.back(); } diff -r db18c071fbd7 -r 13e230bbd882 OrthancServer/Scheduler/ServerJob.h --- a/OrthancServer/Scheduler/ServerJob.h Fri Jul 04 14:09:53 2014 +0200 +++ b/OrthancServer/Scheduler/ServerJob.h Fri Jul 04 14:14:14 2014 +0200 @@ -32,7 +32,7 @@ #pragma once -#include "ServerFilterInstance.h" +#include "ServerCommandInstance.h" #include "../../Core/MultiThreading/SharedMessageQueue.h" namespace Orthanc @@ -42,7 +42,7 @@ friend class ServerScheduler; private: - std::list filters_; + std::list filters_; std::string jobId_; bool submitted_; std::string description_; @@ -50,7 +50,7 @@ void CheckOrdering(); size_t Submit(SharedMessageQueue& target, - ServerFilterInstance::IListener& listener); + ServerCommandInstance::IListener& listener); public: ServerJob(); @@ -72,6 +72,6 @@ return description_; } - ServerFilterInstance& AddFilter(IServerFilter* filter); + ServerCommandInstance& AddCommand(IServerCommand* filter); }; } diff -r db18c071fbd7 -r 13e230bbd882 OrthancServer/Scheduler/ServerScheduler.cpp --- a/OrthancServer/Scheduler/ServerScheduler.cpp Fri Jul 04 14:09:53 2014 +0200 +++ b/OrthancServer/Scheduler/ServerScheduler.cpp Fri Jul 04 14:14:14 2014 +0200 @@ -41,7 +41,7 @@ namespace { // Anonymous namespace to avoid clashes between compilation modules - class Sink : public IServerFilter + class Sink : public IServerCommand { private: ListOfStrings& target_; @@ -143,7 +143,7 @@ std::auto_ptr object(that->queue_.Dequeue(TIMEOUT)); if (object.get() != NULL) { - ServerFilterInstance& filter = dynamic_cast(*object); + ServerCommandInstance& filter = dynamic_cast(*object); // Skip the execution of this filter if its parent job has // previously failed. @@ -234,14 +234,14 @@ // Add a sink filter to collect all the results of the filters // that have no next filter. - ServerFilterInstance& sink = job.AddFilter(new Sink(outputs)); + ServerCommandInstance& sink = job.AddCommand(new Sink(outputs)); - for (std::list::iterator + for (std::list::iterator it = job.filters_.begin(); it != job.filters_.end(); it++) { if ((*it) != &sink && - (*it)->GetNextFilters().size() == 0 && - (*it)->GetFilter().SendOutputsToSink()) + (*it)->GetNextCommands().size() == 0 && + (*it)->GetCommand().SendOutputsToSink()) { (*it)->ConnectNext(sink); } diff -r db18c071fbd7 -r 13e230bbd882 OrthancServer/Scheduler/ServerScheduler.h --- a/OrthancServer/Scheduler/ServerScheduler.h Fri Jul 04 14:09:53 2014 +0200 +++ b/OrthancServer/Scheduler/ServerScheduler.h Fri Jul 04 14:14:14 2014 +0200 @@ -38,7 +38,7 @@ namespace Orthanc { - class ServerScheduler : public ServerFilterInstance::IListener + class ServerScheduler : public ServerCommandInstance::IListener { private: struct JobInfo @@ -58,7 +58,7 @@ JobStatus_Failure = 3 }; - typedef IServerFilter::ListOfStrings ListOfStrings; + typedef IServerCommand::ListOfStrings ListOfStrings; typedef std::map Jobs; boost::mutex mutex_; diff -r db18c071fbd7 -r 13e230bbd882 OrthancServer/Scheduler/StoreScuCommand.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OrthancServer/Scheduler/StoreScuCommand.cpp Fri Jul 04 14:14:14 2014 +0200 @@ -0,0 +1,65 @@ +/** + * 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 . + **/ + + +#include "StoreScuCommand.h" + +#include + +namespace Orthanc +{ + StoreScuCommand::StoreScuCommand(ServerContext& context, + const RemoteModalityParameters& modality) : + context_(context), + modality_(modality) + { + } + + bool StoreScuCommand::Apply(ListOfStrings& outputs, + const ListOfStrings& inputs) + { + + ReusableDicomUserConnection::Locker locker(context_.GetReusableDicomUserConnection(), modality_); + + for (ListOfStrings::const_iterator + it = inputs.begin(); it != inputs.end(); ++it) + { + LOG(INFO) << "Sending resource " << *it << " to modality \"" + << modality_.GetApplicationEntityTitle() << "\""; + + std::string dicom; + context_.ReadFile(dicom, *it, FileContentType_Dicom); + locker.GetConnection().Store(dicom); + } + + return true; + } +} diff -r db18c071fbd7 -r 13e230bbd882 OrthancServer/Scheduler/StoreScuCommand.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OrthancServer/Scheduler/StoreScuCommand.h Fri Jul 04 14:14:14 2014 +0200 @@ -0,0 +1,58 @@ +/** + * 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 . + **/ + + +#pragma once + +#include "IServerCommand.h" +#include "../ServerContext.h" + +namespace Orthanc +{ + class StoreScuCommand : public IServerCommand + { + private: + ServerContext& context_; + RemoteModalityParameters modality_; + + public: + StoreScuCommand(ServerContext& context, + const RemoteModalityParameters& modality); + + bool Apply(ListOfStrings& outputs, + const ListOfStrings& inputs); + + bool SendOutputsToSink() const + { + return false; + } + }; +} diff -r db18c071fbd7 -r 13e230bbd882 OrthancServer/Scheduler/StoreScuFilter.cpp --- a/OrthancServer/Scheduler/StoreScuFilter.cpp Fri Jul 04 14:09:53 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,65 +0,0 @@ -/** - * 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 . - **/ - - -#include "StoreScuFilter.h" - -#include - -namespace Orthanc -{ - StoreScuFilter::StoreScuFilter(ServerContext& context, - const RemoteModalityParameters& modality) : - context_(context), - modality_(modality) - { - } - - bool StoreScuFilter::Apply(ListOfStrings& outputs, - const ListOfStrings& inputs) - { - - ReusableDicomUserConnection::Locker locker(context_.GetReusableDicomUserConnection(), modality_); - - for (ListOfStrings::const_iterator - it = inputs.begin(); it != inputs.end(); ++it) - { - LOG(INFO) << "Sending resource " << *it << " to modality \"" - << modality_.GetApplicationEntityTitle() << "\""; - - std::string dicom; - context_.ReadFile(dicom, *it, FileContentType_Dicom); - locker.GetConnection().Store(dicom); - } - - return true; - } -} diff -r db18c071fbd7 -r 13e230bbd882 OrthancServer/Scheduler/StoreScuFilter.h --- a/OrthancServer/Scheduler/StoreScuFilter.h Fri Jul 04 14:09:53 2014 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -/** - * 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 . - **/ - - -#pragma once - -#include "IServerFilter.h" -#include "../ServerContext.h" - -namespace Orthanc -{ - class StoreScuFilter : public IServerFilter - { - private: - ServerContext& context_; - RemoteModalityParameters modality_; - - public: - StoreScuFilter(ServerContext& context, - const RemoteModalityParameters& modality); - - bool Apply(ListOfStrings& outputs, - const ListOfStrings& inputs); - - bool SendOutputsToSink() const - { - return false; - } - }; -} diff -r db18c071fbd7 -r 13e230bbd882 UnitTestsSources/MultiThreadingTests.cpp --- a/UnitTestsSources/MultiThreadingTests.cpp Fri Jul 04 14:09:53 2014 +0200 +++ b/UnitTestsSources/MultiThreadingTests.cpp Fri Jul 04 14:14:14 2014 +0200 @@ -277,7 +277,7 @@ -class Tutu : public IServerFilter +class Tutu : public IServerCommand { private: int factor_; @@ -317,7 +317,7 @@ static void Tata(ServerScheduler* s, ServerJob* j, bool* done) { - typedef IServerFilter::ListOfStrings ListOfStrings; + typedef IServerCommand::ListOfStrings ListOfStrings; #if 1 while (!(*done)) @@ -348,10 +348,10 @@ ServerScheduler scheduler(10); ServerJob job; - ServerFilterInstance& f2 = job.AddFilter(new Tutu(2)); - ServerFilterInstance& f3 = job.AddFilter(new Tutu(3)); - ServerFilterInstance& f4 = job.AddFilter(new Tutu(4)); - ServerFilterInstance& f5 = job.AddFilter(new Tutu(5)); + ServerCommandInstance& f2 = job.AddCommand(new Tutu(2)); + ServerCommandInstance& f3 = job.AddCommand(new Tutu(3)); + ServerCommandInstance& f4 = job.AddCommand(new Tutu(4)); + ServerCommandInstance& f5 = job.AddCommand(new Tutu(5)); f2.AddInput(boost::lexical_cast(42)); //f3.AddInput(boost::lexical_cast(42)); //f4.AddInput(boost::lexical_cast(42)); @@ -367,10 +367,10 @@ //scheduler.Submit(job); - IServerFilter::ListOfStrings l; + IServerCommand::ListOfStrings l; scheduler.SubmitAndWait(l, job); - for (IServerFilter::ListOfStrings::iterator i = l.begin(); i != l.end(); i++) + for (IServerCommand::ListOfStrings::iterator i = l.begin(); i != l.end(); i++) { printf("** %s\n", i->c_str()); }