MeVisLab Toolbox Reference
mlObjLoaderFrame.h
Go to the documentation of this file.
1 /*************************************************************************************
2 **
3 ** Copyright 2007, MeVis Medical Solutions AG
4 **
5 ** The user may use this file in accordance with the license agreement provided with
6 ** the Software or, alternatively, in accordance with the terms contained in a
7 ** written agreement between the user and MeVis Medical Solutions AG.
8 **
9 ** For further information use the contact form at https://www.mevislab.de/contact
10 **
11 **************************************************************************************/
12 
13 #ifndef ML_OBJ_LOADER_FRAME_H
14 #define ML_OBJ_LOADER_FRAME_H
15 
16 
18 
19 // Include dll-specific settings.
20 #include "MLObjLoaderSystem.h"
22 
23 #ifdef WIN32
24 # define SLASH '\\'
25 #else
26 # define SLASH '/'
27 #endif
28 
29 #define ML_PRINT_CONDITIONAL_ERROR(a,b,c,d) \
30 if (a) { \
31  ML_PRINT_ERROR(b,c,d); \
32 }
33 
34 
35 ML_START_NAMESPACE
36 
37  class olFullPath;
38 
41  class MLOBJMGR_EXPORT olSpecializedLoader
42  {
44 
45  friend class olFullPath;
46 
47  private:
48 
49  void storeInfoFilePath(const std::string &infoFile);
50 
51  protected:
52 
57 
60  bool _sawErrors;
61 
65  std::string _infoFileDirectory;
66 
69  std::string _miscInfo;
70 
73 
74  public:
75 
78 
80  inline bool suppressErrorLog() const { return _suppressErrorLog; }
82  inline void setSuppressErrorLog(bool trueOrFalse) { _suppressErrorLog = trueOrFalse; }
83 
85  inline bool sawErrors() const { return _sawErrors; }
87  inline void resetErrors() { _sawErrors = false; }
88 
92  virtual bool isValidHeader(const char *header, const size_t length) = 0;
93 
100  virtual void readDoc(const std::string &infoFile, omObjectContainer &oc, bool accumulate);
101 
103  virtual const std::string getName() const = 0;
104 
106  virtual const std::string miscInfo() { return _miscInfo; }
107  };
108 
114  class MLOBJMGR_EXPORT olFullPath
115  {
116  public:
118  olFullPath(const olSpecializedLoader &sl, const std::string &relPath) {
119  _fullPath = sl._infoFileDirectory + SLASH;
120  _fullPath+= relPath;
121  }
122 
124  olFullPath(const olSpecializedLoader &sl, const char *relPath) {
125  _fullPath = sl._infoFileDirectory + SLASH;
126  _fullPath+= relPath;
127  }
128 
130  operator const char *() const {
131  return _fullPath.c_str();
132  }
133 
134  private:
135  std::string _fullPath;
136  };
137 
138 ML_END_NAMESPACE
139 
140 #endif // __mlObjLoaderFrame_H
This is a simple class that lets us do easy prepending of the info file's directory to a given relati...
olFullPath(const olSpecializedLoader &sl, const std::string &relPath)
Constructor.
olFullPath(const olSpecializedLoader &sl, const char *relPath)
Constructor.
Base class for all loader-plugins.
virtual void readDoc(const std::string &infoFile, omObjectContainer &oc, bool accumulate)
readDoc() is called with the filename of the file to be loaded and a reference to the object containe...
virtual const std::string getName() const =0
Returns a string with the name of the loader (e.g. ObjDump)
bool _sawErrors
_sawErrors is set if any errors occurred, and is queryable via the sawErrors() method.
virtual bool isValidHeader(const char *header, const size_t length)=0
This member is called with a pointer (header) to the first length bytes of the file to be loaded.
bool sawErrors() const
Returns 'true' if an error occurred.
bool _suppressErrorLog
Error messages to console should be suppressed if _suppressErrorLog is 'true'.
void resetErrors()
Reset error flag.
std::string _miscInfo
Loader-specific misc.
olSpecializedLoader()
Constructor.
virtual ~olSpecializedLoader()
Destructor.
std::string _infoFileDirectory
Stores the info file directory which is used by olFullPath to construct paths to files that are locat...
virtual const std::string miscInfo()
Returns loader-specific information that has been stored in the _miscInfo class member.
bool suppressErrorLog() const
Suppress error messages to console if 'true'.
void setSuppressErrorLog(bool trueOrFalse)
Suppress error messages to console if 'true'.
Database (object container) - manages all objects.
#define SLASH
This file declares the ObjLoader specialized data loader.
#define ML_ABSTRACT_ROOT_CLASS_HEADER(className)