Subversion Repository Public Repository

Divide-Framework

This repository has no backups
This repository's network speed is throttled to 100KB/sec

Diff Revisions 167 vs 168 for /trunk/Source Code/Core/Resources/Headers/ResourceDescriptor.h

Diff revisions: vs.
  @@ -25,24 +25,50 @@
25 25 #define RESOURCE_DESCRIPTOR_H_
26 26
27 27 #include "core.h"
28 + #include <boost/shared_ptr.hpp>
29 +
30 + ///Dummy class so that resource loaders can have fast access to extra information in a general format
31 + class PropertyDescriptor {
32 + public:
33 +
34 + enum descriptorType{
35 + DESCRIPTOR_TEXTURE = 0,
36 + DESCRIPTOR_SAMPLER = 1
37 + };
38 +
39 + PropertyDescriptor(const descriptorType& type) : _type(type) {}
40 +
41 + protected:
42 + friend class ResourceDescriptor;
43 + ///Initialize descriptor values to their safe defaults
44 + virtual void setDefaultValues() = 0;
45 + ///Used to clone the property descriptor pointer
46 + virtual PropertyDescriptor* clone() const = 0;
47 +
48 + protected:
49 + ///usefull for switch statements
50 + descriptorType _type;
51 + };
28 52
29 53 class ResourceDescriptor{
30 54 public:
31 55 ResourceDescriptor(const std::string& name = "default",
32 56 const std::string& resourceLocation = "default",
33 - bool flag = false, U32 id = RAND_MAX, U8 enumValue = -1) : _name(name),
34 - _resourceLocation(resourceLocation),
35 - _flag(flag),
36 - _id(id),
37 - _enumValue(enumValue)
38 - {
39 - _mask.i = 0;
40 - _threaded = true;
41 - }
42 -
43 - const std::string& getPropertyListString() const {return _properties;}
44 - const std::string& getResourceLocation() const {return _resourceLocation;}
45 - const std::string& getName() const {return _name;}
57 + bool flag = false, U32 id = RAND_MAX, U8 enumValue = -1);
58 +
59 + ~ResourceDescriptor();
60 +
61 + ResourceDescriptor(const ResourceDescriptor& old);
62 + ResourceDescriptor& operator= (ResourceDescriptor const& old);
63 +
64 + inline const std::string& getPropertyListString() const {return _properties;}
65 + inline const std::string& getResourceLocation() const {return _resourceLocation;}
66 + inline const std::string& getName() const {return _name;}
67 +
68 + template<class T>
69 + inline const T* getPropertyDescriptor() const {return dynamic_cast<T*>(_propertyDescriptor); }
70 +
71 + inline bool hasPropertyDescriptor() const {return _propertyDescriptor != NULL;}
46 72 inline bool getFlag() const {return _flag;}
47 73 inline bool getThreaded() const {return _threaded;}
48 74 inline U8 getEnumValue() const {return _enumValue;}
  @@ -58,6 +84,12 @@
58 84 inline void setBoolMask(P32 mask) {_mask = mask;}
59 85 inline void setThreadedLoading(const bool threaded) {_threaded = threaded;}
60 86
87 +
88 + template<class T>
89 + inline void setPropertyDescriptor(const T& descriptor) {
90 + _propertyDescriptor = New T(descriptor);
91 + }
92 +
61 93 private:
62 94 std::string _name; ///< Item name
63 95 std::string _resourceLocation; ///< Physical file location
  @@ -67,6 +99,8 @@
67 99 U32 _id;
68 100 P32 _mask; ///<4 bool values representing ... anything ...
69 101 U8 _enumValue;
102 +
103 + PropertyDescriptor* _propertyDescriptor; ///< Use for extra resource properties: textures, samplers, terrain etc.
70 104 };
71 105
72 106 #endif