gnSourceFactory Class Reference

gnSourceFactory is the middle man when acessing a sequence data source It tracks all data sources currently in use, ensuring that a particular data source is only opened and parsed once. More...

#include <gnSourceFactory.h>

Collaboration diagram for gnSourceFactory:

Collaboration graph
[legend]
List of all members.

Public Member Functions

boolean AddPath (const string &path)
 Adds the directory to the search path.
gnBaseSourceAddSource (const string &sourceStr, boolean searchPaths=true)
 Opens and returns a pointer to a source of genetic sequence data.
boolean DelPath (uint32 i)
 Deletes the directory path at index i from the search path list.
boolean DelSource (const gnBaseSource *source)
 Deletes the given source from the source list.
void DelSource (uint32 i)
 Deletes the source at index i in the source list.
boolean DelSourceClass (const string &ext)
 Deletes a file extension to class mapping.
gnBaseSourceGetDefaultSourceClass () const
 Gets the source class which is the default class for unknown file extensions.
string GetPath (uint32 i) const
 Gets the directory path at index i in the path list.
uint32 GetPathListSize () const
 Returns the number of directory paths to search for files.
gnBaseSourceGetSource (uint32 i) const
 Gets the source at index i in the source list.
gnBaseSourceGetSourceClass (const string &ext) const
 Gets the source class which is mapped to the specified file extension.
uint32 GetSourceClassListSize () const
 Returns the number of file extension to class mappings.
uint32 GetSourceListSize () const
 Returns the number of open data sources.
boolean HasPath (string path) const
 Checks the path list for the given path.
gnBaseSourceHasSource (string sourceStr, boolean searchPaths=true) const
 Gets the source if it has already been opened.
boolean HasSourceClass (const string &ext) const
 Checks if the specified file extension is recognized.
boolean InsPath (const string &path, uint32 i)
 Inserts the directory path at index i in the search path list.
gnBaseSourceMatchSourceClass (const string &sourceStr) const
 Gets the source class which would be mapped to the string.
boolean SetDefaultSourceClass (const gnBaseSource *source)
 Sets a source class to be the default class for unknown file extensions.
boolean SetSourceClass (const string &ext, const gnBaseSource &source)
 Maps the specified file extension to the given source class.
 ~gnSourceFactory ()

Static Public Member Functions

gnSourceFactoryGetSourceFactory ()
 Returns the current source factory.

Private Member Functions

 gnSourceFactory (gnSourceFactory &gnsf)
 gnSourceFactory ()
gnSourceFactoryoperator= (gnSourceFactory &gnsf)
boolean PathExists (string path) const

Static Private Member Functions

boolean GetURL (const string &urlStr, string &localFile)

Private Attributes

vector< string > m_pathList
gnBaseSourcem_pDefaultSourceClass
map< string, gnBaseSource * > m_sourceClassList
vector< gnBaseSource * > m_sourceList

Detailed Description

gnSourceFactory is the middle man when acessing a sequence data source It tracks all data sources currently in use, ensuring that a particular data source is only opened and parsed once.

When opening a data source it first tries to interpret the source location as a URL, opening the specified file, or downloading it if necessary. If that fails, it will attempt to open the source as a file on the local disk. gnSourceFactory uses the file extension to determine file format, so a file which ends with .fas will be opened by gnFASSource. Finally, gnSourceFactory can be given directory paths to search when opening a file whose path is not specified. IMPORTANT: Do not try to instantiate this class. To use this class do the following: gnSourceFactory* mySourceFactory = gnSourceFactory::GetSourceFactory();

Definition at line 37 of file gnSourceFactory.h.


Constructor & Destructor Documentation

gnSourceFactory::~gnSourceFactory  ) 
 

Definition at line 54 of file gnSourceFactory.cpp.

References m_sourceClassList, and m_sourceList.

gnSourceFactory::gnSourceFactory  )  [private]
 

Definition at line 39 of file gnSourceFactory.cpp.

References m_pDefaultSourceClass, and m_sourceClassList.

Referenced by GetSourceFactory().

gnSourceFactory::gnSourceFactory gnSourceFactory gnsf  )  [private]
 


Member Function Documentation

boolean gnSourceFactory::AddPath const string &  path  ) 
 

Adds the directory to the search path.

Parameters:
path The path to add.
Returns:
True if successful.
Definition at line 108 of file gnSourceFactory.cpp.

References HasPath(), m_pathList, and PathExists().

Referenced by main(), and gnDNXSource::ParseStream().

