|
gnSourceFactory.hGo to the documentation of this file.00001 00002 // File: gnSourceFactory.h 00003 // Purpose: Manage data sources 00004 // Description: Manages data sources by tracking open files/databases/URLs 00005 // Changes: 00006 // Version: libGenome 0.1.0 00007 // Author: Aaron Darling 00008 // Last Edited: April 15, 2001, 10:34:50pm 00009 // Modified by: 00010 // Copyright: (c) Aaron Darling 00011 // Licenses: Proprietary 00013 #ifndef _gnSourceFactory_h_ 00014 #define _gnSourceFactory_h_ 00015 00016 #include "gn/gnDefs.h" 00017 00018 #include <string> 00019 #include <vector> 00020 #include <map> 00021 #include "gn/gnBaseSource.h" 00022 00038 class GNDLLEXPORT gnSourceFactory{ 00039 public: 00040 ~gnSourceFactory(); 00041 00046 static gnSourceFactory* GetSourceFactory(); 00047 // Plugin Sources 00052 uint32 GetSourceClassListSize() const; 00058 boolean DelSourceClass( const string& ext ); 00064 gnBaseSource* GetSourceClass( const string& ext ) const; 00070 gnBaseSource* MatchSourceClass( const string& sourceStr ) const; 00076 boolean HasSourceClass( const string& ext ) const; 00084 boolean SetSourceClass( const string& ext, const gnBaseSource& source ); 00090 boolean SetDefaultSourceClass( const gnBaseSource* source ); 00095 gnBaseSource* GetDefaultSourceClass() const; 00096 // Directory paths to search for sources 00101 uint32 GetPathListSize() const; 00107 boolean AddPath( const string& path ); 00113 boolean DelPath( uint32 i ); 00120 boolean InsPath( const string& path, uint32 i ); 00126 string GetPath( uint32 i ) const; 00132 boolean HasPath( string path ) const; 00133 // Sources 00138 uint32 GetSourceListSize() const; 00146 gnBaseSource* AddSource( const string& sourceStr, boolean searchPaths = true ); 00152 gnBaseSource* GetSource( uint32 i ) const; 00159 void DelSource( uint32 i ); 00166 boolean DelSource( const gnBaseSource* source ); 00173 gnBaseSource* HasSource( string sourceStr, boolean searchPaths = true ) const; 00174 00175 private: 00176 gnSourceFactory(); 00177 gnSourceFactory(gnSourceFactory& gnsf); 00178 gnSourceFactory& operator=(gnSourceFactory& gnsf); 00179 00180 boolean PathExists( string path ) const; 00181 static boolean GetURL( const string& urlStr, string& localFile ); 00182 00183 vector< string > m_pathList; 00184 vector< gnBaseSource* > m_sourceList; 00185 map< string, gnBaseSource* > m_sourceClassList; 00186 gnBaseSource* m_pDefaultSourceClass; 00187 };//class gnSourceFactory 00188 00189 inline 00190 gnSourceFactory* gnSourceFactory::GetSourceFactory() 00191 { 00192 //use construct on first use method to avoid the static constructor 00193 //initialization fiasco... 00194 static gnSourceFactory* m_sSourceFactory = new gnSourceFactory(); 00195 return m_sSourceFactory; 00196 } 00197 00198 // Plugin Sources 00199 inline 00200 uint32 gnSourceFactory::GetSourceClassListSize() const 00201 { 00202 return m_sourceClassList.size(); 00203 } 00204 inline 00205 boolean gnSourceFactory::SetDefaultSourceClass( const gnBaseSource* source ) 00206 { 00207 if(m_pDefaultSourceClass != NULL){ 00208 delete m_pDefaultSourceClass; 00209 } 00210 m_pDefaultSourceClass = source->Clone(); 00211 return true; 00212 } 00213 inline 00214 gnBaseSource* gnSourceFactory::GetDefaultSourceClass() const 00215 { 00216 return m_pDefaultSourceClass; 00217 } 00218 00219 // Directory paths to search for sources 00220 inline 00221 uint32 gnSourceFactory::GetPathListSize() const 00222 { 00223 return m_pathList.size(); 00224 } 00225 inline 00226 uint32 gnSourceFactory::GetSourceListSize() const 00227 { 00228 return m_sourceList.size(); 00229 } 00230 00231 00232 #endif 00233 // _gnSourceFactory_h_ Generated at Fri Nov 30 15:36:52 2001 for libGenome by 1.2.8.1 written by Dimitri van Heesch, © 1997-2001 |