FilterManager Class Reference

Take out some of the functionality from filters. More...

#include <filtrmgr.h>

List of all members.

Public Types

enum  DESTRUCTION_METHOD { DM_INVALID = 0, DM_DELETE_WHEN_DONE = 1, DM_KEEP_WHEN_DONE }

Public Member Functions

 FilterManager ()
 Set the Filter object up to be in a clean state.
BOOL Init ()
 Initializes the filter manager Currently just does some tests.
INT32 DeInit ()
 Destroy all the FileFormat objects, maybe.
UINT32 RegisterFilter (Filter *const pFilter, const DESTRUCTION_METHOD DestructMethod)
 Permits the filter to be used by the FilterManager. For an import filter to be present on the Import dialog the filter should associate itself with the requisite FileFormats via AssociateFilterWithFormat().
FileFormatID RegisterFileFormat (FileFormat *const pFormat, const DESTRUCTION_METHOD DestructMethod)
 Registers the given FileFormat with this FilterManager.
BOOL AssociateFilterWithFormat (const UINT32 FilterID, const FileFormatID FileFormatID)
FilterFindFilterFromID (const UINT32 FilterID) const
 Provides the Filter given its ID.
FilterFindFilter (FilterSearchCriteria &Criteria) const
 To find a filter with the given SearchCriteria Notes: Returns the first matching filter within the context of the given SearchCriteria (the SearchContext is contained within the SearchCriteria).
FilterListListMatchingFilters (FilterSearchCriteria &Criteria)
 Creates a list of filters matching the given FilterSearchCriteria.
FileFormatFindFormatFromID (const FileFormatID FormatID) const
 Provides the FileFormat given its ID See Also: FindFormatEntryFromID.
FileFormatFindFormatFromName (const StringBase &FormatName) const
 Finds the one & only FileFormat with the given FormatName Used by Xtra's mainly.
FileFormatID FindFormatIDFromName (const StringBase &Name) const
 Relief function returning the FileFormat ID instead of the FileFormat per se See Also: Other overloaded function.

Protected Member Functions

ListGetFilters () const
UINT32 GetNewFilterID ()
 Support function providing an unique ID for each newly registered Filter.
FormatArrayGetFormats ()
 Support function providing access to the FileFormats.
const FormatArrayGetFormats () const
FileFormatID GetNewFormatID ()
 Support function providing an unique ID for each newly registered FileFormat.
FileFormatID GetLastFormatID () const
FormatEntryFindFormatEntryFromID (const FileFormatID FormatID) const
 Internally does the actual finding by ID See Also: FindFormatFromID.
FormatEntryFindFormatEntryFromName (const StringBase &FormatName) const
 Finds the one & only FileFormat with the given FormatName Used by Xtra's mainly.

Protected Attributes

const UINT32 FILTERID_START
const FileFormatID FORMATID_START

Private Member Functions

 CC_DECLARE_MEMDUMP (FilterManager)

Private Attributes

UINT32 m_NextFilterID
FormatArray m_Formats
FileFormatID m_NextFormatID


Detailed Description

Take out some of the functionality from filters.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
Today

Definition at line 148 of file filtrmgr.h.


Member Enumeration Documentation

enum FilterManager::DESTRUCTION_METHOD
 

Enumerator:
DM_INVALID 
DM_DELETE_WHEN_DONE 
DM_KEEP_WHEN_DONE 

Definition at line 161 of file filtrmgr.h.

00162     {
00163         DM_INVALID          = 0,    // don't use this, it's for catching duff initialization
00164         DM_DELETE_WHEN_DONE = 1,
00165         DM_KEEP_WHEN_DONE
00166     };


Constructor & Destructor Documentation

FilterManager::FilterManager  ) 
 

Set the Filter object up to be in a clean state.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/02/94
See also:
Filter; Filter::~Filter; OILFilter

Definition at line 130 of file filtrmgr.cpp.

