Changeset 113

Show
Ignore:
Timestamp:
08/11/10 19:17:21 (18 months ago)
Author:
Carsten
Message:

Our libraries *declare* (module-)global pointers to implementations of their interfaces,
i.e. pointers that are available for convenient access from the entire exe or dll.

Some libraries also (erroneously) provided *definitions* for these pointer instances,
namely the ConsoleInterpreter, the MaterialManager and the SoundShaderManager.

These definitions have been removed (and moved into the application code instead).

This change makes all our libraries consistent, and linking them to an application or dll easier.

Location:
cafu/branches/cafu_to_wx
Files:
2 removed
17 modified

Legend:

Unmodified
Added
Removed
  • cafu/branches/cafu_to_wx/CaBSP/CaBSP.cpp

    r51 r113  
    4646 
    4747#include "ConsoleCommands/Console.hpp" 
     48#include "ConsoleCommands/ConsoleInterpreter.hpp" 
    4849#include "ConsoleCommands/ConsoleStdout.hpp" 
    4950#include "FileSys/FileManImpl.hpp" 
     
    7475static cf::ClipSys::CollModelManImplT CCM; 
    7576cf::ClipSys::CollModelManI* cf::ClipSys::CollModelMan=&CCM; 
     77 
     78ConsoleInterpreterI* ConsoleInterpreter=NULL; 
     79MaterialManagerI*    MaterialManager   =NULL; 
    7680 
    7781 
  • cafu/branches/cafu_to_wx/CaLight/CaLight.cpp

    r51 r113  
    6868#include "Bitmap/Bitmap.hpp" 
    6969#include "ConsoleCommands/Console.hpp" 
     70#include "ConsoleCommands/ConsoleInterpreter.hpp" 
    7071#include "ConsoleCommands/ConsoleStdout.hpp" 
    7172#include "FileSys/FileManImpl.hpp" 
     
    9596static cf::ClipSys::CollModelManImplT CCM; 
    9697cf::ClipSys::CollModelManI* cf::ClipSys::CollModelMan=&CCM; 
     98 
     99ConsoleInterpreterI* ConsoleInterpreter=NULL; 
     100MaterialManagerI*    MaterialManager   =NULL; 
    97101 
    98102 
  • cafu/branches/cafu_to_wx/CaPVS/CaPVS.cpp

    r51 r113  
    5353#include "CaPVSWorld.hpp" 
    5454#include "ConsoleCommands/Console.hpp" 
     55#include "ConsoleCommands/ConsoleInterpreter.hpp" 
    5556#include "ConsoleCommands/ConsoleStdout.hpp" 
    5657#include "FileSys/FileManImpl.hpp" 
     
    6869static cf::ClipSys::CollModelManImplT CCM; 
    6970cf::ClipSys::CollModelManI* cf::ClipSys::CollModelMan=&CCM; 
     71 
     72ConsoleInterpreterI* ConsoleInterpreter=NULL; 
     73MaterialManagerI*    MaterialManager   =NULL; 
    7074 
    7175 
  • cafu/branches/cafu_to_wx/CaSHL/CaSHL.cpp

    r51 r113  
    6767#include "Templates/Array.hpp" 
    6868#include "ConsoleCommands/Console.hpp" 
     69#include "ConsoleCommands/ConsoleInterpreter.hpp" 
    6970#include "ConsoleCommands/ConsoleStdout.hpp" 
    7071#include "FileSys/FileManImpl.hpp" 
     
    9798static cf::ClipSys::CollModelManImplT CCM; 
    9899cf::ClipSys::CollModelManI* cf::ClipSys::CollModelMan=&CCM; 
     100 
     101ConsoleInterpreterI* ConsoleInterpreter=NULL; 
     102MaterialManagerI*    MaterialManager   =NULL; 
    99103 
    100104 
  • cafu/branches/cafu_to_wx/CaTools/CaSanity.cpp

    r51 r113  
    5252#include "Templates/Array.hpp" 
    5353#include "ConsoleCommands/Console.hpp" 
     54#include "ConsoleCommands/ConsoleInterpreter.hpp" 
    5455#include "ConsoleCommands/ConsoleStdout.hpp" 
    5556#include "FileSys/FileManImpl.hpp" 
     
    7778static cf::ClipSys::CollModelManImplT CCM; 
    7879cf::ClipSys::CollModelManI* cf::ClipSys::CollModelMan=&CCM; 
     80 
     81ConsoleInterpreterI* ConsoleInterpreter=NULL; 
     82MaterialManagerI*    MaterialManager   =NULL; 
    7983 
    8084 
  • cafu/branches/cafu_to_wx/CaTools/MaterialViewer.cpp

    r51 r113  
    4646 
    4747#include "ConsoleCommands/Console.hpp" 
     48#include "ConsoleCommands/ConsoleInterpreter.hpp" 
    4849#include "ConsoleCommands/ConsoleStdout.hpp" 
    4950#include "FileSys/FileManImpl.hpp" 
     
    6869static cf::FileSys::FileManImplT FileManImpl; 
    6970cf::FileSys::FileManI* cf::FileSys::FileMan=&FileManImpl; 
     71 
     72ConsoleInterpreterI* ConsoleInterpreter=NULL; 
     73MaterialManagerI*    MaterialManager   =NULL; 
    7074 
    7175 
  • cafu/branches/cafu_to_wx/CaTools/ModelViewer.cpp

    r51 r113  
    2727 
    2828#include "ConsoleCommands/Console.hpp" 
     29#include "ConsoleCommands/ConsoleInterpreter.hpp" 
    2930#include "ConsoleCommands/ConsoleStdout.hpp" 
    3031#include "FileSys/FileManImpl.hpp" 
     
    6061static cf::FileSys::FileManImplT FileManImpl; 
    6162cf::FileSys::FileManI* cf::FileSys::FileMan=&FileManImpl; 
     63 
     64ConsoleInterpreterI* ConsoleInterpreter=NULL; 
     65MaterialManagerI*    MaterialManager   =NULL; 
    6266 
    6367 
  • cafu/branches/cafu_to_wx/CaTools/TerrainViewer.cpp

    r51 r113  
    7070cf::FileSys::FileManI* cf::FileSys::FileMan=&FileManImpl; 
    7171 
     72MaterialManagerI* MaterialManager=NULL; 
     73 
    7274 
    7375#define DEG2RAD(x) ((3.1415927f / 180.0f) * (x)) 
  • cafu/branches/cafu_to_wx/CaWE/AppCaWE.cpp

    r112 r113  
    7272cf::ClipSys::CollModelManI* cf::ClipSys::CollModelMan=&CCM; 
    7373 
     74ConsoleInterpreterI* ConsoleInterpreter=NULL; 
     75MaterialManagerI*    MaterialManager   =NULL; 
    7476cf::GuiSys::GuiManI* cf::GuiSys::GuiMan=NULL; 
    7577 
  • cafu/branches/cafu_to_wx/Games/DeathMatch/Code/DeathMatch.cpp

    r51 r113  
    9494SingleOpenGLWindowT*   SingleOpenGLWindow=NULL; 
    9595cf::GuiSys::GuiManI*   cf::GuiSys::GuiMan=NULL;     // Define the global GuiMan pointer instance -- see GuiMan.hpp for more details. 
     96MaterialManagerI*      MaterialManager   =NULL; 
    9697cf::ConsoleI*          Console=NULL; 
    9798ConsoleInterpreterI*   ConsoleInterpreter=NULL; 
     
    99100cf::ClipSys::CollModelManI* cf::ClipSys::CollModelMan=NULL; 
    100101SoundSysI*             SoundSystem=NULL; 
     102SoundShaderManagerI*   SoundShaderManager=NULL; 
    101103#endif 
    102104 
  • cafu/branches/cafu_to_wx/Games/VSWM/Code/VSWM.cpp

    r51 r113  
    251251SingleOpenGLWindowT*   SingleOpenGLWindow=NULL; 
    252252cf::GuiSys::GuiManI*   cf::GuiSys::GuiMan=NULL;     // Define the global GuiMan pointer instance -- see GuiMan.hpp for more details. 
     253MaterialManagerI*      MaterialManager   =NULL; 
    253254cf::ConsoleI*          Console=NULL; 
    254255ConsoleInterpreterI*   ConsoleInterpreter=NULL; 
  • cafu/branches/cafu_to_wx/Libs/ConsoleCommands/Console.hpp

    r36 r113  
    6868 
    6969 
    70 /// Each module (the exe and each dll) needs a pointer to the application-wide global ConsoleI implementation. 
    71 /// For the exe, which hosts the implementation of the ConsoleI, the pointer is defined and set by linking in e.g. the ConsoleStdout.cpp file. 
    72 /// Each dll that uses the console has to provide a definition by itself, and initialize it to point to the exe's console instance. 
     70/// A global pointer to an implementation of the ConsoleI interface. 
     71/// 
     72/// Each module (exe or dll) that uses this pointer must somewhere provide exactly one definition for it (none is provided by the Console library). 
     73/// That is, typically the main.cpp or similar file of each exe and dll must contain a line like 
     74///     cf::ConsoleI* Console=NULL; 
     75/// or else the module will not link successfully due to an undefined symbol. 
     76/// 
     77/// Exe files will then want to reset this pointer to an instance of e.g. a ConsoleStdoutT during their initialization 
     78/// e.g. by code like:   Console=new cf::ConsoleStdoutT; 
     79/// 
     80/// Dlls typically get one of their init functions called immediately after they have been loaded. 
     81/// By doing so, the exe passes a pointer to its above instance to the dll, which in turn copies it to its Console variable. 
    7382extern cf::ConsoleI* Console; 
    7483 
  • cafu/branches/cafu_to_wx/Libs/ConsoleCommands/ConsoleInterpreter.hpp

    r36 r113  
    105105 
    106106 
    107 /// Each module (the exe and each dll) needs a pointer to the application-wide global ConsoleInterpreterI implementation. 
    108 /// For the exe, which hosts the implementation of the ConsoleInterpreter, the pointer is defined and set by linking in the ConsoleInterpreterImpl.cpp file. 
    109 /// Each dll that uses convars has to provide a definition by itself, and initialize it to point to the exe's ConsoleInterpreter instance. 
     107/// A global pointer to an implementation of the ConsoleInterpreterI interface. 
     108/// 
     109/// Each module (exe or dll) that uses this pointer must somewhere provide exactly one definition for it (none is provided by the ConsoleInterpreter library). 
     110/// That is, typically the main.cpp or similar file of each exe and dll must contain a line like 
     111///     ConsoleInterpreterI* ConsoleInterpreter=NULL; 
     112/// or else the module will not link successfully due to an undefined symbol. 
     113/// 
     114/// Exe files will then want to reset this pointer to an instance of a ConsoleInterpreterImplT during their initialization 
     115/// e.g. by code like:   ConsoleInterpreter=new ConsoleInterpreterImplT; 
     116/// Note that the ConsoleInterpreterImplT ctor may require that other interfaces (e.g. the Console) have been inited first. 
     117/// 
     118/// Dlls typically get one of their init functions called immediately after they have been loaded. 
     119/// By doing so, the exe passes a pointer to its above instance to the dll, which in turn copies it to its ConsoleInterpreter variable. 
    110120extern ConsoleInterpreterI* ConsoleInterpreter; 
    111121 
  • cafu/branches/cafu_to_wx/Libs/ConsoleCommands/ConsoleInterpreterImpl.cpp

    r51 r113  
    4242#include <sstream> 
    4343#include <cassert> 
    44  
    45  
    46 ConsoleInterpreterI* ConsoleInterpreter=NULL; 
    4744 
    4845 
  • cafu/branches/cafu_to_wx/Libs/MaterialSystem/MaterialManager.hpp

    r36 r113  
    8080 
    8181 
    82 /// A global pointer to the material manager that currently defaults to &MaterialManagerI::Get(). 
    83 /// This pointer should be used by all code (e.g. models) that potentially is included in a DLL and should share the common Material Manager 
    84 /// of another module (e.g. the main executable). As the DLL will during its initialization reset this pointer to the one provided by the 
    85 /// executable, this goal is thus automatically achieved. 
     82/// A global pointer to an implementation of the MaterialManagerI interface. 
     83/// 
     84/// Each module (exe or dll) that uses this pointer must somewhere provide exactly one definition for it (none is provided by the MatSys). 
     85/// That is, typically the main.cpp or similar file of each exe and dll must contain a line like 
     86///     MaterialManagerI* MaterialManager=NULL; 
     87/// or else the module will not link successfully due to an undefined symbol. 
     88/// 
     89/// Exe files will then want to reset this pointer to an instance of a MaterialManagerImplT during their initialization 
     90/// e.g. by code like:   MaterialManager=new MaterialManagerImplT; 
     91/// Note that the MaterialManagerImplT ctor may require that other interfaces (e.g. the Console) have been inited first. 
     92/// 
     93/// Dlls typically get one of their init functions called immediately after they have been loaded. 
     94/// By doing so, the exe passes a pointer to its above instance to the dll, which in turn copies it to its MaterialManager variable. 
    8695extern MaterialManagerI* MaterialManager; 
    8796 
  • cafu/branches/cafu_to_wx/Libs/SConscript

    r80 r113  
    5959env.StaticLibrary( 
    6060    target="MatSys", 
    61     source=Split("""MaterialSystem/Expression.cpp MaterialSystem/MapComposition.cpp MaterialSystem/Material.cpp MaterialSystem/MaterialManager.cpp 
     61    source=Split("""MaterialSystem/Expression.cpp MaterialSystem/MapComposition.cpp MaterialSystem/Material.cpp 
    6262                    MaterialSystem/MaterialManagerImpl.cpp MaterialSystem/Renderer.cpp MaterialSystem/TextureMap.cpp""")) 
    6363 
     
    6666env.StaticLibrary( 
    6767    target="SoundSys", 
    68     source=Split("""SoundSystem/SoundShaderManager.cpp SoundSystem/SoundShaderManagerImpl.cpp SoundSystem/SoundShader.cpp""")) 
     68    source=Split("""SoundSystem/SoundShaderManagerImpl.cpp SoundSystem/SoundShader.cpp""")) 
    6969 
    7070 
  • cafu/branches/cafu_to_wx/Libs/SoundSystem/SoundShaderManager.hpp

    r36 r113  
    7070}; 
    7171 
    72 /// A global pointer to the sound shader manager. 
    73 /// This pointer should be used by all code that potentially is included in a DLL and should share the common sound shader manager 
    74 /// of another module (e.g. the main executable). As the DLL will during its initialization reset this pointer to the one provided by the 
    75 /// executable, this goal is thus automatically achieved. 
     72 
     73/// A global pointer to an implementation of the SoundShaderManagerI interface. 
     74/// 
     75/// Each module (exe or dll) that uses this pointer must somewhere provide exactly one definition for it (none is provided by the SoundSys). 
     76/// That is, typically the main.cpp or similar file of each exe and dll must contain a line like 
     77///     SoundShaderManagerI* SoundShaderManager=NULL; 
     78/// or else the module will not link successfully due to an undefined symbol. 
     79/// 
     80/// Exe files will then want to reset this pointer to an instance of a SoundShaderManagerImplT during their initialization 
     81/// e.g. by code like:   SoundShaderManager=new SoundShaderManagerImplT; 
     82/// Note that the SoundShaderManagerImplT ctor may require that other interfaces (e.g. the Console) have been inited first. 
     83/// 
     84/// Dlls typically get one of their init functions called immediately after they have been loaded. 
     85/// By doing so, the exe passes a pointer to its above instance to the dll, which in turn copies it to its SoundShaderManager variable. 
    7686extern SoundShaderManagerI* SoundShaderManager; 
    7787