gnBaseSource * gnSourceFactory::AddSource const string &  sourceStr,
boolean  searchPaths = true
 

Opens and returns a pointer to a source of genetic sequence data.

If the source has already been opened, AddSource() returns a copy of the existing source class.

Parameters:
sourceStr The file name or URL where the source is located.
searchPaths Should the path list be searched if the file can't be found.
Returns:
A pointer to the source.
Definition at line 234 of file gnSourceFactory.cpp.

References gnBaseSource::Clone(), ErrorMsg(), getFileString(), GetURL(), HasSource(), m_pathList, m_sourceList, MatchSourceClass(), gnBaseSource::Open(), and Throw_gnEx.

Referenced by main(), and gnDNXSource::ParseStream().

boolean gnSourceFactory::DelPath uint32  i  ) 
 

Deletes the directory path at index i from the search path list.

Parameters:
i The index of the path to delete.
Returns:
True if successful, false if i is out of range.
Definition at line 116 of file gnSourceFactory.cpp.

References m_pathList, and uint32.

Referenced by main().

boolean gnSourceFactory::DelSource const gnBaseSource source  ) 
 

Deletes the given source from the source list.

This will close the associated file, network, or database connection.

Parameters:
source The source to close.
Returns:
True if successful.
Definition at line 335 of file gnSourceFactory.cpp.

References gnBaseSource::Close(), and m_sourceList.

void gnSourceFactory::DelSource uint32  i  ) 
 

Deletes the source at index i in the source list.

This will close the associated file, network, or database connection.

Parameters:
i The index of the source to delete.
Exceptions:
IndexOutOfBounds if i is too large
Definition at line 320 of file gnSourceFactory.cpp.

References gnBaseSource::Close(), m_sourceList, Throw_gnEx, and uint32.

boolean gnSourceFactory::DelSourceClass const string &  ext  ) 
 

Deletes a file extension to class mapping.

Parameters:
ext The extension to delete.
Returns:
True if successful.
Definition at line 69 of file gnSourceFactory.cpp.

References m_sourceClassList.

Referenced by main().

gnBaseSource * gnSourceFactory::GetDefaultSourceClass  )  const [inline]
 

Gets the source class which is the default class for unknown file extensions.

Returns:
The default class
Definition at line 213 of file gnSourceFactory.h.

References m_pDefaultSourceClass.

Referenced by main().

string gnSourceFactory::GetPath uint32  i  )  const
 

Gets the directory path at index i in the path list.

Parameters:
i The index of the path to get.
Returns:
The path or an empty string if i is out of range.
Definition at line 133 of file gnSourceFactory.cpp.

References m_pathList, and uint32.

Referenced by main().

uint32 gnSourceFactory::GetPathListSize  )  const [inline]
 

Returns the number of directory paths to search for files.

Returns:
The list size.
Definition at line 220 of file gnSourceFactory.h.

References m_pathList, and uint32.

Referenced by main().

gnBaseSource * gnSourceFactory::GetSource uint32  i  )  const
 

Gets the source at index i in the source list.

Parameters:
i The index of the source to get.
Returns:
The source.
Definition at line 314 of file gnSourceFactory.cpp.

References m_sourceList, and uint32.

gnBaseSource * gnSourceFactory::GetSourceClass const string &  ext  )  const
 

Gets the source class which is mapped to the specified file extension.

Parameters:
ext The extension to delete.
Returns:
The class associated with the extension.
Definition at line 77 of file gnSourceFactory.cpp.

References m_pDefaultSourceClass, and m_sourceClassList.

Referenced by main(), and MatchSourceClass().

uint32 gnSourceFactory::GetSourceClassListSize  )  const [inline]
 

Returns the number of file extension to class mappings.

Returns:
The list size.
Definition at line 199 of file gnSourceFactory.h.

References m_sourceClassList, and uint32.

Referenced by main().

gnSourceFactory * gnSourceFactory::GetSourceFactory  )  [inline, static]
 

Returns the current source factory.

Returns:
The current source factory.
Definition at line 189 of file gnSourceFactory.h.

References gnSourceFactory().

Referenced by gnSequence::LoadSource(), main(), gnDNXSource::ParseStream(), and gnDNXSource::Write().

uint32 gnSourceFactory::GetSourceListSize  )  const [inline]
 

Returns the number of open data sources.

Returns:
The list size.
Definition at line 225 of file gnSourceFactory.h.

References m_sourceList, and uint32.

Referenced by main().

