Files
Webcam/include/modules/tools/resource_explorer.h
2026-06-22 11:49:35 +02:00

94 lines
2.0 KiB
C++

/* -----------------------------------------------------------------------------
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 <NML::File> file;
AutoList <Dependency *> 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 <Resource *> resources;
void ExploreResourceRuleTags(const StringList &, uint pos, NML::Tag *, Resource *, int depth);
bool ExploreResourceRule(ExplorerRule &, Resource *, int depth);
public:
void Clear();
const AutoList <Resource *> &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__