OWLNext    7.0
Borland's Object Windows Library for the modern age
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
global.cpp
Go to the documentation of this file.
1//----------------------------------------------------------------------------
2// ObjectWindows
3// Copyright (c) 1991, 1996 by Borland International, All Rights Reserved
4//
5/// \file
6/// Global data required for every module using OWL
7//----------------------------------------------------------------------------
8
9#if defined(__BORLANDC__)
10# pragma option -w-ccc // Disable "Condition is always true/false"
11# pragma option -w-inl // Disable warning "Functions containing 'statement' is not expanded inline".
12#endif
13
14#include <owl/pch.h>
15
16#include <owl/applicat.h>
17
18#if defined(_MSC_VER)
19#include <owl/private/defs.h>
20#include <owl/module.h>
21#endif
22
23namespace owl {
24
27
29
30//
31// Global module pointer representing this executable instance
32// provides the default instance for resources contructed within this module
33//
34TModule* Module = 0; // Global Module ptr in each DLL/EXE
35
37{
38 if (Module == NULL)
39 {
41 GetModuleFileName(hInstance, buffer, _MAX_PATH);
42 static TModule module(buffer, hInstance);
43 Module = &module;
44 TRACEX(OwlMain, 0, "Global Module " << hInstance << ", " << buffer << " created");
45 }
46}
47
49{
50 if (Module == NULL)
51 {
54 }
55
56 return *Module;
57}
58
59} // OWL namespace
60
61using namespace owl;
62
63//
64// Document templates contructed before doc manager get linked in here
65//
66owl::TDocTemplate* DocTemplateStaticHead = 0; // initialize to no templates
67
68//
69// This mask deems when certain features are available.
70// See GetDocTemplateHead and GetModulePtr below.
71//
72const uint32 CompatibleVersionMask = 0xFFF00000;
73
74//
75// Exported access to global variables for DLLs that use OWL
76//
77
78#if defined(BI_COMP_BORLANDC)
79
80extern "C" {
82{
84}
86GetModulePtr(uint32 version)
87{
88 return (version&CompatibleVersionMask) == (OWLGetVersion()&CompatibleVersionMask) ? &owl::Module : nullptr;
89}
90}
91
92#elif defined(BI_COMP_GNUC)
93
94extern "C" {
96{
98}
100GetModulePtr(uint32 version)
101{
103}
104}
105
106#else
107
108// EMF __export removed because it isn't needed in win32
110{
112}
113
114/*__export*/ STDAPI_(TModule**) GetModulePtr(uint32 version)
115{
116 return (version&CompatibleVersionMask) == (OWLGetVersion()&CompatibleVersionMask) ? &owl::Module : nullptr;
117}
118
119#endif
120
121/* ========================================================================== */
122
Definition of class TApplication.
#define TRACEX(group, level, message)
Definition checks.h:263
#define DIAG_DEFINE_GROUP_INIT(f, g, e, l)
Definition checks.h:429
TDocTemplate is an abstract base class that contains document template functionality.
Definition doctpl.h:54
ObjectWindows dynamic-link libraries (DLLs) construct an instance of TModule, which acts as an object...
Definition module.h:75
#define _MAX_PATH
Definition cygwin.h:97
const uint32 CompatibleVersionMask
Definition global.cpp:72
owl::TDocTemplate * DocTemplateStaticHead
Templates constructed before app get linked onto this head pointer.
Definition global.cpp:66
STDAPI_(TDocTemplate **) GetDocTemplateHead(uint32 version)
Definition global.cpp:109
Definition of class TModule.
STDAPI_(owl::TDocTemplate **) GetDocTemplateHead(owl STDAPI_(owl::TModule **) GetModulePtr(owl in OwlMain)(int argc, TCHAR *argv[])
Main entry point for an Owl application.
Definition module.h:391
Object Windows Library (OWLNext Core)
Definition animctrl.h:22
TModule * Module
Definition global.cpp:34
OWL_DIAGINFO
Definition animctrl.cpp:14
void InitGlobalModule(HINSTANCE hInstance)
Definition global.cpp:36
TModule & GetGlobalModule()
Definition global.cpp:48
uint32 OWLGetVersion()
Get version of OWL at runtime.
Definition owl.cpp:43
STDAPI __declspec(dllexport) DllRegisterCommand(LPCTSTR cmdLine)
Entry point for complete registration management via command line Don't let any exceptions blow back ...
Definition ocreg.cpp:495
#define OWL_INI
Definition defs.h:170
#define _OWLCLASS
Definition defs.h:338