SHOGUN
6.0.0
src
shogun
classifier
vw
cache
VwCacheWriter.cpp
Go to the documentation of this file.
1
/*
2
* Copyright (c) 2009 Yahoo! Inc. All rights reserved. The copyrights
3
* embodied in the content of this file are licensed under the BSD
4
* (revised) open source license.
5
*
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 3 of the License, or
9
* (at your option) any later version.
10
*
11
* Written (W) 2011 Shashwat Lal Das
12
* Adaptation of Vowpal Wabbit v5.1.
13
* Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society.
14
*/
15
16
#include <
shogun/classifier/vw/cache/VwCacheWriter.h
>
17
#include <fcntl.h>
18
#ifdef _WIN32
19
#include <io.h>
20
#endif
21
22
using namespace
shogun
;
23
24
CVwCacheWriter::CVwCacheWriter
()
25
:
CSGObject
()
26
{
27
fd
= -1;
28
env
= NULL;
29
}
30
31
CVwCacheWriter::CVwCacheWriter
(
char
* fname,
CVwEnvironment
* env_to_use)
32
:
CSGObject
()
33
{
34
fd
= open(fname, O_CREAT | O_TRUNC | O_RDWR, 0666);
35
36
if
(
fd
< 0)
37
SG_SERROR
(
"Error opening the file %s for writing cache!\n"
)
38
39
env
= env_to_use;
40
SG_REF
(
env
);
41
}
42
43
CVwCacheWriter::CVwCacheWriter
(int32_t f,
CVwEnvironment
* env_to_use)
44
:
CSGObject
()
45
{
46
fd
= f;
47
env
= env_to_use;
48
SG_REF
(
env
);
49
}
50
51
CVwCacheWriter::~CVwCacheWriter
()
52
{
53
if
(
env
)
54
SG_UNREF
(
env
);
55
}
56
57
void
CVwCacheWriter::set_file
(int32_t f)
58
{
59
fd
= f;
60
}
61
62
void
CVwCacheWriter::set_env
(
CVwEnvironment
* env_to_use)
63
{
64
env
= env_to_use;
65
SG_REF
(
env
);
66
}
67
68
CVwEnvironment
*
CVwCacheWriter::get_env
()
69
{
70
SG_REF
(
env
);
71
return
env
;
72
}
VwCacheWriter.h
shogun::CVwEnvironment
Class CVwEnvironment is the environment used by VW.
Definition:
VwEnvironment.h:41
shogun::CVwCacheWriter::get_env
virtual CVwEnvironment * get_env()
Definition:
VwCacheWriter.cpp:68
SG_REF
#define SG_REF(x)
Definition:
SGObject.h:52
shogun::CVwCacheWriter::set_file
virtual void set_file(int32_t f)
Definition:
VwCacheWriter.cpp:57
shogun::CVwCacheWriter::set_env
virtual void set_env(CVwEnvironment *env_to_use)
Definition:
VwCacheWriter.cpp:62
shogun::CVwCacheWriter::CVwCacheWriter
CVwCacheWriter()
Definition:
VwCacheWriter.cpp:24
shogun::CSGObject
Class SGObject is the base class of all shogun objects.
Definition:
SGObject.h:125
shogun::CVwCacheWriter::env
CVwEnvironment * env
Environment.
Definition:
VwCacheWriter.h:99
shogun::CVwCacheWriter::fd
int32_t fd
File descriptor.
Definition:
VwCacheWriter.h:96
shogun::CVwCacheWriter::~CVwCacheWriter
virtual ~CVwCacheWriter()
Definition:
VwCacheWriter.cpp:51
SG_UNREF
#define SG_UNREF(x)
Definition:
SGObject.h:53
shogun
all of classes and functions are contained in the shogun namespace
Definition:
class_list.h:18
SG_SERROR
#define SG_SERROR(...)
Definition:
SGIO.h:178
SHOGUN
Machine Learning Toolbox - Documentation