00130                              :
00131     FILTERID_START(FILTERID_ALDUS_END + 1),
00132     FORMATID_START(1)
00133 {
00134     m_NextFilterID      = FILTERID_START;
00135     m_NextFormatID      = FORMATID_START;
00136 }


Member Function Documentation

BOOL FilterManager::AssociateFilterWithFormat const UINT32  FilterID,
const FileFormatID  FileFormatID
 

FilterManager::CC_DECLARE_MEMDUMP FilterManager   )  [private]
 

BOOL FilterManager::DeInit  ) 
 

Destroy all the FileFormat objects, maybe.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/12/96

Definition at line 232 of file filtrmgr.cpp.

00233 {
00234     for (UINT32 index = 0; index < GetLastFormatID(); index++)
00235     {
00236         FormatEntry* pEntry = GetFormats()[index];
00237         ERROR2IF(pEntry == NULL, FALSE, "pEntry NULL");
00238 
00239         FileFormat* pFormat = pEntry->GetFormat();
00240         ERROR2IF(pFormat == NULL, FALSE, "pFormat NULL");
00241 
00242         if (pEntry->GetDestructionMethod() == DM_DELETE_WHEN_DONE)
00243         {
00244             delete pFormat;
00245         }
00246         delete pEntry;
00247         GetFormats()[index] = NULL;
00248     }
00249 
00250     // All ok
00251     return TRUE;
00252 }

Filter * FilterManager::FindFilter FilterSearchCriteria &  Criteria  )  const
 

To find a filter with the given SearchCriteria Notes: Returns the first matching filter within the context of the given SearchCriteria (the SearchContext is contained within the SearchCriteria).

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/12/96

Definition at line 563 of file filtrmgr.cpp.

00564 {
00565     return NULL;
00566 }

Filter * FilterManager::FindFilterFromID const UINT32  FilterID  )  const
 

Provides the Filter given its ID.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/12/96

Definition at line 284 of file filtrmgr.cpp.

00285 {
00286     Filter* pFilter = Filter::GetFirst();
00287     while (pFilter != NULL)
00288     {
00289         if (pFilter->FilterID == FilterID)
00290         {
00291             break;
00292         }
00293         pFilter = Filter::GetNext(pFilter);
00294     }
00295     return pFilter;
00296 }

FormatEntry * FilterManager::FindFormatEntryFromID const FileFormatID  FormatID  )  const [protected]
 

Internally does the actual finding by ID See Also: FindFormatFromID.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/12/96

Definition at line 506 of file filtrmgr.cpp.

00507 {
00508     ERROR2IF(FormatID == 0 || FormatID > GetLastFormatID(), NULL, 
00509                 "Invalid FileFormatID");
00510 
00511     return GetFormats()[FormatID - 1];
00512 }

FormatEntry * FilterManager::FindFormatEntryFromName const StringBase FormatName  )  const [protected]
 

Finds the one & only FileFormat with the given FormatName Used by Xtra's mainly.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/12/96
Parameters:
FormatName,: The name of a FileFormat given in the FileFormat's constructor [INPUTS] which has subsequently been Added to this FilterManager.
Returns:
A pointer to the FileFormat with the name given or NULL if none was found

Definition at line 528 of file filtrmgr.cpp.

00529 {
00530     for (UINT32 index = 0; index < GetLastFormatID(); ++index)
00531     {
00532         FormatEntry* pFormatEntry = GetFormats()[index];
00533         if (pFormatEntry != NULL)
00534         {
00535             FileFormat* pFormat = pFormatEntry->GetFormat();
00536             if (pFormat->GetName() == FormatName)
00537             {
00538                 return pFormatEntry;
00539             }
00540         }
00541         else
00542         {
00543             // we'll ignore this one
00544         }
00545     }
00546 
00547     return NULL;
00548 }

FileFormat * FilterManager::FindFormatFromID const FileFormatID  FormatID  )  const
 

Provides the FileFormat given its ID See Also: FindFormatEntryFromID.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/12/96

Definition at line 478 of file filtrmgr.cpp.

