Page Menu
Home
Phabricator (Chris)
Search
Configure Global Search
Log In
Files
F626239
resource.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
resource.cpp
View Options
#include
"bitmap.h"
#include
"resource.h"
// #include "factory/collector.h"
#include
"funcs.h"
#include
"sound.h"
#include
"load_exception.h"
#include
"file-system.h"
#include
<string>
#include
<vector>
using
namespace
std
;
Resource
*
Resource
::
resource
=
NULL
;
Sound
*
Resource::getSound
(
const
Filesystem
::
RelativePath
&
path
){
return
resource
->
_getSound
(
Storage
::
instance
().
find
(
path
));
}
Graphics
::
Bitmap
*
Resource::getBitmap
(
const
Filesystem
::
RelativePath
&
path
){
return
resource
->
_getBitmap
(
Storage
::
instance
().
find
(
path
));
}
/* the resource is created in the Collector */
Resource
::
Resource
(){
resource
=
this
;
}
Resource
::~
Resource
(){
for
(
std
::
map
<
std
::
string
,
Sound
*>::
iterator
it
=
sounds
.
begin
();
it
!=
sounds
.
end
();
it
++
){
delete
(
*
it
).
second
;
}
for
(
std
::
map
<
std
::
string
,
Graphics
::
Bitmap
*>::
iterator
it
=
bitmaps
.
begin
();
it
!=
bitmaps
.
end
();
it
++
){
delete
(
*
it
).
second
;
}
}
Sound
*
Resource
::
_getSound
(
const
Filesystem
::
AbsolutePath
&
path
){
Util
::
Thread
::
ScopedLock
locked
(
lock
);
if
(
sounds
[
path
.
path
()]
==
NULL
){
sounds
[
path
.
path
()]
=
new
Sound
(
path
.
path
());
}
return
sounds
[
path
.
path
()];
}
Graphics
::
Bitmap
*
Resource
::
_getBitmap
(
const
Filesystem
::
AbsolutePath
&
path
){
Util
::
Thread
::
ScopedLock
locked
(
lock
);
if
(
bitmaps
[
path
.
path
()]
==
NULL
){
bitmaps
[
path
.
path
()]
=
new
Graphics
::
Bitmap
(
path
.
path
());
}
return
bitmaps
[
path
.
path
()];
}
File Metadata
Details
Attached
Mime Type
text/x-c++
Expires
Sun, Nov 15, 12:29 AM (1 d, 16 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
121422
Default Alt Text
resource.cpp (1 KB)
Attached To
Mode
R75 R-Tech1
Attached
Detach File
Event Timeline