Nebula
Toggle main menu visibility
Loading...
Searching...
No Matches
streamcache.h
Go to the documentation of this file.
1
#pragma once
2
//------------------------------------------------------------------------------
12
13
#include "
core/refcounted.h
"
14
#include "
core/singleton.h
"
15
#include "
io/uri.h
"
16
#include "
io/stream.h
"
17
#include "
util/dictionary.h
"
18
19
//------------------------------------------------------------------------------
20
namespace
IO
21
{
22
class
StreamCache
:
public
Core::RefCounted
23
{
24
__DeclareClass
(
StreamCache
);
25
__DeclareSingleton
(
StreamCache
);
26
public
:
28
StreamCache
();
30
virtual
~StreamCache
();
31
33
bool
IsCached
(
IO::URI
const
& uri)
const
;
35
Util::KeyValuePair<void*,Ptr<IO::Stream>
>
GetCachedStream
(
IO::URI
const
& uri);
37
bool
OpenStream
(
IO::URI
const
& uri,
Core::Rtti
const
& rtti);
39
void
RemoveStream
(
IO::URI
const
& uri);
40
41
private
:
43
void
Discard
();
44
struct
CacheEntry
45
{
46
Ptr<IO::Stream>
stream
;
47
void
*
buffer
=
nullptr
;
48
SizeT
useCount
= 0;
49
};
50
51
Util::Dictionary<Util::String, CacheEntry>
streams
;
52
};
53
54
}
// namespace IO
55
//------------------------------------------------------------------------------
Core::RefCounted
The common base class of Nebula.
Definition
refcounted.h:38
Core::Rtti
Nebula's runtime type information for one class.
Definition
rtti.h:27
IO::StreamCache::GetCachedStream
Util::KeyValuePair< void *, Ptr< IO::Stream > > GetCachedStream(IO::URI const &uri)
Definition
streamcache.cc:45
IO::StreamCache::~StreamCache
virtual ~StreamCache()
destructor
Definition
streamcache.cc:26
IO::StreamCache::__DeclareSingleton
__DeclareSingleton(StreamCache)
IO::StreamCache::IsCached
bool IsCached(IO::URI const &uri) const
Definition
streamcache.cc:36
IO::StreamCache::Discard
void Discard()
discard
Definition
streamcache.cc:100
IO::StreamCache::OpenStream
bool OpenStream(IO::URI const &uri, Core::Rtti const &rtti)
Definition
streamcache.cc:57
IO::StreamCache::RemoveStream
void RemoveStream(IO::URI const &uri)
Definition
streamcache.cc:81
IO::StreamCache::StreamCache
StreamCache()
constructor
Definition
streamcache.cc:18
IO::StreamCache::__DeclareClass
__DeclareClass(StreamCache)
IO::StreamCache::streams
Util::Dictionary< Util::String, CacheEntry > streams
Definition
streamcache.h:51
IO::URI
An URI object can split a Uniform Resource Identifier string into its components or build a string fr...
Definition
uri.h:67
Ptr
Nebula's smart pointer class which manages the life time of RefCounted objects.
Definition
ptr.h:38
Util::Dictionary
A collection of key/value pairs with quick value retrieval by key at roughly O(log n).
Definition
dictionary.h:35
Util::KeyValuePair
Key/Value pair objects are used by most assiociative container classes, like Dictionary or HashTable.
Definition
keyvaluepair.h:19
dictionary.h
IO
Instances of wrapped stream classes.
Definition
multiplayerfeatureunit.cc:324
refcounted.h
singleton.h
stream.h
IO::StreamCache::CacheEntry
Definition
streamcache.h:45
IO::StreamCache::CacheEntry::buffer
void * buffer
Definition
streamcache.h:47
IO::StreamCache::CacheEntry::useCount
SizeT useCount
Definition
streamcache.h:48
IO::StreamCache::CacheEntry::stream
Ptr< IO::Stream > stream
Definition
streamcache.h:46
SizeT
int SizeT
Definition
types.h:42
uri.h
code
foundation
io
cache
streamcache.h
Generated on
for Nebula. Dark theme by
Tilen Majerle
. All rights reserved.