00479 {
00480     FileFormat* pReturnedFormat;
00481 
00482     FormatEntry* pEntry = FindFormatEntryFromID(FormatID);
00483     if (pEntry != NULL)
00484     {
00485         pReturnedFormat = pEntry->GetFormat();
00486     }
00487     else
00488     {
00489         pReturnedFormat = NULL;
00490     }
00491 
00492     return pReturnedFormat;
00493 }

FileFormat * FilterManager::FindFormatFromName const StringBase FormatName  )  const
 

Finds the one & only FileFormat with the given FormatName Used by Xtra's mainly.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/12/96
Parameters:
FormatName,: The name of a FileFormat given in the FileFormat's constructor [INPUTS] which has subsequently been Added to this FilterManager.
Returns:
A pointer to the FileFormat with the name given or NULL if none was found

Definition at line 457 of file filtrmgr.cpp.

00458 {
00459     FormatEntry* pEntry = FindFormatEntryFromName(FormatName);
00460     if (pEntry != NULL)
00461     {
00462         return pEntry->GetFormat();
00463     }
00464     return NULL;
00465 }

FileFormatID FilterManager::FindFormatIDFromName const StringBase FormatName  )  const
 

Relief function returning the FileFormat ID instead of the FileFormat per se See Also: Other overloaded function.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/12/96

Definition at line 427 of file filtrmgr.cpp.

00428 {
00429     FileFormatID FoundID = 0;
00430     FormatEntry* pFoundEntry = FindFormatEntryFromName(FormatName);
00431 
00432     if (pFoundEntry != NULL)
00433     {
00434         FoundID = pFoundEntry->GetID();
00435     }
00436     else
00437     {
00438         FoundID = 0;
00439     }
00440 
00441     return FoundID;
00442 }

List& FilterManager::GetFilters  )  const [protected]
 

const FormatArray& FilterManager::GetFormats  )  const [inline, protected]
 

Definition at line 195 of file filtrmgr.h.

00195 {   return m_Formats;   }

FormatArray & FilterManager::GetFormats  )  [protected]
 

Support function providing access to the FileFormats.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/12/96
Returns:
A reference to the FormatArray

Definition at line 311 of file filtrmgr.cpp.

00312 {
00313     return m_Formats;
00314 }

FileFormatID FilterManager::GetLastFormatID  )  const [inline, protected]
 

Definition at line 198 of file filtrmgr.h.

00198 {   return m_NextFormatID - 1;  }

UINT32 FilterManager::GetNewFilterID  )  [protected]
 

Support function providing an unique ID for each newly registered Filter.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/12/96
Returns:
A FilterID unique to this FilterManager for each call to the function

Definition at line 149 of file filtrmgr.cpp.

00150 {
00151     ERROR3IF(!m_NextFilterID, "Creating duff FilterID");
00152 
00153     return m_NextFilterID++;
00154 }

FileFormatID FilterManager::GetNewFormatID  )  [protected]
 

Support function providing an unique ID for each newly registered FileFormat.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/12/96
Returns:
A FileFormatID unique to this FilterManager for each call to the function

Definition at line 326 of file filtrmgr.cpp.

00327 {
00328     return m_NextFormatID++;
00329 }

BOOL FilterManager::Init void   ) 
 

Initializes the filter manager Currently just does some tests.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/12/96
Returns:
TRUE if initialised ok, FALSE if not.

Definition at line 196 of file filtrmgr.cpp.

00197 {
00198 #if defined(DEBUG_THIS)
00199 
00200     String_256 MyFormatName = _T("myFormat");
00201     String_256 MyFormatDesc = _T("Format (*.frm)");
00202     XtraFileFormat* pFormat = new XtraFileFormat(MyFormatName, MyFormatDesc);
00203     FileFormatID myFormatID = RegisterFileFormat((FileFormat*)pFormat, FilterManager::DM_DELETE_WHEN_DONE);
00204     MyFormatDesc = _T(".fm1");
00205     pFormat->AddExtension(MyFormatDesc);
00206     MyFormatDesc = _T(".fm2");
00207     pFormat->AddExtension(MyFormatDesc);
00208     MyFormatDesc = _T(".fm3");
00209     pFormat->AddExtension(MyFormatDesc);
00210     MyFormatDesc = _T(".fm2");
00211     pFormat->AddExtension(MyFormatDesc);
00212     MyFormatDesc = _T(".one long mother of an extension well beyond thirty-two");
00213     pFormat->AddExtension(MyFormatDesc);
00214 
00215 #endif
00216 
00217     // All ok
00218     return TRUE;
00219 }

