gwnavruntime/base/filehandler.h Source File

filehandler.h
Go to the documentation of this file.
1 /*
2 * Copyright 2016 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 #pragma once
8 
13 
14 namespace Kaim
15 {
16 
17 class File;
18 class FileOpenerBase;
19 
20 class FileHandler
21 {
22  KY_DEFINE_NEW_DELETE_OPERATORS(Stat_Default_Mem)
23  KY_CLASS_WITHOUT_COPY(FileHandler)
24 public:
25  enum ErrorReportMode { NO_ERROR_REPORT = 0, DO_ERROR_REPORT};
26 
27  FileHandler() : m_file(nullptr) {}
28 
29  File* OpenForRead(const char* fileName, FileOpenerBase* fileOpener = nullptr, ErrorReportMode errorReportMode = DO_ERROR_REPORT);
30  File* OpenForWrite(const char* fileName, FileOpenerBase* fileOpener = nullptr, ErrorReportMode errorReportMode = DO_ERROR_REPORT);
31 
32  File* GetFile() { return m_file.GetPtr(); }
33 
34  ~FileHandler() { Close(); }
35 
36  void Close();
37 
38 private:
39  void Open(const char* fileName, FileOpenerBase* fileOpener, FileOpenerMode openMode, ErrorReportMode errorReportMode);
40 
41 private:
42  Ptr<File> m_file;
43 };
44 
45 }
46 
#define KY_CLASS_WITHOUT_COPY(ClassName)
Define to forbid copy constructor and copy assignment.
Definition: types.h:196
#define KY_DEFINE_NEW_DELETE_OPERATORS(MemStat)
This macro defines new and delete operators.
Definition: memory.h:132
FileOpenerMode
Enumerates the possible modes for opening a file with a class that derives from FileOpenerBase.
Definition: fileopener.h:23
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17