changeset 4313:91554aecff9a

removed a friend method for better abi
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 09 Nov 2020 16:09:05 +0100
parents 6d49e3b6ff77
children 0a4347203a7e
files OrthancFramework/Resources/CheckOrthancFrameworkSymbols.py OrthancFramework/Sources/DicomFormat/DicomTag.cpp OrthancFramework/Sources/DicomFormat/DicomTag.h OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp OrthancFramework/Sources/DicomParsing/DicomModification.cpp OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp OrthancFramework/Sources/Logging.h OrthancServer/Sources/OrthancFindRequestHandler.cpp OrthancServer/Sources/OrthancGetRequestHandler.cpp OrthancServer/Sources/OrthancMoveRequestHandler.cpp
diffstat 10 files changed, 31 insertions(+), 25 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Resources/CheckOrthancFrameworkSymbols.py	Mon Nov 09 15:22:43 2020 +0100
+++ b/OrthancFramework/Resources/CheckOrthancFrameworkSymbols.py	Mon Nov 09 16:09:05 2020 +0100
@@ -236,13 +236,18 @@
                 ReportProblem('Exported public member variable', fqn, i)
 
         elif i.kind == clang.cindex.CursorKind.FUNCTION_TEMPLATE:
+            # An inline function template is OK, as it is not added to
+            # a shared library, but compiled by the client of the library
             if isPublic:
-                ReportProblem('Exported public template method', fqn, i)
+                print('Detected a template function (this is fine, but avoid it as much as possible): %s' % ('::'.join(fqn + [ i.spelling ])))
+                hasImplementation = False
+                for j in i.get_children():
+                    if j.kind == clang.cindex.CursorKind.COMPOUND_STMT:
+                        hasImplementation = True
 
-        elif i.kind == clang.cindex.CursorKind.FRIEND_DECL:
-            if isPublic:
-                ReportProblem('Exported public friend method', fqn, i)
-            
+                if not hasImplementation:
+                    ReportProblem('Exported template function without an inline implementation', fqn, i)
+
         elif (i.kind == clang.cindex.CursorKind.TYPEDEF_DECL or  # Allow "typedef"
               i.kind == clang.cindex.CursorKind.ENUM_DECL):      # Allow enums
             pass
--- a/OrthancFramework/Sources/DicomFormat/DicomTag.cpp	Mon Nov 09 15:22:43 2020 +0100
+++ b/OrthancFramework/Sources/DicomFormat/DicomTag.cpp	Mon Nov 09 16:09:05 2020 +0100
@@ -120,13 +120,13 @@
   }
 
 
-  std::ostream& operator<< (std::ostream& o, const DicomTag& tag)
+  std::ostream& DicomTag::FormatStream(std::ostream& o) const
   {
     using namespace std;
     ios_base::fmtflags state = o.flags();
     o.flags(ios::right | ios::hex);
-    o << "(" << setfill('0') << setw(4) << tag.GetGroup()
-      << "," << setw(4) << tag.GetElement() << ")";
+    o << "(" << setfill('0') << setw(4) << GetGroup()
+      << "," << setw(4) << GetElement() << ")";
     o.flags(state);
     return o;
   }
--- a/OrthancFramework/Sources/DicomFormat/DicomTag.h	Mon Nov 09 15:22:43 2020 +0100
+++ b/OrthancFramework/Sources/DicomFormat/DicomTag.h	Mon Nov 09 16:09:05 2020 +0100
@@ -64,11 +64,11 @@
 
     std::string Format() const;
 
+    std::ostream& FormatStream(std::ostream& o) const;
+
     static bool ParseHexadecimal(DicomTag& tag,
                                  const char* value);
 
-    ORTHANC_PUBLIC friend std::ostream& operator<< (std::ostream& o, const DicomTag& tag);
-
     static void AddTagsForModule(std::set<DicomTag>& target,
                                  DicomModule module);
   };
--- a/OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp	Mon Nov 09 15:22:43 2020 +0100
+++ b/OrthancFramework/Sources/DicomNetworking/DicomControlUserConnection.cpp	Mon Nov 09 16:09:05 2020 +0100
@@ -167,7 +167,8 @@
       const DicomTag& tag = query.GetElement(i).GetTag();
       if (allowedTags.find(tag) == allowedTags.end())
       {
-        CLOG(WARNING, DICOM) << "Tag not allowed for this C-Find level, will be ignored: " << tag;
+        CLOG(WARNING, DICOM) << "Tag not allowed for this C-Find level, will be ignored: ("
+                             << tag.Format() << ")";
       }
       else
       {
--- a/OrthancFramework/Sources/DicomParsing/DicomModification.cpp	Mon Nov 09 15:22:43 2020 +0100
+++ b/OrthancFramework/Sources/DicomParsing/DicomModification.cpp	Mon Nov 09 16:09:05 2020 +0100
@@ -1186,12 +1186,12 @@
       {
         case DicomModification::TagOperation_Keep:
           target.Keep(tag);
-          LOG(TRACE) << "Keep: " << name << " " << tag;
+          LOG(TRACE) << "Keep: " << name << " (" << tag.Format() << ")";
           break;
 
         case DicomModification::TagOperation_Remove:
           target.Remove(tag);
-          LOG(TRACE) << "Remove: " << name << " " << tag;
+          LOG(TRACE) << "Remove: " << name << " (" << tag.Format() << ")";
           break;
 
         default:
@@ -1227,8 +1227,8 @@
 
       target.Replace(tag, value, false);
 
-      LOG(TRACE) << "Replace: " << name << " " << tag 
-                 << " == " << value.toStyledString();
+      LOG(TRACE) << "Replace: " << name << " (" << tag.Format() 
+                 << ") == " << value.toStyledString();
     }
   }
 
