Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
ffactory.h
Go to the documentation of this file.
1/*
2** Command & Conquer Generals Zero Hour(tm)
3** Copyright 2025 Electronic Arts Inc.
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
19/***********************************************************************************************
20 *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
21 ***********************************************************************************************
22 * *
23 * Project Name : Command & Conquer *
24 * *
25 * $Archive:: /Commando/Code/wwlib/ffactory.h $*
26 * *
27 * $Author:: Steve_t $*
28 * *
29 * $Modtime:: 9/07/01 5:30p $*
30 * *
31 * $Revision:: 14 $*
32 * *
33 *---------------------------------------------------------------------------------------------*
34 * Functions: *
35 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
36
37#if _MSC_VER >= 1000
38#pragma once
39#endif // _MSC_VER >= 1000
40
41#ifndef FFACTORY_H
42#define FFACTORY_H
43
44#ifndef ALWAYS_H
45#include "always.h"
46#endif
47
48#include "mutex.h"
49#include "vector.h"
50#include "wwstring.h"
51
52/*
53**
54*/
55#include "rawfile.h"
56class FileClass;
57
58/*
59** FileFactoryClass is a pure virtual class used to
60** create FileClasses.
61*/
63
64public:
65 virtual ~FileFactoryClass(void){};
66 virtual FileClass * Get_File( char const *filename ) = 0;
67 virtual void Return_File( FileClass *file ) = 0;
68};
69
70
71
72
73//
74// Handy auto pointer class. Prevents you from having to call Return_File manually
75//
77{
78public:
79 explicit file_auto_ptr(FileFactoryClass *fac, const char *filename);
81
82 operator FileClass*(void) const
83 {return (get()); }
84
86 {return (*get()); }
87
89 {return (get()); }
90
91 FileClass *get() const
92 {return (_Ptr); }
93
94private:
95 // prevent these from getting auto-generated or used
96 file_auto_ptr(const file_auto_ptr &other);
97 file_auto_ptr &operator=(const file_auto_ptr &other);
98
99
100 FileClass *_Ptr;
101 FileFactoryClass *_Fac;
102};
103
104
105
106
107
108
109
110/*
111** RawFileFactoryClass is a derived FileFactoryClass which
112** gives RawFileClass objects
113*/
115public:
116 RawFileClass * Get_File( char const *filename );
117 void Return_File( FileClass *file );
118};
119
120#define no_SIMPLE_FILE
121/*
122** SimpleFileFactoryClass is a slightly more capable derivative of
123** FileFactoryClass which adds some simple extra functionality. It supports a
124** current subdirectory, and also adds some logging capabilities. Note that
125** it currently creates BufferedFileClass objects instead of RawFileClass
126** objects.
127*/
129
130public:
133
134 virtual FileClass * Get_File( char const *filename );
135 virtual void Return_File( FileClass *file );
136
137 // sub_directory may be a semicolon seperated search path. New files will always
138 // go in the last dir in the path.
139 void Get_Sub_Directory( StringClass& new_dir ) const;
140 void Set_Sub_Directory( const char * sub_directory );
141 void Prepend_Sub_Directory( const char * sub_directory );
142 void Append_Sub_Directory( const char * sub_directory );
143 bool Get_Strip_Path( void ) const { return IsStripPath; }
144 void Set_Strip_Path( bool set ) { IsStripPath = set; }
145 void Reset_Sub_Directory( void ) { SubDirectory = ""; }
146
147protected:
150
151 // Mutex must be mutable because const functions lock on it.
153};
154
155
158
159// No simple file factory. jba.
160// (gth) re-enabling this because w3d view uses it
162
163#endif
virtual ~FileFactoryClass(void)
Definition ffactory.h:65
virtual void Return_File(FileClass *file)=0
virtual FileClass * Get_File(char const *filename)=0
RawFileClass * Get_File(char const *filename)
Definition ffactory.cpp:80
void Return_File(FileClass *file)
Definition ffactory.cpp:85
CriticalSectionClass Mutex
Definition ffactory.h:152
bool Get_Strip_Path(void) const
Definition ffactory.h:143
void Append_Sub_Directory(const char *sub_directory)
Definition ffactory.cpp:173
void Get_Sub_Directory(StringClass &new_dir) const
Definition ffactory.cpp:103
virtual void Return_File(FileClass *file)
Definition ffactory.cpp:307
void Reset_Sub_Directory(void)
Definition ffactory.h:145
StringClass SubDirectory
Definition ffactory.h:148
void Set_Strip_Path(bool set)
Definition ffactory.h:144
virtual FileClass * Get_File(char const *filename)
Definition ffactory.cpp:235
void Set_Sub_Directory(const char *sub_directory)
Definition ffactory.cpp:124
void Prepend_Sub_Directory(const char *sub_directory)
Definition ffactory.cpp:138
FileClass & operator*() const
Definition ffactory.h:85
FileClass * get() const
Definition ffactory.h:91
file_auto_ptr(FileFactoryClass *fac, const char *filename)
Definition ffactory.cpp:60
FileClass * operator->() const
Definition ffactory.h:88
RawFileFactoryClass * _TheWritingFileFactory
Definition ffactory.cpp:55
FileFactoryClass * _TheFileFactory
Definition ffactory.cpp:51
SimpleFileFactoryClass * _TheSimpleFileFactory
Definition ffactory.cpp:52