Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members  

ODBCFilePlugin.h

00001 /*
00002    Copyright (C) 2002 the Strongroom project
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Lesser General Public
00006    License as published by the Free Software Foundation; either
00007    version 2.1 of the License, or (at your option) any later version.
00008 
00009    @author Ewald Snel
00010 */
00011 
00012 #ifndef __ODBCFILEPLUGIN_H
00013 #define __ODBCFILEPLUGIN_H
00014 
00015 #include <pthread.h>
00016 
00017 #include <FilePlugin.h>
00018 #include <HashUtils.h>
00019 #include <ODBCConnection.h>
00020 #include <ODBCQuery.h>
00021 
00022 
00023 // Open file information
00024 struct OpenFileInfo
00025 {
00026     ODBCQuery *query;
00027     int64_t length;
00028     NumID fileid;
00029 };
00030 
00031 
00049 class ODBCFilePlugin : public FilePlugin
00050 {
00051 public:
00052     ODBCFilePlugin( const Config &cfg );
00053     ~ODBCFilePlugin();
00054 
00055     bool init();
00056 
00057     CoreError create( NumID &fileid );
00058     CoreError open( NumID fileid, NumID &of );
00059     CoreError remove( NumID fileid );
00060 
00061     int64_t getLength( NumID fileid );
00062     CoreError write( NumID fileid, char *data, int length );
00063     CoreError read( NumID fileid, char *data, int length, int &bRead );
00064     CoreError close( NumID fileid );
00065 
00066 private:
00067     ODBCConnection odbc;
00068     pthread_mutex_t mutex;
00069     hash_map<NumID,OpenFileInfo,_hash_NumID> openFiles;
00070     hash_map<NumID,int,_hash_NumID> fileLocks;
00071 };
00072 
00073 #endif

Generated on Wed Feb 18 13:45:55 2004 for strongroom by doxygen1.2.18