1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137
|
/*
$Id: resource.h,v 1.18 2001/12/16 17:19:33 starch Exp $
------------------------------------------------------------------------
ClanLib, the platform independent game SDK.
This library is distributed under the GNU LIBRARY GENERAL PUBLIC LICENSE
version 2. See COPYING for details.
For a total list of contributers see CREDITS.
See http://www.clanlib.org
------------------------------------------------------------------------
*/
//! clanCore="Resources"
//! header=core.h
#ifndef header_resource
#define header_resource
#include "../../signals.h"
#include <string>
class CL_ResourceOptions;
class CL_ResourceManager;
class CL_ResourceData;
class CL_InputSource;
class CL_OutputSource;
class CL_InputSourceProvider;
class CL_OutputSourceProvider;
class CL_Resource_Generic;
//: Interface representing a resource in the resource manager.
class CL_Resource
{
//! Construction:
public:
//: Resource Constructor
CL_Resource(
const std::string &type,
const std::string &name,
const std::string &location,
const CL_ResourceOptions &options,
const CL_ResourceManager &manager);
//: Resource Constructor
CL_Resource(const CL_Resource ©);
//: Resource Constructor
CL_Resource();
//: Resource Destructor
virtual ~CL_Resource();
//! Attributes:
public:
//: Returns the type of the resource.
const std::string &get_type() const;
//: Returns the name of the resource.
const std::string &get_name() const;
//: Returns the location of the resource (relative to resource definition file).
//: Use this function if file is to be opened with CL_ResourceManager::get_resource_provider().
const std::string &get_location() const;
//: Returns the full path location of the resource.
//: Use this function if file is to be opened without ClanLib input sources.
std::string get_full_location() const;
//: Returns the resource options.
CL_ResourceOptions &get_options();
//: Returns the resource manager.
CL_ResourceManager get_manager();
//: Returns the data with the matching name.
CL_ResourceData *get_data(const std::string &name);
//: Returns the current reference count.
int get_reference_count() const;
//! Signals:
public:
//: Signal invoked when a call to load_file is made.
CL_Signal_v0 &sig_load_file();
//: Signal invoked when a call to load_datafile is made.
CL_Signal_v1<CL_InputSourceProvider *> &sig_load_datafile();
//: Signal invoked when a call to save_datafile is made.
CL_Signal_v1<CL_OutputSourceProvider *> &sig_save_datafile();
//: Signal invoked when a call to unload is made.
CL_Signal_v0 &sig_unload();
//! Operators:
public:
//: Copy a resource.
void operator = (const CL_Resource ©);
//! Operations:
public:
//: Attach some data to the resource.
void attach_data(const std::string &name, CL_ResourceData *data);
//: Detach some data from the resource.
void detach_data(CL_ResourceData *data);
//: Unloads the resource from memory.
void unload();
//: <p>Loads the resource, using the prefered source as specified by
//: the resource manager.</p>
void load();
//: Loads the resource from file.
void load_file();
//: Loads the resource from the input source.
void load_datafile(CL_InputSourceProvider *input_provider);
//: Saves the resource to the output source.
void save_datafile(CL_OutputSourceProvider *output_provider);
//! Implementation:
public:
//: Resource Constructor
CL_Resource(class CL_Resource_Generic *impl);
//: Pointer to implementation
CL_Resource_Generic *impl;
};
#endif
|