/* ----------------------------------------------------------------------------- GSFramework Copyright 2001-2013 Emmanuel Julien. All Rights Reserved. ----------------------------------------------------------------------------- */ #ifndef __RESOURCEEXPLORER__ #define __RESOURCEEXPLORER__ #include "nstring/nstring.h" #include "container/nlist.h" #include "memory/nauto_ptr.h" #include "metafile/nml.h" namespace GS { namespace Resource { //------------------------------------------------------------------------------ struct DependencyRule { const char *path; const char *type; }; struct ExplorerRule { const char *type, *root; DependencyRule *rules; }; //------------------------------------------------------------------------------ // struct Explorer { struct Dependency { bool missing; virtual const char *GetName() const = 0; virtual void SetName(const char *) = 0; Dependency() : missing(true) {} virtual ~Dependency() {} }; struct DependencyTag : public Dependency { NML::Tag *tag; virtual const char *GetName() const; virtual void SetName(const char *); DependencyTag(NML::Tag *t) : tag(t) {} }; struct Resource { String name, type; AutoPtr file; AutoList dependencies; const Dependency *FindDependency(const char *) const; bool HasMissingDependencies() const; Resource(const char *n, const char *t) : name(n), type(t) {} }; private: String project_path, core_path; bool recursive; AutoList resources; void ExploreResourceRuleTags(const StringList &, uint pos, NML::Tag *, Resource *, int depth); bool ExploreResourceRule(ExplorerRule &, Resource *, int depth); public: void Clear(); const AutoList &GetResources() const { return resources; } const Resource *FindResource(const char *) const; // Explore dependencies for a given resource. Resource *ExploreResource(const char *name, const char *base_path, const char *core_path, int max_depth = 128); }; } // Resource } // GS #endif // __RESOURCEEXPLORER__