Module Class Reference

The Module type reflects the latest Module specification. Do NOT subclass from Module, but use the latest Module revision (e.g. Module_v42). The Module type should only be used by the Kernel and OIL layers, never by Modules themselves. More...

#include <module.h>

Inheritance diagram for Module:

Module_v1 List of all members.

Static Public Member Functions

static BOOL InitModules ()
 Called at the end of initialisation (as it may well need all other initialisations to have been done) to add Tools and Modules to the Kernel's knowledgebase.
static void DeinitModules ()
 Deletes all allocated modules (and hence tools), then asks OIL to tidy up. Safe to call more than once.
static ModuleListItemFind (UINT32 ModuleID)
 Anyone can ask about a module's presence by its ID.
static ModuleListItemDeclare (Module *, OILModule *)
 Called by OIL code to declare new modules.

Private Member Functions

 CC_DECLARE_MEMDUMP (Module)

Static Private Member Functions

static BOOL CreateTools ()
 Scan all modules known to the kernel, and try to create an instance of each tool they contain, and add this tool to the kernel's list.

Static Private Attributes

static ModuleListModules = NULL

Detailed Description

The Module type reflects the latest Module specification. Do NOT subclass from Module, but use the latest Module revision (e.g. Module_v42). The Module type should only be used by the Kernel and OIL layers, never by Modules themselves.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/6/93
The modules known to the kernel are contained in the Modules object, which is pointer to an instance of the class ModuleList. This class should be used to declare/search for modules, etc.

See also:
Module_v1; ModuleList; ModuleListItem; Tool

Definition at line 258 of file module.h.


Member Function Documentation

Module::CC_DECLARE_MEMDUMP Module   )  [private]
 

BOOL Module::CreateTools  )  [static, private]
 

Scan all modules known to the kernel, and try to create an instance of each tool they contain, and add this tool to the kernel's list.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
1/7/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE => Tools created OK.

Errors: -

See also:
-

Definition at line 332 of file module.cpp.

00333 {
00334     // Scan the list of modules
00335     ModuleListItem *Item = (ModuleListItem *) Modules->GetHead();
00336     
00337     while (Item != NULL)
00338     {
00339         // Interrogate module
00340         ModInfo Info;
00341         Item->m_pModule->Describe(&Info);
00342 
00343         // Try to create an instance of each tool in this module
00344         for (unsigned tool = 1; tool <= Info.NumTools; tool++)
00345         {
00346             Tool *NewTool = (Tool *) Item->m_pModule->CreateTool(tool);
00347             
00348             if (NewTool != NULL)
00349             {
00350                 // Tool was created - add it to the list
00351                 Tool::Declare(NewTool, Info.ID);
00352                 
00353             }
00354         }
00355 
00356         // Try the next module in the list.     
00357         Item = (ModuleListItem *) Modules->GetNext(Item);
00358     }
00359 //  Tool* NewTool ;
00360 //  NewTool = (Tool*)new ZoomTool; if ( NewTool ) Tool::Declare(NewTool,1);
00361 //  NewTool = (Tool*)new PushTool; if ( NewTool ) Tool::Declare(NewTool,Info.ID);
00362 
00363     // No error codes yet
00364     return TRUE;
00365 }

ModuleListItem * Module::Declare Module NewModule,
OILModule pOILModule
[static]
 

Called by OIL code to declare new modules.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/6/93
Parameters:
NewModule - pointer to a new Tool and its ID [INPUTS] pOILModule - pointer to the OILModule object to be associated with this module.
None [OUTPUTS]
Returns:
Pointer to new module list item if module.

Errors: Will return NULL if invalid ID or same module ID used twice, and NewModule will have been deleted.

Definition at line 227 of file module.cpp.

00228 {
00229     // Try to add the module to the kernel's list.
00230     ModuleListItem *NewItem = Modules->Add(NewModule, pOILModule);
00231     
00232     if (NewItem == NULL)
00233     {
00234         // Either out of memory or Module has invalid ID - print error message and 
00235         // destroy module.
00236         #ifdef _DEBUG
00237         ModInfo Info;
00238         NewModule->Describe(&Info);
00239         TRACE( _T("Module %u is invalid or has no memory to initialise with.\n"), Info.ID );
00240         #endif
00241         
00242         delete NewModule;
00243     }
00244     
00245     return NewItem;
00246 }

