Visualization Library 2.1.0

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
ResourceLoadWriter.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2020, Michele Bosi */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without modification, */
10 /* are permitted provided that the following conditions are met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, this */
13 /* list of conditions and the following disclaimer. */
14 /* */
15 /* - Redistributions in binary form must reproduce the above copyright notice, this */
16 /* list of conditions and the following disclaimer in the documentation and/or */
17 /* other materials provided with the distribution. */
18 /* */
19 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND */
20 /* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED */
21 /* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
22 /* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR */
23 /* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES */
24 /* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; */
25 /* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON */
26 /* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT */
27 /* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
28 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
29 /* */
30 /**************************************************************************************/
31 
32 #ifndef ResourceLoadWriter_INCLUDE_ONCE
33 #define ResourceLoadWriter_INCLUDE_ONCE
34 
35 #include <vlCore/String.hpp>
36 
37 namespace vl
38 {
39  class ResourceDatabase;
40 
44  class ResourceLoadWriter: public Object
45  {
47 
48  public:
49  ResourceLoadWriter(const String& load_extensions, const String& write_extensions): mLoadExtensions(load_extensions), mWriteExtensions(write_extensions) {}
50 
51  virtual ref<ResourceDatabase> loadResource(const String& path) const = 0;
52  virtual ref<ResourceDatabase> loadResource(VirtualFile* file) const = 0;
53  virtual bool writeResource(const String& path, ResourceDatabase* resource) const = 0;
54  virtual bool writeResource(VirtualFile* file, ResourceDatabase* resource) const = 0;
55 
58  bool canLoad(const String& extension) const { return mLoadExtensions.find("|"+extension.toLowerCase()+"|") != -1; }
59 
62  const String& loadExtensions() const { return mLoadExtensions; }
63 
68  void setLoadExtensions(const String& extensions) { mLoadExtensions = extensions; mLoadExtensions = mLoadExtensions.toLowerCase(); }
69 
72  bool canWrite(const String& extension) const { return mWriteExtensions.find("|"+extension.toLowerCase()+"|") != -1; }
73 
76  const String& writeExtensions() const { return mWriteExtensions; }
77 
83 
84  protected:
87  };
88 }
89 
90 #endif
virtual ref< ResourceDatabase > loadResource(const String &path) const =0
String toLowerCase() const
Returns the lower-case version of a String.
Definition: String.cpp:755
An abstract class representing a file.
Definition: VirtualFile.hpp:60
The String class implements an advanced UTF16 (Unicode BMP) string manipulation engine.
Definition: String.hpp:62
bool canLoad(const String &extension) const
Returns true if the given file type can be loaded.
const String & writeExtensions() const
Returns the string containing the file types that can be written.
void setLoadExtensions(const String &extensions)
Sets the set of file extensions that can be loaded.
virtual bool writeResource(const String &path, ResourceDatabase *resource) const =0
Visualization Library main namespace.
bool canWrite(const String &extension) const
Returns true if the given file type can be written.
The base class for all the reference counted objects.
Definition: Object.hpp:158
const String & loadExtensions() const
Returns the string containing the file types that can be loaded.
void setWriteExtensions(const String &extensions)
Sets the set of file extensions that can be written.
int find(wchar_t ch, int start=0) const
Searches for the specified character ch starting at position start and returns the index of the first...
Definition: String.cpp:217
#define VL_INSTRUMENT_ABSTRACT_CLASS(ClassName, BaseClass)
Definition: TypeInfo.hpp:145
ResourceLoadWriter(const String &load_extensions, const String &write_extensions)
The ref<> class is used to reference-count an Object.
Definition: Object.hpp:55
The ResourceLoadWriter class is an abstract class used to implement read/write support for one or mor...
The ResourceDatabase class contains and manipulates a set of resources.