Triton
Visual simulation library for ocean rendering.
ResourceLoader.h
Go to the documentation of this file.
1// Copyright (c) 2010-2013 Sundog Software, LLC All rights reserved worldwide.
2
8#ifndef TRITON_RESOURCE_LOADER_H
9#define TRITON_RESOURCE_LOADER_H
10
11#ifdef SWIG
12%module TritonResourceLoader
13#define TRITONAPI
14SWIG_CSBODY_PROXY(public, public, SWIGTYPE)
15SWIG_CSBODY_TYPEWRAPPER(public, public, public, SWIGTYPE)
16%{
17#include "ResourceLoader.h"
18using namespace Triton;
19%}
20#endif
21
22#if defined(WIN32) || defined(WIN64)
23#pragma warning (disable: 4786)
24#endif
25
26#include "TritonCommon.h"
27#include <string>
28
29#pragma pack(push)
30#pragma pack(8)
31
32namespace Triton
33{
40{
41public:
49 ResourceLoader(const char *resourceDirPath, bool useAddDllDirectory = false);
50
52 virtual ~ResourceLoader();
53
63 virtual void TRITONAPI SetResourceDirPath(const char *path, bool useAddDllDirectory = false);
64
66 virtual const char * TRITONAPI GetResourceDirPath() const {
67 return resourcePath;
68 }
69
84 virtual bool TRITONAPI LoadResource(const char *pathName, char*& data, unsigned int& dataLen, bool text);
85
88 virtual void TRITONAPI FreeResource(char *data);
89
90protected:
91 char *resourcePath;
92};
93
94class ScopedResource
95{
96public:
97 ScopedResource(const char* pathName, ResourceLoader* _loader);
98 ~ScopedResource();
99 char* Data(void) const;
100private:
101 ResourceLoader* loader;
102 char *data;
103 unsigned int dataLen;
104};
105}
106
107#pragma pack(pop)
108
109#endif
A class for loading Triton's resources from mass storage, which you may extend.
Common typedefs and defines used within Triton.
This base class for all Triton objects intercepts the new and delete operators, routing them through ...
Definition: MemAlloc.h:71
This class is used whenever Triton needs to load textures, data files, or shaders from mass storage; ...
Definition: ResourceLoader.h:40
ResourceLoader(const char *resourceDirPath, bool useAddDllDirectory=false)
Constructor.
virtual bool TRITONAPI LoadResource(const char *pathName, char *&data, unsigned int &dataLen, bool text)
Load a resource from mass storage; the default implementation uses the POSIX functions fopen(),...
virtual void TRITONAPI SetResourceDirPath(const char *path, bool useAddDllDirectory=false)
Sets the path to the Triton resources folder, which will be pre-pended to all resource filenames pass...
virtual void TRITONAPI FreeResource(char *data)
Frees the resource data memory that was returned from LoadResource().
virtual ~ResourceLoader()
Virtual destructor; frees the memory of the resource path string.
virtual const char *TRITONAPI GetResourceDirPath() const
Retrieves the path set by SetResourceDirPath().
Definition: ResourceLoader.h:66