boolean gnSourceFactory::GetURL const string &  urlStr,
string &  localFile
[static, private]
 

Definition at line 202 of file gnSourceFactory.cpp.

References uint32.

Referenced by AddSource().

boolean gnSourceFactory::HasPath string  path  )  const
 

Checks the path list for the given path.

Parameters:
path The path to look for.
Returns:
True if the path is in the path list.
Definition at line 139 of file gnSourceFactory.cpp.

References m_pathList, standarizePathString(), and uint32.

Referenced by AddPath(), and main().

gnBaseSource * gnSourceFactory::HasSource string  sourceStr,
boolean  searchPaths = true
const
 

Gets the source if it has already been opened.

Parameters:
sourceStr The file name or URL where the source is located.
searchPaths Should the path list be searched if the file can't be found.
Returns:
A pointer to the source.
Definition at line 353 of file gnSourceFactory.cpp.

References getFileString(), m_pathList, m_sourceList, and standarizePathString().

Referenced by AddSource(), and gnDNXSource::Write().

boolean gnSourceFactory::HasSourceClass const string &  ext  )  const
 

Checks if the specified file extension is recognized.

Parameters:
ext The extension to check.
Returns:
True if the extension has a class.
Definition at line 92 of file gnSourceFactory.cpp.

References m_sourceClassList.

Referenced by main().

boolean gnSourceFactory::InsPath const string &  path,
uint32  i
 

Inserts the directory path at index i in the search path list.

Parameters:
path The path to insert.
i The index of the path to insert before.
Returns:
True if successful, false if i is out of range.
Definition at line 124 of file gnSourceFactory.cpp.

References m_pathList, PathExists(), and uint32.

Referenced by main().

gnBaseSource * gnSourceFactory::MatchSourceClass const string &  sourceStr  )  const
 

Gets the source class which would be mapped to the string.

Parameters:
sourceStr The string to check, usually a filename.
Returns:
The class associated with the extension.
Definition at line 84 of file gnSourceFactory.cpp.

References GetSourceClass(), and m_pDefaultSourceClass.

Referenced by AddSource(), and main().

gnSourceFactory& gnSourceFactory::operator= gnSourceFactory gnsf  )  [private]
 

boolean gnSourceFactory::PathExists string  path  )  const [private]
 

Definition at line 380 of file gnSourceFactory.cpp.

References standarizePathString().

Referenced by AddPath(), and InsPath().

boolean gnSourceFactory::SetDefaultSourceClass const gnBaseSource source  )  [inline]
 

Sets a source class to be the default class for unknown file extensions.

Parameters:
source The default class to map
Returns:
True if successful.
Definition at line 204 of file gnSourceFactory.h.

References gnBaseSource::Clone(), and m_pDefaultSourceClass.

Referenced by main().

boolean gnSourceFactory::SetSourceClass const string &  ext,
const gnBaseSource source
 

Maps the specified file extension to the given source class.

e.g. ".fas" to gnFASSource

Parameters:
ext The extension to map.
source The class to map
Returns:
True if successful.
Definition at line 98 of file gnSourceFactory.cpp.

References gnBaseSource::Clone(), and m_sourceClassList.

Referenced by main().


Member Data Documentation

vector< string > gnSourceFactory::m_pathList [private]
 

Definition at line 182 of file gnSourceFactory.h.

Referenced by AddPath(), AddSource(), DelPath(), GetPath(), GetPathListSize(), HasPath(), HasSource(), and InsPath().

gnBaseSource* gnSourceFactory::m_pDefaultSourceClass [private]
 

Definition at line 185 of file gnSourceFactory.h.

Referenced by GetDefaultSourceClass(), GetSourceClass(), gnSourceFactory(), MatchSourceClass(), and SetDefaultSourceClass().

map< string, gnBaseSource* > gnSourceFactory::m_sourceClassList [private]
 

Definition at line 184 of file gnSourceFactory.h.

Referenced by DelSourceClass(), GetSourceClass(), GetSourceClassListSize(), gnSourceFactory(), HasSourceClass(), SetSourceClass(), and ~gnSourceFactory().

vector< gnBaseSource* > gnSourceFactory::m_sourceList [private]
 

Definition at line 183 of file gnSourceFactory.h.

Referenced by AddSource(), DelSource(), GetSource(), GetSourceListSize(), HasSource(), and ~gnSourceFactory().


The documentation for this class was generated from the following files:
Generated on Mon Feb 14 19:29:57 2005 for libGenome by doxygen 1.3.8