FilterList * FilterManager::ListMatchingFilters FilterSearchCriteria &  Criteria  ) 
 

Creates a list of filters matching the given FilterSearchCriteria.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/12/96
Returns:
A list of filters matching the given FilterSearchCriteria. The list IsEmpty if no filters matched NULL if failed Notes: The returned list should be deleted when finished with.

Definition at line 582 of file filtrmgr.cpp.

00583 {
00584     FilterList* pList = new FilterList;
00585 
00586     return pList;
00587 }

FileFormatID FilterManager::RegisterFileFormat FileFormat *const   pFormat,
const DESTRUCTION_METHOD  DestructMethod
 

Registers the given FileFormat with this FilterManager.

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
10/12/96
Parameters:
pFormat,: A pointer to the FileFormat to register [INPUTS]
Returns:
A FileFormatID by which the given FileFormat can be uniquely identified and quickly retrieved.

Definition at line 345 of file filtrmgr.cpp.

00347 {
00348     ERROR2IF(pFormat == NULL, 0, "NULL Args");
00349 
00350     // Look for one we might already have
00351     FileFormatID IDToReturn = FindFormatIDFromName(pFormat->GetName());
00352     if (IDToReturn == 0)
00353     {
00354         // Have to add a new one
00355         IDToReturn = GetNewFormatID();
00356         FormatEntry* pFormatEntry = new FormatEntry(IDToReturn, pFormat, DestructMethod);
00357         if (pFormatEntry == NULL)
00358         {
00359             goto AddFormatError;
00360         }
00361 
00362         if (!GetFormats().Add(pFormatEntry))
00363         {
00364             delete pFormatEntry;
00365             goto AddFormatError;
00366         }
00367     }
00368     else
00369     {
00370         // Use the duplicate then
00371     }
00372     
00373     return IDToReturn;
00374 
00375 AddFormatError:
00376 
00377     return 0;
00378 }

UINT32 FilterManager::RegisterFilter Filter *const   pFilter,
const DESTRUCTION_METHOD  DestructMethod
 

Permits the filter to be used by the FilterManager. For an import filter to be present on the Import dialog the filter should associate itself with the requisite FileFormats via AssociateFilterWithFormat().

Author:
Colin_Barfoot (Xara Group Ltd) <camelotdev@xara.com>
Date:
15/12/94
Parameters:
pFilter,: pointer to the filter to register [INPUTS]
Returns:
FilterID that uniquely identifies the given filter within the scope of this FilterManager and allows for fast retrieval of the filter.

Definition at line 173 of file filtrmgr.cpp.

00175 {
00176     //DestructMethod; // This line just read "DestructMethod;" - what's that meant to do then?
00177     UINT32 newID = Filter::RegisterFilter(pFilter);
00178 
00179     return newID;
00180 }


Member Data Documentation

const UINT32 FilterManager::FILTERID_START [protected]
 

Definition at line 191 of file filtrmgr.h.

const FileFormatID FilterManager::FORMATID_START [protected]
 

Definition at line 196 of file filtrmgr.h.

FormatArray FilterManager::m_Formats [private]
 

Definition at line 208 of file filtrmgr.h.

UINT32 FilterManager::m_NextFilterID [private]
 

Definition at line 206 of file filtrmgr.h.

FileFormatID FilterManager::m_NextFormatID [private]
 

Definition at line 209 of file filtrmgr.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:54:19 2007 for Camelot by  doxygen 1.4.4