void Module::DeinitModules  )  [static]
 

Deletes all allocated modules (and hence tools), then asks OIL to tidy up. Safe to call more than once.

Author:
Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
Date:
21/6/93
Parameters:
None [INPUTS]
None [OUTPUTS]
Returns:
None
Do NOT try to use any tools or modules after calling this.

Returns:
Errors: None

Definition at line 300 of file module.cpp.

00301 {
00302     if (Modules != NULL)
00303     {
00304         // Delete the list itself.
00305         delete Modules;
00306         Modules = NULL;
00307 
00308         // Perform any clean-up required by the OIL layer.
00309 PORTNOTE("other","Removed OILModule usage")
00310 #ifndef EXCLUDE_FROM_XARALX
00311         OILModule::Deinit();
00312 #endif
00313     }
00314 }

ModuleListItem * Module::Find UINT32  ModuleID  )  [static]
 

Anyone can ask about a module's presence by its ID.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/6/93
Parameters:
Module ID [INPUTS]
None [OUTPUTS]
Returns:
Pointer to list item of the required module, or NULL if not found.

Errors: None.

Definition at line 263 of file module.cpp.

00264 {
00265     // Simple search of list for ID
00266     
00267     ModuleListItem *Item = (ModuleListItem *) Modules->GetHead();
00268     
00269     while (Item != NULL)
00270     {
00271         if (Item->m_ModInfo.ID == ModuleID)
00272             // Found ID - return pointer to this list item.
00273             return Item;
00274         
00275         Item = (ModuleListItem *) Modules->GetNext(Item);
00276     }
00277     
00278     // Not found
00279     return NULL;
00280 }

BOOL Module::InitModules  )  [static]
 

Called at the end of initialisation (as it may well need all other initialisations to have been done) to add Tools and Modules to the Kernel's knowledgebase.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/6/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
TRUE if OK, FALSE for catastrophic failure

Errors: None Scope: Public

Definition at line 146 of file module.cpp.

00147 {
00148     // Initialise the list of Modules.
00149     Modules = new ModuleList;
00150     if (!Modules)
00151         return FALSE;
00152         
00153     if (!OILModule::Init())                     // get OIL's list of modules. This works
00154         return FALSE;                           // by calling back to DescribeModule.
00155                                                 // NB. OILModule::Init does it own error
00156     BOOL Finished;                              // reporting
00157     
00158     do
00159     {
00160         // All the modules have been 'new'ed now. We can now ask them to initialise themselves.
00161         // If they don't want to, they get 'delete'ed.
00162 
00163         ModuleListItem *Item = (ModuleListItem *) Modules->GetHead();
00164         
00165         Finished = TRUE;
00166         
00167         while (Item != NULL)
00168         {
00169             Module *Module = Item->m_pModule;
00170             
00171             // If this module exists and has not been initialised yet, then try to
00172             // initialise it.  If it initialises ok, set the item's flag, and force
00173             // another scan of the remaining modules in case one of them depends on
00174             // this module being present.
00175             if ((Module != NULL) && (!Item->m_Initialised) && (Module->Init()))
00176             {
00177                 Item->m_Initialised = TRUE; // Tool initialised ok.
00178                 Finished = FALSE;           // At least one more loop to try
00179             }
00180 
00181             // Try the next module
00182             Item = (ModuleListItem *) Modules->GetNext(Item);
00183         }
00184         
00185     } while (!Finished);
00186 
00187     // Delete any un-initialised modules
00188     ModuleListItem *Item = (ModuleListItem *) Modules->GetHead();
00189 
00190     while (Item != NULL)
00191     {
00192         if ((Item->m_pModule != NULL) && (!Item->m_Initialised))
00193         {
00194             delete Item->m_pModule;
00195             Item->m_pModule = NULL;
00196         }
00197 
00198         // Try the next module
00199         Item = (ModuleListItem *) Modules->GetNext(Item);
00200     }
00201 
00202     // Scan all the modules and create (but do not initialise) any tools they provide.
00203     if (!Tool::InitToolList() || !CreateTools())
00204         return FALSE;
00205 
00206     return TRUE;
00207 }


Member Data Documentation

ModuleList * Module::Modules = NULL [static, private]
 

Definition at line 270 of file module.h.


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