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

ODBCMetadataPlugin.h

00001 /*
00002    Copyright (C) 2002 - 2003 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    @author Wouter de Vries
00011 */
00012 
00013 #ifndef __ODBCMETADATAPLUGIN_H
00014 #define __ODBCMETADATAPLUGIN_H
00015 
00016 #include <pthread.h>
00017 
00018 #include <MetadataPlugin.h>
00019 #include <ODBCConnection.h>
00020 #include <ODBCQuery.h>
00021 
00022 
00026 class FastLock
00027 {
00028 public:
00029     FastLock() {}
00030     FastLock( pthread_t thread, int lockCount, int pending )
00031         : thread( thread ), lockCount( lockCount ), pending( pending ) {}
00032 
00033     pthread_t thread;
00034     int lockCount;
00035     int pending;
00036 };
00037 
00038 
00068 class ODBCMetadataPlugin : public MetadataPlugin
00069 {
00070 public:
00071     ODBCMetadataPlugin( const Config &cfg );
00072     ~ODBCMetadataPlugin();
00073 
00078     bool init();
00079 
00080     CoreError create( NumID &docid, const Document &document );
00081     CoreError remove( NumID docid );
00082     CoreError update( NumID docid, const Document &document );
00083     CoreError get( NumID docid, Document &document );
00084     CoreError lock( NumID docid, DocumentLock lock );
00085     CoreError getLocks( map<NumID,DocumentLock> &locks );
00086     CoreError query( NumID first, int maxlen, map<NumID,NumID> &updates );
00087 
00088 private:
00093     void fastLock( NumID docid );
00094 
00100     bool fastUnlock( NumID docid );
00101 
00107     bool fastTestLock( NumID docid );
00108 
00112     bool tablesExist();
00113 
00117     bool tablesCorrect();
00118 
00122     bool createTables();
00123 
00124     ODBCConnection odbc;
00125     pthread_mutex_t mutex;
00126     pthread_cond_t cond;
00127     hash_map<NumID,FastLock,_hash_NumID> fastLocks;
00128 };
00129 
00130 #endif

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