1 /* === S I N F G =========================================================== */
5 ** $Id: module.h,v 1.1.1.1 2005/01/04 01:23:14 darco Exp $
8 ** Copyright (c) 2002 Robert B. Quattlebaum Jr.
10 ** This software and associated documentation
11 ** are CONFIDENTIAL and PROPRIETARY property of
12 ** the above-mentioned copyright holder.
14 ** You may not copy, print, publish, or in any
15 ** other way distribute this software without
16 ** a prior written agreement with
17 ** the copyright holder.
20 /* ========================================================================= */
22 /* === S T A R T =========================================================== */
24 #ifndef __SINFG_MODULE_H
25 #define __SINFG_MODULE_H
27 /* === H E A D E R S ======================================================= */
41 /* === M A C R O S ========================================================= */
43 //! Marks the start of a module description
44 #define MODULE_DESC_BEGIN(x) struct x##_modclass : public sinfg::Module { x##_modclass(sinfg::ProgressCallback *callback=NULL);
46 //! Sets the localized name of the module
47 #define MODULE_NAME(x) virtual const char * Name() { return x; }
49 //! Sets a localized description of the module
50 #define MODULE_DESCRIPTION(x) virtual const char * Desc() { return x; }
52 //! Sets the name of the module's author
53 #define MODULE_AUTHOR(x) virtual const char * Author() { return x; }
55 //! Sets the version string for the module
56 #define MODULE_VERSION(x) virtual const char * Version() { return x; }
58 //! Sets the copyright string for the module
59 #define MODULE_COPYRIGHT(x) virtual const char * Copyright() { return x; }
61 //! Describes the module's construction function
62 #define MODULE_CONSTRUCTOR(x) bool constructor_(sinfg::ProgressCallback *cb) { return x(cb); }
64 //! Describes the module's destruction function
65 #define MODULE_DESTRUCTOR(x) virtual void destructor_() { return x(); }
67 //! Marks the end of a module description
68 #define MODULE_DESC_END };
72 //! Marks the start of a module's inventory
73 #define MODULE_INVENTORY_BEGIN(x) extern "C" { \
74 sinfg::Module* _##x##_LTX_new_instance(sinfg::ProgressCallback *cb) \
75 { if(SINFG_CHECK_VERSION()){x##_modclass *mod=new x##_modclass(cb); mod->constructor_(cb); return mod; }\
76 if(cb)cb->error(#x": Unable to load module due to version mismatch."); return NULL; } \
77 }; x##_modclass::x##_modclass(sinfg::ProgressCallback *cb) {
79 //! Marks the start of a module's inventory
80 #define MODULE_INVENTORY_BEGIN(x) extern "C" { \
81 sinfg::Module* x##_LTX_new_instance(sinfg::ProgressCallback *cb) \
82 { if(SINFG_CHECK_VERSION()){x##_modclass *mod=new x##_modclass(cb); mod->constructor_(cb); return mod; }\
83 if(cb)cb->error(#x": Unable to load module due to version mismatch."); return NULL; } \
84 }; x##_modclass::x##_modclass(sinfg::ProgressCallback *cb) {
87 //! Marks the start of the layers in the module's inventory
88 #define BEGIN_LAYERS {
90 //! DEPRECATED - use @INCLUDE_LAYER()
91 //#define LAYER(x) sinfg::Layer::book()[sinfg::String(x::name__)]=x::create;
92 #define LAYER(class) sinfg::Layer::register_in_book(sinfg::Layer::BookEntry(class::create,class::name__,class::local_name__,class::category__,class::cvs_id__,class::version__));
93 #define LAYER_ALIAS(class,alias) sinfg::Layer::register_in_book(sinfg::Layer::BookEntry(class::create,alias,alias,_("Do Not Use"),class::cvs_id__,class::version__));
95 //! Marks the end of the layers in the module's inventory
98 //! Marks the start of the targets in the module's inventory
99 #define BEGIN_TARGETS {
101 #define TARGET(x) sinfg::Target::book()[sinfg::String(x::name__)]=std::pair<sinfg::Target::Factory,sinfg::String>(x::create,sinfg::String(x::ext__));sinfg::Target::ext_book()[sinfg::String(x::ext__)]=x::name__;
103 #define TARGET_EXT(x,y) sinfg::Target::ext_book()[sinfg::String(y)]=x::name__;
105 //! Marks the end of the targets in the module's inventory
106 #define END_TARGETS }
108 //! Marks the start of the importers in the module's inventory
109 #define BEGIN_IMPORTERS {
111 #define IMPORTER(x) sinfg::Importer::book()[sinfg::String(x::ext__)]=x::create;
113 #define IMPORTER_EXT(x,y) sinfg::Importer::book()[sinfg::String(y)]=x::create;
115 //! Marks the end of the importers in the module's inventory
116 #define END_IMPORTERS }
118 //! Marks the end of a module's inventory
119 #define MODULE_INVENTORY_END }
121 /* === T Y P E D E F S ===================================================== */
123 /* === C L A S S E S & S T R U C T S ======================================= */
127 class ProgressCallback;
132 class Module : public etl::shared_object
135 bool constructor_(sinfg::ProgressCallback *cb) { return true; }
136 virtual void destructor_() { }
138 typedef etl::handle<Module> Handle;
139 typedef etl::loose_handle<Module> LooseHandle;
140 typedef etl::handle<const Module> ConstHandle;
143 typedef Module*(*constructor_type)(ProgressCallback *);
144 typedef std::map<String, Handle > Book;
150 static bool subsys_init(const String &prefix);
151 static bool subsys_stop();
152 static bool register_default_modules();
154 static void Register(Handle mod);
155 static bool Register(const String &module_name, ProgressCallback *cb=NULL);
156 static inline void Register(Module *mod) { Register(Handle(mod)); }
158 virtual const char * Name() { return " "; }
159 virtual const char * Desc() { return " "; }
160 virtual const char * Author() { return " "; }
161 virtual const char * Version() { return " "; }
162 virtual const char * Copyright() { return SINFG_COPYRIGHT; }
164 virtual ~Module() { destructor_(); }
167 }; // END of namespace sinfg
169 /* === E N D =============================================================== */