Spinning Topp Logo BlackTopp Studios
inc
asset.h
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 #ifndef _resourceasset_h
41 #define _resourceasset_h
42 
43 #include "datatypes.h"
44 
45 namespace Mezzanine
46 {
47  namespace Resource
48  {
49  ///////////////////////////////////////////////////////////////////////////////
50  /// @brief A convenience base class for objects that may need common IO operations exposed for them.
51  /// @details An Asset is just a class that may need saving or loading operations present on the class. Any
52  /// data that has IO performed on it can be an Asset, regardless of whether or not it is represented by
53  /// this class. @n @n
54  /// The internal IO methods bypass the resource system and access the resource directly. This should be
55  /// avoided in most use cases as you could be opening multiple streams to the same assets or creating race
56  /// conditions, or generating large delays for the WorkUnit if it is being executed in a WorkUnit. They
57  /// were primarily created to facilitate testing.
58  ///////////////////////////////////////
60  {
61  protected:
62  // Listing of classes to be Assets:
63  // Audio::Sound
64  // Graphics::Image
65  public:
66  /// @brief Class constructor.
67  Asset();
68  /// @brief Class destructor.
69  virtual ~Asset();
70 
71  ///////////////////////////////////////////////////////////////////////////////
72  // Loading Methods
73 
74  /// @brief Loads an asset from an input stream.
75  /// @param Stream The stream this asset will be read from.
76  virtual void LoadAsset(std::istream* Stream) = 0;
77  /// @brief Loads an asset from an asset group.
78  /// @param FileName The name of the file to search for.
79  /// @param GroupName The name of the asset group to look for the resource in.
80  virtual void LoadAsset(const String& FileName, const String& GroupName);
81 
82  ///////////////////////////////////////////////////////////////////////////////
83  // Saving Methods
84 
85  /// @brief Saves an asset to an output stream.
86  /// @param Stream The stream this asset will written to.
87  virtual void SaveAsset(std::ostream* Stream) = 0;
88  /// @brief Saves an asset to an asset group.
89  /// @param FileName The name of the file to save as.
90  /// @param GroupName The name of the asset group to save to.
91  virtual void SaveAsset(const String& FileName, const String& GroupName);
92 
93  ///////////////////////////////////////////////////////////////////////////////
94  // Internal Loading Methods
95 
96  /// @internal
97  /// @brief Workaround method to load an asset from the filesystem.
98  /// @param File The complete file path and a name of the asset to be loaded.
99  virtual void _LoadAsset(const String& File) = 0;
100  /// @internal
101  /// @brief Workaround method to load an asset from the filesystem.
102  /// @param FilePath The directory path the file should be loaded from.
103  /// @param FileName The name of the file to search for.
104  virtual void _LoadAsset(const String& FilePath, const String& FileName);
105 
106  ///////////////////////////////////////////////////////////////////////////////
107  // Internal Saving Methods
108 
109  /// @internal
110  /// @brief Workaround method to save an asset to the filesystem.
111  /// @param File The complete file path and a name of the asset to be saved.
112  virtual void _SaveAsset(const String& File) = 0;
113  /// @internal
114  /// @brief Workaround method to save an asset to the filesystem.
115  /// @param FilePath The directory path the file should be saved to.
116  /// @param FileName The name of the file to save as.
117  virtual void _SaveAsset(const String& FilePath, const String& FileName);
118  };//Asset
119  }//Resource
120 }//Mezzanine
121 
122 #endif
All the definitions for datatypes as well as some basic conversion functions are defined here...
A convenience base class for objects that may need common IO operations exposed for them...
Definition: asset.h:59
#define MEZZ_LIB
Some platforms require special decorations to denote what is exported/imported in a share library...
The bulk of the engine components go in this namspace.
Definition: actor.cpp:56
std::string String
A datatype used to a series of characters.
Definition: datatypes.h:159