Mercurial > hg > orthanc
changeset 609:5651d2c6f6fd
cleaning
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 25 Oct 2013 10:36:06 +0200 |
parents | b1a0990ad40c |
children | 5c24273d54f9 b58d65608949 |
files | Resources/Archives/MessageWithDestination.cpp Resources/Archives/OrthancCppClient.cmake Resources/Archives/PrepareDatabase-v1.sql |
diffstat | 3 files changed, 0 insertions(+), 369 deletions(-) [+] |
line wrap: on
line diff
--- a/Resources/Archives/MessageWithDestination.cpp Thu Oct 24 10:32:33 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,171 +0,0 @@ -#include "../Core/IDynamicObject.h" - -#include "../Core/OrthancException.h" - -#include <stdint.h> -#include <memory> -#include <map> -#include <gtest/gtest.h> -#include <string> -#include <boost/thread.hpp> -#include <boost/date_time/posix_time/posix_time_types.hpp> - -namespace Orthanc -{ - class SharedMessageQueue - { - private: - typedef std::list<IDynamicObject*> Queue; - - unsigned int maxSize_; - Queue queue_; - boost::mutex mutex_; - boost::condition_variable elementAvailable_; - - public: - SharedMessageQueue(unsigned int maxSize = 0) - { - maxSize_ = maxSize; - } - - ~SharedMessageQueue() - { - for (Queue::iterator it = queue_.begin(); it != queue_.end(); it++) - { - delete *it; - } - } - - void Enqueue(IDynamicObject* message) - { - boost::mutex::scoped_lock lock(mutex_); - - if (maxSize_ != 0 && queue_.size() > maxSize_) - { - // Too many elements in the queue: First remove the oldest - delete queue_.front(); - queue_.pop_front(); - } - - queue_.push_back(message); - elementAvailable_.notify_one(); - } - - IDynamicObject* Dequeue(int32_t timeout) - { - boost::mutex::scoped_lock lock(mutex_); - - // Wait for a message to arrive in the FIFO queue - while (queue_.empty()) - { - if (timeout == 0) - { - elementAvailable_.wait(lock); - } - else - { - bool success = elementAvailable_.timed_wait - (lock, boost::posix_time::milliseconds(timeout)); - if (!success) - { - throw OrthancException(ErrorCode_Timeout); - } - } - } - - std::auto_ptr<IDynamicObject> message(queue_.front()); - queue_.pop_front(); - - return message.release(); - } - - IDynamicObject* Dequeue() - { - return Dequeue(0); - } - }; - - - /** - * This class represents a message that is to be sent to some destination. - **/ - class MessageToDispatch : public boost::noncopyable - { - private: - IDynamicObject* message_; - std::string destination_; - - public: - /** - * Create a new message with a destination. - * \param message The content of the message (takes the ownership) - * \param destination The destination of the message - **/ - MessageToDispatch(IDynamicObject* message, - const char* destination) - { - message_ = message; - destination_ = destination; - } - - ~MessageToDispatch() - { - if (message_) - { - delete message_; - } - } - }; - - - class IDestinationContext : public IDynamicObject - { - public: - virtual void Handle(const IDynamicObject& message) = 0; - }; - - - class IDestinationContextFactory : public IDynamicObject - { - public: - virtual IDestinationContext* Construct(const char* destination) = 0; - }; - - - class MessageDispatcher - { - private: - typedef std::map<std::string, IDestinationContext*> ActiveContexts; - - std::auto_ptr<IDestinationContextFactory> factory_; - ActiveContexts activeContexts_; - SharedMessageQueue queue_; - - public: - MessageDispatcher(IDestinationContextFactory* factory) // takes the ownership - { - factory_.reset(factory); - } - - ~MessageDispatcher() - { - for (ActiveContexts::iterator it = activeContexts_.begin(); - it != activeContexts_.end(); it++) - { - delete it->second; - } - } - }; -} - - - -#include "../Core/DicomFormat/DicomString.h" - -using namespace Orthanc; - -TEST(MessageToDispatch, A) -{ - MessageToDispatch a(new DicomString("coucou"), "pukkaj"); -} -
--- a/Resources/Archives/OrthancCppClient.cmake Thu Oct 24 10:32:33 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,62 +0,0 @@ -include_directories(${ORTHANC_ROOT}/OrthancCppClient/Package/Laaw) - -set(STATIC_BUILD ON) -include(${ORTHANC_ROOT}/Resources/CMake/DownloadPackage.cmake) -include(${ORTHANC_ROOT}/Resources/CMake/JsonCppConfiguration.cmake) -include(${ORTHANC_ROOT}/Resources/CMake/LibCurlConfiguration.cmake) -include(${ORTHANC_ROOT}/Resources/CMake/LibPngConfiguration.cmake) -include(${ORTHANC_ROOT}/Resources/CMake/BoostConfiguration.cmake) -include(${ORTHANC_ROOT}/Resources/CMake/ZlibConfiguration.cmake) - -if (${CMAKE_COMPILER_IS_GNUCXX}) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -Wno-implicit-function-declaration") # --std=c99 makes libcurl not to compile - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Wno-long-long -Wno-variadic-macros") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed") - set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") -elseif (${MSVC}) - add_definitions(-D_CRT_SECURE_NO_WARNINGS=1) -endif() - -if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows") - if (${CMAKE_SIZEOF_VOID_P} EQUAL 4) - set(WINDOWS_DEF ${ORTHANC_ROOT}/OrthancCppClient/Package/Build/Windows32.def) - elseif (${CMAKE_SIZEOF_VOID_P} EQUAL 8) - set(WINDOWS_DEF ${ORTHANC_ROOT}/OrthancCppClient/Package/Build/Windows64.def) - else() - message(FATAL_ERROR "Support your platform here") - endif() -endif() - -add_library(OrthancCppClient SHARED - ${THIRD_PARTY_SOURCES} - ${ORTHANC_ROOT}/Core/OrthancException.cpp - ${ORTHANC_ROOT}/Core/Enumerations.cpp - ${ORTHANC_ROOT}/Core/Toolbox.cpp - ${ORTHANC_ROOT}/Core/HttpClient.cpp - ${ORTHANC_ROOT}/Core/MultiThreading/ArrayFilledByThreads.cpp - ${ORTHANC_ROOT}/Core/MultiThreading/ThreadedCommandProcessor.cpp - ${ORTHANC_ROOT}/Core/MultiThreading/SharedMessageQueue.cpp - ${ORTHANC_ROOT}/Core/FileFormats/PngReader.cpp - ${ORTHANC_ROOT}/OrthancCppClient/OrthancConnection.cpp - ${ORTHANC_ROOT}/OrthancCppClient/Series.cpp - ${ORTHANC_ROOT}/OrthancCppClient/Study.cpp - ${ORTHANC_ROOT}/OrthancCppClient/Instance.cpp - ${ORTHANC_ROOT}/OrthancCppClient/Patient.cpp - ${ORTHANC_ROOT}/OrthancCppClient/Package/SharedLibrary.cpp - ${ORTHANC_ROOT}/Resources/sha1/sha1.cpp - ${ORTHANC_ROOT}/Resources/md5/md5.c - ${ORTHANC_ROOT}/Resources/base64/base64.cpp - ${WINDOWS_DEF} - ) - -if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") - set_target_properties(OrthancCppClient - PROPERTIES LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -Wl,--version-script=${ORTHANC_ROOT}/OrthancCppClient/Package/Laaw/VersionScript.map" - ) - target_link_libraries(OrthancCppClient pthread) -else() - set_target_properties(OrthancCppClient - PROPERTIES LINK_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--allow-multiple-definition -static-libgcc -static-libstdc++" - ) - target_link_libraries(OrthancCppClient ws2_32) -endif()
--- a/Resources/Archives/PrepareDatabase-v1.sql Thu Oct 24 10:32:33 2013 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,136 +0,0 @@ -CREATE TABLE GlobalProperties( - name TEXT PRIMARY KEY, - value TEXT - ); - -CREATE TABLE Resources( - uuid TEXT PRIMARY KEY, - resourceType INTEGER - ); - -CREATE TABLE Patients( - uuid TEXT PRIMARY KEY, - dicomPatientId TEXT - ); - -CREATE TABLE Studies( - uuid TEXT PRIMARY KEY, - parentPatient TEXT REFERENCES Patients(uuid) ON DELETE CASCADE, - dicomStudy TEXT - ); - -CREATE TABLE Series( - uuid TEXT PRIMARY KEY, - parentStudy TEXT REFERENCES Studies(uuid) ON DELETE CASCADE, - dicomSeries TEXT, - expectedNumberOfInstances INTEGER - ); - -CREATE TABLE Instances( - uuid TEXT PRIMARY KEY, - parentSeries TEXT REFERENCES Series(uuid) ON DELETE CASCADE, - dicomInstance TEXT, - fileUuid TEXT, - fileSize INTEGER, - jsonUuid TEXT, - distantAet TEXT, - indexInSeries INTEGER - ); - -CREATE TABLE MainDicomTags( - uuid TEXT, - tagGroup INTEGER, - tagElement INTEGER, - value TEXT, - PRIMARY KEY(uuid, tagGroup, tagElement) - ); - -CREATE TABLE Changes( - seq INTEGER PRIMARY KEY AUTOINCREMENT, - basePath TEXT, - uuid TEXT - ); - - -CREATE INDEX PatientToStudies ON Studies(parentPatient); -CREATE INDEX StudyToSeries ON Series(parentStudy); -CREATE INDEX SeriesToInstances ON Instances(parentSeries); - -CREATE INDEX DicomPatientIndex ON Patients(dicomPatientId); -CREATE INDEX DicomStudyIndex ON Studies(dicomStudy); -CREATE INDEX DicomSeriesIndex ON Series(dicomSeries); -CREATE INDEX DicomInstanceIndex ON Instances(dicomInstance); - -CREATE INDEX MainDicomTagsIndex ON MainDicomTags(uuid); -CREATE INDEX MainDicomTagsGroupElement ON MainDicomTags(tagGroup, tagElement); -CREATE INDEX MainDicomTagsValues ON MainDicomTags(value COLLATE BINARY); - -CREATE INDEX ChangesIndex ON Changes(uuid); - -CREATE TRIGGER InstanceRemoved -AFTER DELETE ON Instances -FOR EACH ROW BEGIN - DELETE FROM Resources WHERE uuid = old.uuid; - DELETE FROM MainDicomTags WHERE uuid = old.uuid; - DELETE FROM Changes WHERE uuid = old.uuid; - SELECT DeleteFromFileStorage(old.fileUuid); - SELECT DeleteFromFileStorage(old.jsonUuid); - SELECT SignalDeletedLevel(3, old.parentSeries); -END; - -CREATE TRIGGER SeriesRemoved -AFTER DELETE ON Series -FOR EACH ROW BEGIN - DELETE FROM Resources WHERE uuid = old.uuid; - DELETE FROM MainDicomTags WHERE uuid = old.uuid; - DELETE FROM Changes WHERE uuid = old.uuid; - SELECT SignalDeletedLevel(2, old.parentStudy); -END; - -CREATE TRIGGER StudyRemoved -AFTER DELETE ON Studies -FOR EACH ROW BEGIN - DELETE FROM Resources WHERE uuid = old.uuid; - DELETE FROM MainDicomTags WHERE uuid = old.uuid; - DELETE FROM Changes WHERE uuid = old.uuid; - SELECT SignalDeletedLevel(1, old.parentPatient); -END; - -CREATE TRIGGER PatientRemoved -AFTER DELETE ON Patients -FOR EACH ROW BEGIN - DELETE FROM Resources WHERE uuid = old.uuid; - DELETE FROM MainDicomTags WHERE uuid = old.uuid; - DELETE FROM Changes WHERE uuid = old.uuid; - SELECT SignalDeletedLevel(0, ""); -END; - - - - -CREATE TRIGGER InstanceRemovedUpwardCleaning -AFTER DELETE ON Instances -FOR EACH ROW - WHEN (SELECT COUNT(*) FROM Instances WHERE parentSeries = old.parentSeries) = 0 - BEGIN - SELECT DeleteFromFileStorage("deleting parent series"); -- TODO REMOVE THIS - DELETE FROM Series WHERE uuid = old.parentSeries; - END; - -CREATE TRIGGER SeriesRemovedUpwardCleaning -AFTER DELETE ON Series -FOR EACH ROW - WHEN (SELECT COUNT(*) FROM Series WHERE parentStudy = old.parentStudy) = 0 - BEGIN - SELECT DeleteFromFileStorage("deleting parent study"); -- TODO REMOVE THIS - DELETE FROM Studies WHERE uuid = old.parentStudy; - END; - -CREATE TRIGGER StudyRemovedUpwardCleaning -AFTER DELETE ON Studies -FOR EACH ROW - WHEN (SELECT COUNT(*) FROM Studies WHERE parentPatient = old.parentPatient) = 0 - BEGIN - SELECT DeleteFromFileStorage("deleting parent patient"); -- TODO REMOVE THIS - DELETE FROM Patients WHERE uuid = old.parentPatient; - END;