gwnavruntime/base/filehandler.h Source File

filehandler.h
Go to the documentation of this file.
1 /*
2 * Copyright 2015 Autodesk, Inc. All rights reserved.
3 * Use of this software is subject to the terms of the Autodesk license agreement and any attachments or Appendices thereto provided at the time of installation or download,
4 * or which otherwise accompanies this software in either electronic or hard copy form, or which is signed by you and accepted by Autodesk.
5 */
6 
7 
8 // primary contact: GUAL - secondary contact: NOBODY
9 #ifndef Navigation_Filehandler_H
10 #define Navigation_Filehandler_H
11 
12 
17 
18 
19 namespace Kaim
20 {
21 
22 class File;
23 class FileOpenerBase;
24 
25 
26 class FileHandler
27 {
28  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
29  KY_CLASS_WITHOUT_COPY(FileHandler)
30 public:
31  enum ErrorReportMode { NO_ERROR_REPORT = 0, DO_REPORT_REPORT};
32 
33  FileHandler() : m_file(KY_NULL) {}
34 
35  File* OpenForRead(const char* fileName, FileOpenerBase* fileOpener = KY_NULL, ErrorReportMode errorReportMode = DO_REPORT_REPORT);
36  File* OpenForWrite(const char* fileName, FileOpenerBase* fileOpener = KY_NULL, ErrorReportMode errorReportMode = DO_REPORT_REPORT);
37 
38  File* GetFile() { return m_file.GetPtr(); }
39 
40  ~FileHandler() { Close(); }
41 
42  void Close();
43 
44 private:
45  void Open(const char* fileName, FileOpenerBase* fileOpener, FileOpenerMode openMode, ErrorReportMode errorReportMode);
46 
47 private:
48  Ptr<File> m_file;
49 };
50 
51 }
52 
53 #endif
#define KY_NULL
Null value.
Definition: types.h:247
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:387
FileOpenerMode
Enumerates the possible modes for opening a file with a class that derives from FileOpenerBase.
Definition: fileopener.h:28
Definition: gamekitcrowddispersion.h:20
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:137