Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/base/StarAssetSource.hpp
blob: 0842d342b6291908b0e274fb88345946fecef524 (plain)
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
#pragma once

#include "StarIODevice.hpp"
#include "StarJson.hpp"

namespace Star {

STAR_CLASS(AssetSource);

STAR_EXCEPTION(AssetSourceException, StarException);

// An asset source could be a directory on a filesystem, where assets are
// pulled directly from files, or a single pak-like file containing all assets,
// where assets are pulled from the correct region of the pak-like file.
class AssetSource {
public:
  virtual ~AssetSource() = default;

  // An asset source can have arbitrary metadata attached.
  virtual JsonObject metadata() const = 0;

  // Should return all the available assets in this source
  virtual StringList assetPaths() const = 0;

  // Open the given path in this source and return an IODevicePtr to it.
  virtual IODevicePtr open(String const& path) = 0;

  // Read the entirety of the given path into a buffer.
  virtual ByteArray read(String const& path) = 0;
};

}