Medical Imaging Interaction Toolkit  2026.06.00
Medical Imaging Interaction Toolkit
usModuleResource.h
Go to the documentation of this file.
1 /*============================================================================
2 
3 The Medical Imaging Interaction Toolkit (MITK)
4 
5 Copyright (c) German Cancer Research Center (DKFZ)
6 All rights reserved.
7 
8 Use of this source code is governed by a 3-clause BSD license that can be
9 found in the LICENSE file.
10 
11 ============================================================================*/
12 
13 
14 #ifndef USMODULERESOURCE_H
15 #define USMODULERESOURCE_H
16 
17 #include <usGlobalConfig.h>
19 
20 #include <ostream>
21 #include <vector>
22 
24 
25 namespace us {
26 
27 class ModuleResourcePrivate;
28 class ModuleResourceContainer;
29 
48 {
49 
50 private:
51 
52  typedef ModuleResourcePrivate* ModuleResource::*bool_type;
53 
54 public:
55 
64  ModuleResource(const ModuleResource& resource);
65 
68 
76 
85  bool operator<(const ModuleResource& resource) const;
86 
95  bool operator==(const ModuleResource& resource) const;
96 
103  bool operator!=(const ModuleResource& resource) const;
104 
114  bool IsValid() const;
115 
119  operator bool_type() const;
120 
133  std::string GetName() const;
134 
149  std::string GetPath() const;
150 
157  std::string GetResourcePath() const;
158 
171  std::string GetBaseName() const;
172 
185  std::string GetCompleteBaseName() const;
186 
202  std::string GetSuffix() const;
203 
219  std::string GetCompleteSuffix() const;
220 
227  bool IsDir() const;
228 
234  bool IsFile() const;
235 
244  std::vector<std::string> GetChildren() const;
245 
254  std::vector<ModuleResource> GetChildResources() const;
255 
261  int GetSize() const;
262 
268  time_t GetLastModified() const;
269 
270 private:
271 
272  ModuleResource(const std::string& file, const ModuleResourceContainer& resourceContainer);
273  ModuleResource(int index, const ModuleResourceContainer& resourceContainer);
274 
275  friend class Module;
276  friend class ModulePrivate;
277  friend class ModuleResourceContainer;
278  friend class ModuleResourceStream;
279 
280  friend struct std::hash<ModuleResource>;
281 
282  std::size_t Hash() const;
283 
284  void* GetData() const;
285 
286  ModuleResourcePrivate* d;
287 
288 };
289 
290 }
291 
293 
302 MITKCPPMICROSERVICES_EXPORT std::ostream& operator<<(std::ostream& os, const us::ModuleResource& resource);
303 
304 namespace std {
305 template<> struct hash<us::ModuleResource> { std::size_t operator()(const us::ModuleResource& arg) const {
306  return arg.Hash();
307 } };
308 }
309 
310 #endif // USMODULERESOURCE_H
#define MITKCPPMICROSERVICES_EXPORT
An input stream class for ModuleResource objects.
Represents a resource (text file, image, etc.) embedded in a CppMicroServices module.
bool operator!=(const ModuleResource &resource) const
Inequality operator for ModuleResource objects.
std::string GetBaseName() const
Returns the base name of the resource without the path.
bool operator<(const ModuleResource &resource) const
A less then operator using the full resource path as returned by GetResourcePath() to define the orde...
~ModuleResource()
Destructor.
std::string GetCompleteSuffix() const
Returns the complete suffix of the resource.
bool IsValid() const
Tests this ModuleResource object for validity.
std::string GetResourcePath() const
Returns the resource path including the file name.
int GetSize() const
Returns the size of the resource data for this ModuleResource object.
std::string GetSuffix() const
Returns the suffix of the resource.
std::vector< std::string > GetChildren() const
Returns a list of resource names which are children of this object.
bool IsDir() const
Returns true if this ModuleResource object points to a directory and thus may have child resources.
std::string GetCompleteBaseName() const
Returns the complete base name of the resource without the path.
time_t GetLastModified() const
Returns the last modified time of this resource in seconds from the epoch.
std::string GetPath() const
Returns the resource's path, without the file name.
ModuleResource & operator=(const ModuleResource &resource)
Assignment operator.
std::vector< ModuleResource > GetChildResources() const
Returns a list of resource objects which are children of this object.
bool IsFile() const
Returns true if this ModuleResource object points to a file resource.
std::string GetName() const
Returns the name of the resource, excluding the path.
ModuleResource()
Creates an invalid ModuleResource object.
ModuleResource(const ModuleResource &resource)
Copy constructor.
bool operator==(const ModuleResource &resource) const
Equality operator for ModuleResource objects.
Represents a CppMicroServices module.
Definition: usModule.h:70
US_MSVC_POP_WARNING MITKCPPMICROSERVICES_EXPORT std::ostream & operator<<(std::ostream &os, const us::ModuleResource &resource)
Stream output operator for ModuleResource.
std::size_t operator()(const us::ModuleResource &arg) const
#define US_MSVC_POP_WARNING
#define US_MSVC_PUSH_DISABLE_WARNING(wn)