comparison Framework/Plugins/DatabaseBackendAdapterV3.cpp @ 235:f2b32d31fc99

fix lsb build, fix backward compatibility with SDK <= 1.9.1
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 08 Apr 2021 11:42:32 +0200
parents d1b124d116c1
children 35598014f140
comparison
equal deleted inserted replaced
234:d1b124d116c1 235:f2b32d31fc99
53 53
54 54
55 namespace OrthancDatabases 55 namespace OrthancDatabases
56 { 56 {
57 static bool isBackendInUse_ = false; // Only for sanity checks 57 static bool isBackendInUse_ = false; // Only for sanity checks
58 58
59 59
60 // TODO - TURN THIS INTO A CONNECTION POOL 60 template <typename T>
61 static void CopyListToVector(std::vector<T>& target,
62 const std::list<T>& source)
63 {
64 /**
65 * This has the the same effect as:
66 *
67 * target.reserve(source.size());
68 * std::copy(std::begin(source), std::end(source), std::back_inserter(target));
69 *
70 * However, this implementation is compatible with C++03 (Linux
71 * Standard Base), whereas "std::back_inserter" requires C++11.
72 **/
73
74 target.clear();
75 target.reserve(source.size());
76
77 for (typename std::list<T>::const_iterator it = source.begin(); it != source.end(); ++it)
78 {
79 target.push_back(*it);
80 }
81 }
82
83
61 class DatabaseBackendAdapterV3::Adapter : public boost::noncopyable 84 class DatabaseBackendAdapterV3::Adapter : public boost::noncopyable
62 { 85 {
63 private: 86 private:
64 class ManagerReference : public Orthanc::IDynamicObject 87 class ManagerReference : public Orthanc::IDynamicObject
65 { 88 {
702 match.someInstanceId = StoreString(someInstanceId); 725 match.someInstanceId = StoreString(someInstanceId);
703 726
704 matches_.push_back(match); 727 matches_.push_back(match);
705 } 728 }
706 729
707 730
708 void AnswerIntegers32(const std::list<int32_t>& values) 731 void AnswerIntegers32(const std::list<int32_t>& values)
709 { 732 {
710 SetupAnswerType(_OrthancPluginDatabaseAnswerType_Int32); 733 SetupAnswerType(_OrthancPluginDatabaseAnswerType_Int32);
711 734 CopyListToVector(integers32_, values);
712 integers32_.reserve(values.size());
713 std::copy(std::begin(values), std::end(values), std::back_inserter(integers32_));
714 } 735 }
715 736
716 737
717 void AnswerIntegers64(const std::list<int64_t>& values) 738 void AnswerIntegers64(const std::list<int64_t>& values)
718 { 739 {
719 SetupAnswerType(_OrthancPluginDatabaseAnswerType_Int64); 740 SetupAnswerType(_OrthancPluginDatabaseAnswerType_Int64);
720 741 CopyListToVector(integers64_, values);
721 integers64_.reserve(values.size());
722 std::copy(std::begin(values), std::end(values), std::back_inserter(integers64_));
723 } 742 }
724 743
725 744
726 void AnswerInteger64(int64_t value) 745 void AnswerInteger64(int64_t value)
727 { 746 {
746 765
747 766
748 void AnswerStrings(const std::list<std::string>& values) 767 void AnswerStrings(const std::list<std::string>& values)
749 { 768 {
750 SetupAnswerType(_OrthancPluginDatabaseAnswerType_String); 769 SetupAnswerType(_OrthancPluginDatabaseAnswerType_String);
751 770 CopyListToVector(stringAnswers_, values);
752 stringAnswers_.reserve(values.size());
753 std::copy(std::begin(values), std::end(values), std::back_inserter(stringAnswers_));
754 } 771 }
755 772
756 773
757 void AnswerString(const std::string& value) 774 void AnswerString(const std::string& value)
758 { 775 {