VwCacheWriter.cpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2009 Yahoo! Inc.  All rights reserved.  The copyrights
00003  * embodied in the content of this file are licensed under the BSD
00004  * (revised) open source license.
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 3 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * Written (W) 2011 Shashwat Lal Das
00012  * Adaptation of Vowpal Wabbit v5.1.
00013  * Copyright (C) 2011 Berlin Institute of Technology and Max-Planck-Society.
00014  */
00015 
00016 #include <shogun/classifier/vw/cache/VwCacheWriter.h>
00017 
00018 using namespace shogun;
00019 
00020 CVwCacheWriter::CVwCacheWriter()
00021     : CSGObject()
00022 {
00023     fd = -1;
00024     env = NULL;
00025 }
00026 
00027 CVwCacheWriter::CVwCacheWriter(char * fname, CVwEnvironment* env_to_use)
00028     : CSGObject()
00029 {
00030     fd = open(fname, O_CREAT | O_TRUNC | O_RDWR, 0666);
00031 
00032     if (fd < 0)
00033         SG_SERROR("Error opening the file %s for writing cache!\n");
00034 
00035     env = env_to_use;
00036     SG_REF(env);
00037 }
00038 
00039 CVwCacheWriter::CVwCacheWriter(int32_t f, CVwEnvironment* env_to_use)
00040     : CSGObject()
00041 {
00042     fd = f;
00043     env = env_to_use;
00044     SG_REF(env);
00045 }
00046 
00047 CVwCacheWriter::~CVwCacheWriter()
00048 {
00049     if (env)
00050         SG_UNREF(env);
00051 }
00052 
00053 void CVwCacheWriter::set_file(int32_t f)
00054 {
00055     fd = f;
00056 }
00057 
00058 void CVwCacheWriter::set_env(CVwEnvironment* env_to_use)
00059 {
00060     env = env_to_use;
00061     SG_REF(env);
00062 }
00063 
00064 CVwEnvironment* CVwCacheWriter::get_env()
00065 {
00066     SG_REF(env);
00067     return env;
00068 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

SHOGUN Machine Learning Toolbox - Documentation