Visualization Library 2.0.0-b3

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

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
ioVLX.hpp
Go to the documentation of this file.
1 /**************************************************************************************/
2 /* */
3 /* Visualization Library */
4 /* http://visualizationlibrary.org */
5 /* */
6 /* Copyright (c) 2005-2017, 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 LoadWriterVLX_INCLUDE_ONCE
33 #define LoadWriterVLX_INCLUDE_ONCE
34 
36 #include <vlCore/VLXRegistry.hpp>
37 #include <vlCore/VLXSerializer.hpp>
38 #include <vlCore/VLXValue.hpp>
39 #include <vlCore/vlxutils.hpp>
41 #include <vlGraphics/Actor.hpp>
42 #include <vlGraphics/Effect.hpp>
43 #include <vlGraphics/Shader.hpp>
44 #include <vlGraphics/Geometry.hpp>
45 #include <vlGraphics/Light.hpp>
46 #include <vlGraphics/ClipPlane.hpp>
47 #include <vlGraphics/Camera.hpp>
55 #include <vlGraphics/GLSL.hpp>
57 #include <vlCore/DiskFile.hpp>
58 
59 namespace vl
60 {
61  //-----------------------------------------------------------------------------
62 
63  VLGRAPHICS_EXPORT ref<ResourceDatabase> loadVLT(VirtualFile* file);
64  VLGRAPHICS_EXPORT ref<ResourceDatabase> loadVLT(const String& path);
65  VLGRAPHICS_EXPORT ref<ResourceDatabase> loadVLB(VirtualFile* file);
66  VLGRAPHICS_EXPORT ref<ResourceDatabase> loadVLB(const String& path);
67  VLGRAPHICS_EXPORT bool saveVLT(VirtualFile* file, const ResourceDatabase*);
68  VLGRAPHICS_EXPORT bool saveVLT(const String& file, const ResourceDatabase*);
69  VLGRAPHICS_EXPORT bool saveVLB(VirtualFile* file, const ResourceDatabase*);
70  VLGRAPHICS_EXPORT bool saveVLB(const String& file, const ResourceDatabase*);
71  VLGRAPHICS_EXPORT bool isVLT(VirtualFile* file);
72  VLGRAPHICS_EXPORT bool isVLT(const String& file);
73  VLGRAPHICS_EXPORT bool isVLB(VirtualFile* file);
74  VLGRAPHICS_EXPORT bool isVLB(const String& file);
75 
76  //---------------------------------------------------------------------------
77  // LoadWriterVLX
78  //---------------------------------------------------------------------------
83  {
85 
86  public:
87  LoadWriterVLX(): ResourceLoadWriter("|vlt|vlb|", "|vlt|vlb|") {}
88 
90  {
91  if (isVLT(path))
92  return loadVLT(path);
93  else
94  if (isVLB(path))
95  return loadVLB(path);
96  else
97  return NULL;
98  }
99 
101  {
102  if (isVLT(file))
103  return loadVLT(file);
104  else
105  if (isVLB(file))
106  return loadVLB(file);
107  else
108  return NULL;
109  }
110 
111  bool writeResource(const String& path, ResourceDatabase* res_db) const
112  {
113  if (path.extractFileExtension().toLowerCase() == "vlt")
114  return saveVLT(path, res_db);
115  else
116  if (path.extractFileExtension().toLowerCase() == "vlb")
117  return saveVLB(path, res_db);
118  else
119  return false;
120  }
121 
122  bool writeResource(VirtualFile* file, ResourceDatabase* res_db) const
123  {
124  if (file->path().extractFileExtension().toLowerCase() == "vlt")
125  return saveVLT(file, res_db);
126  else
127  if (file->path().extractFileExtension().toLowerCase() == "vlb")
128  return saveVLB(file, res_db);
129  else
130  return false;
131  }
132  };
133 //-----------------------------------------------------------------------------
134 }
135 
136 #endif
String toLowerCase() const
Returns the lower-case version of a String.
Definition: String.cpp:755
String extractFileExtension(bool require_dot=true) const
If the String contains a file name or file path the function returns the extension of the file...
Definition: String.cpp:857
A ResourceLoadWriter capable of reading Visualization Library&#39;s VLT and VLB files.
Definition: ioVLX.hpp:82
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
VLGRAPHICS_EXPORT bool isVLB(VirtualFile *file)
Definition: ioVLX.cpp:151
VLGRAPHICS_EXPORT bool isVLT(VirtualFile *file)
Definition: ioVLX.cpp:132
VLGRAPHICS_EXPORT bool saveVLT(VirtualFile *file, const ResourceDatabase *)
Definition: ioVLX.cpp:90
VLGRAPHICS_EXPORT ref< ResourceDatabase > loadVLB(VirtualFile *file)
Definition: ioVLX.cpp:67
VLGRAPHICS_EXPORT ref< ResourceDatabase > loadVLT(VirtualFile *file)
Definition: ioVLX.cpp:44
#define VL_INSTRUMENT_CLASS(ClassName, BaseClass)
Definition: TypeInfo.hpp:122
const String & path() const
Returns the path of the file.
Definition: VirtualFile.hpp:98
Visualization Library main namespace.
ref< ResourceDatabase > loadResource(VirtualFile *file) const
Definition: ioVLX.hpp:100
#define NULL
Definition: OpenGLDefs.hpp:81
bool writeResource(const String &path, ResourceDatabase *res_db) const
Definition: ioVLX.hpp:111
bool writeResource(VirtualFile *file, ResourceDatabase *res_db) const
Definition: ioVLX.hpp:122
The ref<> class is used to reference-count an Object.
Definition: Object.hpp:55
VLGRAPHICS_EXPORT bool saveVLB(VirtualFile *file, const ResourceDatabase *)
Definition: ioVLX.cpp:111
The ResourceLoadWriter class is an abstract class used to implement read/write support for one or mor...
ref< ResourceDatabase > loadResource(const String &path) const
Definition: ioVLX.hpp:89
The ResourceDatabase class contains and manipulates a set of resources.