GridComputing
Job Management in Grid Computing
Main Page
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
loader.h
Go to the documentation of this file.
1
#ifndef LOADER_H_
2
#define LOADER_H_
3
4
#include "
utils.h
"
5
#include "
file.h
"
6
#include "
bytebuffer.h
"
7
#include <string>
8
10
13
template
<
class
Loadable>
14
class
Loader
15
{
16
public
:
21
Loader
(
const
std::string& fileName) :
_fileName
(fileName) {}
22
27
Loadable*
Load
();
28
private
:
30
std::string
_fileName
;
31
};
32
33
template
<
class
Loadable>
34
Loadable*
Loader<Loadable>::Load
()
35
{
36
size_t
size;
37
char
* buffer;
38
if
(!
File::Load
(_fileName.c_str(), buffer, size))
39
return
NULL;
40
41
ByteBuffer
bb(size);
42
bb.
WriteBuffer
(buffer, size);
43
44
delete
[] buffer;
45
46
return
Loadable::Load
(bb);
47
}
48
50
53
template
<
class
Savable>
54
class
Saver
55
{
56
public
:
61
Saver
(
const
std::string& fileName) :
_fileName
(fileName) {}
62
67
bool
Save
(Savable* s);
68
69
private
:
71
std::string
_fileName
;
72
};
73
74
template
<
class
Savable>
75
bool
Saver<Savable>::Save
(Savable* s)
76
{
77
ByteBuffer
bb(100);
78
if
(!s->Save(bb))
79
return
false
;
80
81
return
File::Save
(_fileName.c_str(), bb, bb.
Size
());
82
}
83
84
#endif // LOADER_H_
src
loader.h
Generated on Sun Dec 30 2012 14:13:37 for GridComputing by
1.8.2