aboutsummaryrefslogtreecommitdiff
path: root/core/resource.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/resource.h')
-rw-r--r--core/resource.h77
1 files changed, 35 insertions, 42 deletions
diff --git a/core/resource.h b/core/resource.h
index 3ea54ef27..c391a4f31 100644
--- a/core/resource.h
+++ b/core/resource.h
@@ -30,25 +30,25 @@
#define RESOURCE_H
#include "object.h"
-#include "safe_refcount.h"
+#include "object_type_db.h"
#include "ref_ptr.h"
#include "reference.h"
-#include "object_type_db.h"
+#include "safe_refcount.h"
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
-#define RES_BASE_EXTENSION(m_ext)\
-public:\
-static void register_custom_data_to_otdb() { ObjectTypeDB::add_resource_base_extension(m_ext,get_type_static()); }\
-virtual String get_base_extension() const { return m_ext; }\
+#define RES_BASE_EXTENSION(m_ext) \
+public: \
+ static void register_custom_data_to_otdb() { ObjectTypeDB::add_resource_base_extension(m_ext, get_type_static()); } \
+ virtual String get_base_extension() const { return m_ext; } \
+ \
private:
-
class ResourceImportMetadata : public Reference {
- OBJ_TYPE( ResourceImportMetadata, Reference );
+ OBJ_TYPE(ResourceImportMetadata, Reference);
struct Source {
String path;
@@ -58,44 +58,44 @@ class ResourceImportMetadata : public Reference {
Vector<Source> sources;
String editor;
- Map<String,Variant> options;
+ Map<String, Variant> options;
StringArray _get_options() const;
+
protected:
virtual bool _use_builtin_script() const { return false; }
static void _bind_methods();
-public:
- void set_editor(const String& p_editor);
+public:
+ void set_editor(const String &p_editor);
String get_editor() const;
- void add_source(const String& p_path,const String& p_md5="");
+ void add_source(const String &p_path, const String &p_md5 = "");
String get_source_path(int p_idx) const;
String get_source_md5(int p_idx) const;
- void set_source_md5(int p_idx,const String& p_md5);
+ void set_source_md5(int p_idx, const String &p_md5);
void remove_source(int p_idx);
int get_source_count() const;
- void set_option(const String& p_key, const Variant& p_value);
- Variant get_option(const String& p_key) const;
- bool has_option(const String& p_key) const;
+ void set_option(const String &p_key, const Variant &p_value);
+ Variant get_option(const String &p_key) const;
+ bool has_option(const String &p_key) const;
void get_options(List<String> *r_options) const;
ResourceImportMetadata();
};
-
class Resource : public Reference {
- OBJ_TYPE( Resource, Reference );
+ OBJ_TYPE(Resource, Reference);
OBJ_CATEGORY("Resources");
RES_BASE_EXTENSION("res");
Set<ObjectID> owners;
-friend class ResBase;
-friend class ResourceCache;
+ friend class ResBase;
+ friend class ResourceCache;
String name;
String path_cache;
@@ -109,7 +109,6 @@ friend class ResourceCache;
#endif
protected:
-
void emit_changed();
void notify_change_to_owners();
@@ -117,38 +116,35 @@ protected:
virtual void _resource_path_changed();
static void _bind_methods();
- void _set_path(const String& p_path);
- void _take_over_path(const String& p_path);
-public:
+ void _set_path(const String &p_path);
+ void _take_over_path(const String &p_path);
+public:
virtual bool editor_can_reload_from_file();
virtual void reload_from_file();
void register_owner(Object *p_owner);
void unregister_owner(Object *p_owner);
- void set_name(const String& p_name);
+ void set_name(const String &p_name);
String get_name() const;
- virtual void set_path(const String& p_path,bool p_take_over=false);
+ virtual void set_path(const String &p_path, bool p_take_over = false);
String get_path() const;
void set_subindex(int p_sub_index);
int get_subindex() const;
- Ref<Resource> duplicate(bool p_subresources=false);
+ Ref<Resource> duplicate(bool p_subresources = false);
- void set_import_metadata(const Ref<ResourceImportMetadata>& p_metadata);
+ void set_import_metadata(const Ref<ResourceImportMetadata> &p_metadata);
Ref<ResourceImportMetadata> get_import_metadata() const;
-
-
-
#ifdef TOOLS_ENABLED
uint32_t hash_edited_version() const;
- virtual void set_last_modified_time(uint64_t p_time) { last_modified_time=p_time; }
+ virtual void set_last_modified_time(uint64_t p_time) { last_modified_time = p_time; }
uint64_t get_last_modified_time() const { return last_modified_time; }
#endif
@@ -157,26 +153,23 @@ public:
Resource();
~Resource();
-
};
-
typedef Ref<Resource> RES;
class ResourceCache {
-friend class Resource;
- static HashMap<String,Resource*> resources;
-friend void unregister_core_types();
+ friend class Resource;
+ static HashMap<String, Resource *> resources;
+ friend void unregister_core_types();
static void clear();
-public:
+public:
static void reload_externals();
- static bool has(const String& p_path);
- static Resource* get(const String& p_path);
- static void dump(const char* p_file=NULL,bool p_short=false);
+ static bool has(const String &p_path);
+ static Resource *get(const String &p_path);
+ static void dump(const char *p_file = NULL, bool p_short = false);
static void get_cached_resources(List<Ref<Resource> > *p_resources);
static int get_cached_resource_count();
-
};
#endif