Debian Codegraph @

netgames/dmfc/idmfc.cpp

raw symbols SCIP
1 /*
2 * Descent 3
3 * Copyright (C) 2024 Parallax Software
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18 --- HISTORICAL COMMENTS FOLLOW ---
19
20 * $Logfile: /DescentIII/Main/Dmfc/idmfc.cpp $
21 * $Revision: 1.1.1.1 $
22 * $Date: 2003/08/26 03:57:21 $
23 * $Author: kevinb $
24 *
25 * DMFC COM Interface implementation
26 *
27 * $Log: idmfc.cpp,v $
28 * Revision 1.1.1.1 2003/08/26 03:57:21 kevinb
29 * initial 1.5 import
30 *
31 *
32 * 3 7/16/99 2:43p Jeff
33 * changed CreateMenuItemWArgs function
34 *
35 * 2 3/17/99 12:25p Jeff
36 * converted DMFC to be COM interface
37 *
38 * 1 3/17/99 11:54a Jeff
39 *
40 * $NoKeywords: $
41 */
42
43 #include "idmfc.h"
44 #include "dmfcinternal.h"
45
46 /*
47 ***********************************************
48 IDMFC
49 ***********************************************
50 */
51 DMFCBase *basethis = NULL;
52 IDMFC DLLFUNCCALLPTR CreateDMFC(void) {
53 if (basethis) {
54 return NULL;
55 }
56
57 basethis = new DMFCBase;
58 IDMFC *pfsResult = basethis;
59 if (pfsResult) {
60 pfsResult->DuplicatePointer();
61 }
62
63 return pfsResult;
64 }
65
66 void DMFCBase::Delete(void) {
67 delete this;
68 basethis = NULL;
69 }
70
71 void *DMFCBase::Dynamic_Cast(const char *pszType) {
72 void *pvResult = NULL;
73
74 if (strcmp(pszType, "IDMFC") == 0)
75 pvResult = static_cast<IDMFC *>(this);
76 else
77 return NULL;
78
79 ((IObject *)pvResult)->DuplicatePointer();
80 return pvResult;
81 }
82
83 void DMFCBase::DuplicatePointer(void) { ++m_cPtrs; }
84
85 void DMFCBase::DestroyPointer(void) {
86 if (--m_cPtrs == 0) {
87 basethis = NULL;
88 delete this;
89 }
90 }
91
92 /*
93 ***********************************************
94 IMenuItem
95 ***********************************************
96 */
97
98 IMenuItem DLLFUNCCALLPTR CreateMenuItem(void) {
99 IMenuItem *pfsResult = new MenuItem;
100 if (pfsResult)
101 pfsResult->DuplicatePointer();
102 return pfsResult;
103 }
104
105 IMenuItem DLLFUNCCALLPTR CreateMenuItemWArgs(const char *title, char type, uint8_t flags, void (*fp)(int),
106 tCustomMenu *custom_menu) {
107 MenuItem *p;
108
109 if (type != MIT_CUSTOM && type != MIT_STATE) {
110 p = new MenuItem(title, type, flags, fp);
111 } else {
112 if (type == MIT_CUSTOM) {
113 ASSERT(custom_menu != NULL);
114 if (custom_menu == NULL)
115 return NULL;
116
117 p = new MenuItem(title, type, flags, fp, custom_menu);
118 } else {
119 p = new MenuItem(title, type, flags, fp, 0, 0); // set initially to 0 state items
120 }
121 }
122
123 if (p)
124 p->DuplicatePointer();
125
126 return p;
127 }
128
129 void MenuItem::Delete(void) { delete this; }
130
131 void *MenuItem::Dynamic_Cast(const char *pszType) {
132 void *pvResult = NULL;
133
134 if (strcmp(pszType, "IMenuItem") == 0)
135 pvResult = static_cast<IMenuItem *>(this);
136 else
137 return NULL;
138
139 ((IObject *)pvResult)->DuplicatePointer();
140 return pvResult;
141 }
142
143 void MenuItem::DuplicatePointer(void) { ++m_cPtrs; }
144
145 void MenuItem::DestroyPointer(void) {
146 if (--m_cPtrs == 0)
147 delete this;
148 }
149
150 /*
151 ***********************************************
152 IDmfcStats
153 ***********************************************
154 */
155 IDmfcStats DLLFUNCCALLPTR CreateDmfcStats(void) {
156 IDmfcStats *pfsResult = new CDmfcStats;
157 if (pfsResult)
158 pfsResult->DuplicatePointer();
159 return pfsResult;
160 }
161
162 void CDmfcStats::Delete(void) { delete this; }
163
164 void *CDmfcStats::Dynamic_Cast(const char *pszType) {
165 void *pvResult = NULL;
166
167 if (strcmp(pszType, "IDmfcStats") == 0)
168 pvResult = static_cast<IDmfcStats *>(this);
169 else
170 return NULL;
171
172 ((IObject *)pvResult)->DuplicatePointer();
173 return pvResult;
174 }
175
176 void CDmfcStats::DuplicatePointer(void) { ++m_cPtrs; }
177
178 void CDmfcStats::DestroyPointer(void) {
179 if (--m_cPtrs == 0)
180 delete this;
181 }