blip  0.1
Asset.hpp
Go to the documentation of this file.
1 #ifndef __blip__Asset_hpp
2 #define __blip__Asset_hpp
3 
4 #include <blip/Blip.hpp>
5 
6 #include <commonc++/IOException.h++>
7 #include <commonc++/Stream.h++>
8 
9 struct AAsset;
10 
11 namespace blip {
12 
13 class AssetManager;
14 
23 class Asset
24 {
25  friend class AssetManager;
26 
27  public:
28 
30  ~Asset();
31 
40  size_t read(byte_t* buf, size_t count);
41 
49  off_t seek(off_t offset, ccxx::SeekMode mode);
50 
58  const byte_t* getBuffer();
59 
61  off_t getLength();
62 
64  off_t getBytesRemaining();
65 
69  bool isAllocated() const;
70 
71  protected:
72 
73  private:
74 
75  Asset(AAsset* asset);
76 
77  AAsset* _asset;
78 
79  CCXX_COPY_DECLS(Asset);
80 };
81 
82 } // namespace blip
83 
84 #endif // __blip__Asset_hpp
An asset manager, which provides access to the application&#39;s raw asset files.
Definition: AssetManager.hpp:34
off_t seek(off_t offset, ccxx::SeekMode mode)
Seek to a goven offset in the asset file.
Definition: Asset.cpp:44
off_t getBytesRemaining()
Get the number of bytes remaining to be read from the asset.
Definition: Asset.cpp:94
WAV file format details at: https://ccrma.stanford.edu/courses/422/projects/WaveFormat/.
Definition: AccelerometerSensorEvent.cpp:3
~Asset()
Destructor.
Definition: Asset.cpp:22
An application asset file.
Definition: Asset.hpp:23
off_t getLength()
Get the length of the asset file, in bytes.
Definition: Asset.cpp:86
bool isAllocated() const
Determine if the asset&#39;s internal buffer is allocated in ordinary RAM (as opposed to being memory-map...
Definition: Asset.cpp:102
size_t read(byte_t *buf, size_t count)
Read raw data from the asset file.
Definition: Asset.cpp:30
const byte_t * getBuffer()
If the asset has been read into an in-memory buffer, get a pointer to that buffer.
Definition: Asset.cpp:74