--- a/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp	Mon Nov 09 15:22:43 2020 +0100
+++ b/OrthancFramework/Sources/DicomParsing/FromDcmtkBridge.cpp	Mon Nov 09 16:09:05 2020 +0100
@@ -351,7 +351,8 @@
     
     DcmEVR evr = ToDcmtkBridge::Convert(vr);
 
-    LOG(INFO) << "Registering tag in dictionary: " << tag << " " << (DcmVR(evr).getValidVRName()) << " " 
+    LOG(INFO) << "Registering tag in dictionary: (" << tag.Format() << ") "
+              << (DcmVR(evr).getValidVRName()) << " " 
               << name << " (multiplicity: " << minMultiplicity << "-" 
               << (arbitrary ? "n" : boost::lexical_cast<std::string>(maxMultiplicity)) << ")";
 
--- a/OrthancFramework/Sources/Logging.h	Mon Nov 09 15:22:43 2020 +0100
+++ b/OrthancFramework/Sources/Logging.h	Mon Nov 09 16:09:05 2020 +0100
@@ -24,6 +24,7 @@
 
 // To have ORTHANC_ENABLE_LOGGING defined if using the shared library
 #include "OrthancFramework.h"
+#include "Compatibility.h"
 
 #include <iostream>
 
@@ -112,7 +113,7 @@
 
     ORTHANC_PUBLIC void SetTargetFolder(const std::string& path);
 
-    struct NullStream : public std::ostream 
+    struct ORTHANC_LOCAL NullStream : public std::ostream 
     {
       NullStream() : 
         std::ios(0), 
@@ -224,8 +225,6 @@
 #if (ORTHANC_ENABLE_LOGGING == 1 &&             \
      ORTHANC_ENABLE_LOGGING_STDIO == 0)
 
-#include "Compatibility.h"  // For std::unique_ptr<>
-
 #include <boost/lexical_cast.hpp>
 #include <boost/noncopyable.hpp>
 #include <boost/thread/mutex.hpp>
--- a/OrthancServer/Sources/OrthancFindRequestHandler.cpp	Mon Nov 09 15:22:43 2020 +0100
+++ b/OrthancServer/Sources/OrthancFindRequestHandler.cpp	Mon Nov 09 16:09:05 2020 +0100
@@ -637,8 +637,8 @@
     {
       if (!query.GetElement(i).GetValue().IsNull())
       {
-        CLOG(INFO, DICOM) << "  " << query.GetElement(i).GetTag()
-                          << "  " << FromDcmtkBridge::GetTagName(query.GetElement(i))
+        CLOG(INFO, DICOM) << "  (" << query.GetElement(i).GetTag().Format()
+                          << ")  " << FromDcmtkBridge::GetTagName(query.GetElement(i))
                           << " = " << query.GetElement(i).GetValue().GetContent();
       }
     }
--- a/OrthancServer/Sources/OrthancGetRequestHandler.cpp	Mon Nov 09 15:22:43 2020 +0100
+++ b/OrthancServer/Sources/OrthancGetRequestHandler.cpp	Mon Nov 09 16:09:05 2020 +0100
@@ -505,8 +505,8 @@
       {
         if (!query.GetElement(i).GetValue().IsNull())
         {
-          CLOG(INFO, DICOM) << "  " << query.GetElement(i).GetTag()
-                            << "  " << FromDcmtkBridge::GetTagName(query.GetElement(i))
+          CLOG(INFO, DICOM) << "  (" << query.GetElement(i).GetTag().Format()
+                            << ")  " << FromDcmtkBridge::GetTagName(query.GetElement(i))
                             << " = " << query.GetElement(i).GetValue().GetContent();
         }
       }
--- a/OrthancServer/Sources/OrthancMoveRequestHandler.cpp	Mon Nov 09 15:22:43 2020 +0100
+++ b/OrthancServer/Sources/OrthancMoveRequestHandler.cpp	Mon Nov 09 16:09:05 2020 +0100
@@ -342,8 +342,8 @@
       {
         if (!query.GetElement(i).GetValue().IsNull())
         {
-          CLOG(INFO, DICOM) << "  " << query.GetElement(i).GetTag()
-                            << "  " << FromDcmtkBridge::GetTagName(query.GetElement(i))
+          CLOG(INFO, DICOM) << "  (" << query.GetElement(i).GetTag().Format()
+                            << ")  " << FromDcmtkBridge::GetTagName(query.GetElement(i))
                             << " = " << query.GetElement(i).GetValue().GetContent();
         }
       }