Mercurial > hg > orthanc
changeset 1000:13e230bbd882 lua-scripting
rename filter to command
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 04 Jul 2014 14:14:14 +0200 |
parents | db18c071fbd7 |
children | f3929718ea7e |
files | CMakeLists.txt OrthancServer/OrthancRestApi/OrthancRestModalities.cpp OrthancServer/Scheduler/IServerCommand.h OrthancServer/Scheduler/IServerFilter.h OrthancServer/Scheduler/ServerCommandInstance.cpp OrthancServer/Scheduler/ServerCommandInstance.h OrthancServer/Scheduler/ServerFilterInstance.cpp OrthancServer/Scheduler/ServerFilterInstance.h OrthancServer/Scheduler/ServerJob.cpp OrthancServer/Scheduler/ServerJob.h OrthancServer/Scheduler/ServerScheduler.cpp OrthancServer/Scheduler/ServerScheduler.h OrthancServer/Scheduler/StoreScuCommand.cpp OrthancServer/Scheduler/StoreScuCommand.h OrthancServer/Scheduler/StoreScuFilter.cpp OrthancServer/Scheduler/StoreScuFilter.h UnitTestsSources/MultiThreadingTests.cpp |
diffstat | 17 files changed, 394 insertions(+), 394 deletions(-) [+] |
line wrap: on
line diff
--- 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 )
--- 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 <glog/logging.h> @@ -328,7 +328,7 @@ for (std::list<std::string>::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 + "\"");
--- /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 <http://www.gnu.org/licenses/>. + **/ + + +#pragma once + +#include <list> +#include <string> +#include <boost/noncopyable.hpp> + +namespace Orthanc +{ + class IServerCommand : public boost::noncopyable + { + public: + typedef std::list<std::string> ListOfStrings; + + virtual ~IServerCommand() + { + } + + virtual bool Apply(ListOfStrings& outputs, + const ListOfStrings& inputs) = 0; + + virtual bool SendOutputsToSink() const = 0; + }; +}
--- 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 <http://www.gnu.org/licenses/>. - **/ - - -#pragma once - -#include <list> -#include <string> -#include <boost/noncopyable.hpp> - -namespace Orthanc -{ - class IServerFilter : public boost::noncopyable - { - public: - typedef std::list<std::string> ListOfStrings; - - virtual ~IServerFilter() - { - } - - virtual bool Apply(ListOfStrings& outputs, - const ListOfStrings& inputs) = 0; - - virtual bool SendOutputsToSink() const = 0; - }; -}
--- /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 <http://www.gnu.org/licenses/>. + **/ + + +#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<ServerCommandInstance*>::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_; + } + } +}
--- /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 <http://www.gnu.org/licenses/>. + **/ + + +#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<ServerCommandInstance*> 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<ServerCommandInstance*>& GetNextCommands() const + { + return next_; + } + + IServerCommand& GetCommand() const + { + return *filter_; + } + }; +}
--- 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 <http://www.gnu.org/licenses/>. - **/ - - -#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<ServerFilterInstance*>::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_; - } - } -}
--- 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 <http://www.gnu.org/licenses/>. - **/ - - -#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<ServerFilterInstance*> 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<ServerFilterInstance*>& GetNextFilters() const - { - return next_; - } - - IServerFilter& GetFilter() const - { - return *filter_; - } - }; -}
--- 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<ServerFilterInstance*, unsigned int> index; + std::map<ServerCommandInstance*, unsigned int> index; unsigned int count = 0; - for (std::list<ServerFilterInstance*>::const_iterator + for (std::list<ServerCommandInstance*>::const_iterator it = filters_.begin(); it != filters_.end(); it++) { index[*it] = count++; } - for (std::list<ServerFilterInstance*>::const_iterator + for (std::list<ServerCommandInstance*>::const_iterator it = filters_.begin(); it != filters_.end(); it++) { - const std::list<ServerFilterInstance*>& nextFilters = (*it)->GetNextFilters(); + const std::list<ServerCommandInstance*>& nextCommands = (*it)->GetNextCommands(); - for (std::list<ServerFilterInstance*>::const_iterator - next = nextFilters.begin(); next != nextFilters.end(); next++) + for (std::list<ServerCommandInstance*>::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<ServerFilterInstance*>::iterator + for (std::list<ServerCommandInstance*>::iterator it = filters_.begin(); it != filters_.end(); it++) { target.Enqueue(*it); @@ -104,7 +104,7 @@ ServerJob::~ServerJob() { - for (std::list<ServerFilterInstance*>::iterator + for (std::list<ServerCommandInstance*>::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(); }
--- 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<ServerFilterInstance*> filters_; + std::list<ServerCommandInstance*> 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); }; }
--- 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<IDynamicObject> object(that->queue_.Dequeue(TIMEOUT)); if (object.get() != NULL) { - ServerFilterInstance& filter = dynamic_cast<ServerFilterInstance&>(*object); + ServerCommandInstance& filter = dynamic_cast<ServerCommandInstance&>(*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<ServerFilterInstance*>::iterator + for (std::list<ServerCommandInstance*>::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); }
--- 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<std::string, JobInfo> Jobs; boost::mutex mutex_;
--- /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 <http://www.gnu.org/licenses/>. + **/ + + +#include "StoreScuCommand.h" + +#include <glog/logging.h> + +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; + } +}
--- /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 <http://www.gnu.org/licenses/>. + **/ + + +#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; + } + }; +}
--- 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 <http://www.gnu.org/licenses/>. - **/ - - -#include "StoreScuFilter.h" - -#include <glog/logging.h> - -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; - } -}
--- 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 <http://www.gnu.org/licenses/>. - **/ - - -#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; - } - }; -}
--- 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<std::string>(42)); //f3.AddInput(boost::lexical_cast<std::string>(42)); //f4.AddInput(boost::lexical_cast<std::string>(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()); }