CFx SDK Documentation  2023 SP0
RxSystemServices.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2017, Open Design Alliance (the "Alliance").
3 // All rights reserved.
4 //
5 // This software and its documentation and related materials are owned by
6 // the Alliance. The software may only be incorporated into application
7 // programs owned by members of the Alliance, subject to a signed
8 // Membership Agreement and Supplemental Software License Agreement with the
9 // Alliance. The structure and organization of this software are the valuable
10 // trade secrets of the Alliance and its suppliers. The software is also
11 // protected by copyright law and international treaty provisions. Application
12 // programs incorporating this software must include the following statement
13 // with their copyright notices:
14 //
15 // This application incorporates Teigha(R) software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Teigha(R) Copyright (C) 2002-2017 by Open Design Alliance.
18 // All rights reserved.
19 //
20 // By use of this software, its documentation or related materials, you
21 // acknowledge and accept the above terms.
23 
24 
25 #ifndef _ODRXSYSTEMSERVICES_INCLUDED_
26 #define _ODRXSYSTEMSERVICES_INCLUDED_
27 
28 #include <stdarg.h>
29 
30 #include "RxObject.h"
31 #include "OdStreamBuf.h"
32 #include "OdCodePage.h"
33 #if defined(_DEBUG) && defined(_WIN32)
34 #define STL_USING_VECTOR
35 #include "OdaSTL.h"
36 #endif
37 
38 class OdTimeStamp;
39 class OdRxModule;
40 class OdRxDictionary;
42 
43 #include "TD_PackPush.h"
44 
49 namespace Oda
50 {
52 
53 
54  enum FileAccessMode // Access
55  {
56  kFileRead = (long)
57  0x80000000, // Read access. Use kFileRead | kFileWrite for read/write access.
58  kFileWrite = 0x40000000, // Write access. Use kFileRead | kFileWrite for read/write access.
59  kFileTmp = 0x20000000, // hint to use FILE_ATTRIBUTE_TEMPORARY for 'FlagsAndAttributes'
60  kFileDelete = 0x10000000, // hint to use FILE_FLAG_DELETE_ON_CLOSE for 'FlagsAndAttributes'
61  kNoFlushWhenClosed = 0x08000000 //do NOT call FlushFileBuffers when closing file (tremendously accelerates writing small files) //FELIX_CHANGE
62  };
63 
65  {
66  kShareDenyReadWrite = 0x10, // deny read/write mode
67  kShareDenyWrite = 0x20, // deny write mode
68  kShareDenyRead = 0x30, // deny read mode
69  kShareDenyNo = 0x40 // deny none mode
70  };
71 
72 
74  {
75  kCreateNew = 1, // Creates a new file; fails if the specified file already exists.
76  kCreateAlways = 2, // Creates a new file; overwrites any existing file.
77  kOpenExisting = 3, // Opens the file; fails if the file does not exist.
78  kOpenAlways = 4, // Opens the file; creates the file if it does not exist.
79  kTruncateExisting = 5 // Truncates the file; fails if the file does not exist. The file must be open at least kFileWrite.
80  };
81 }
82 
91 {
92 public:
96  OdError_FileException(OdResult code, const OdString& filename, const OdString& extended = OdString::kEmpty);
101 };
102 
111 {
112 public:
115  OdError_FileNotFound(const OdString& filename);
116 };
117 
126 {
127 public:
130  OdError_CantOpenFile(const OdString& filename);
131 };
132 
141 {
142 public:
146 };
147 
155 {
156 public:
158 };
159 
167 {
168 public:
170 };
171 
181 {
182 public:
183 
185  {
186 #if defined _WIN32_WCE
187  srand(GetTickCount());
188 #else
189  Od_srand((unsigned int) time(0));
190 #endif
191  }
193 
234  const OdString& filename,
235  Oda::FileAccessMode accessMode = Oda::kFileRead,
237  Oda::FileCreationDisposition creationDisposition = Oda::kOpenExisting);
238 
256  virtual bool accessFile(const OdString& filename, int accessMode);
257 
265  virtual OdInt64 getFileCTime(const OdString& filename) = 0;
266 
274  virtual OdInt64 getFileMTime(const OdString& filename) = 0;
275 
283  virtual OdInt64 getFileSize(const OdString& filename) = 0;
284 
285 
291  virtual OdString formatMessage(unsigned int formatId, va_list* argList= 0) = 0;
292 
299  virtual OdString formatMsg(unsigned int formatId, ...);
300 
304  virtual OdCodePageId systemCodePage() const = 0;
305 
309  virtual OdString createGuid();
310 
314  virtual OdGUID createOdGUID();
315 
327  virtual OdRxModule* loadModule(const OdString& moduleFileName, bool silent);
328 
334  virtual void unloadModule(OdRxModule* pModuleObj);
335 
341  virtual OdString findModule(const OdString& applicationName);
342 
348  virtual void warning(const OdString& message);
349 
356  virtual void warning(const char* warnVisGroup, const OdString& message);
357 
368  static OdRxModule* loadModuleLib(const OdString& moduleFileName, bool silent);
369 
382 
383 #if defined(_DEBUG) && defined(_WIN32)
384  static void dontFreeLibrary(std::vector<HMODULE>* notFreedDlls) { s_notFreedDlls = notFreedDlls; }
385 private:
386  FIRSTDLL_EXPORT_STATIC static std::vector<HMODULE>* s_notFreedDlls;
387 #endif
388 };
393 
395 
396 #include "TD_PackPop.h"
397 
398 #endif // #ifndef _ODRXSYSTEMSERVICES_INCLUDED_
OdCodePageId
Definition: OdCodePage.h:31
#define Od_srand
Definition: OdPlatform.h:136
OdResult
Definition: OdResult.h:29
#define FIRSTDLL_EXPORT
Definition: RootExport.h:39
#define FIRSTDLL_EXPORT_STATIC
Definition: RootExport.h:40
FIRSTDLL_EXPORT OdRxSystemServices * odrxSystemServices()
OdSmartPtr< OdRxSystemServices > OdRxSystemServicesPtr
OdSmartPtr< OdRxDictionary > OdRxDictionaryPtr
OdError_CantOpenFile(const OdString &filename)
OdString getFileName() const
OdError_FileException(OdResult code, const OdString &filename, const OdString &extended=OdString::kEmpty)
OdError_FileNotFound(const OdString &filename)
OdError_FileWriteError(const OdString &filename)
Definition: OdGUID.h:29
Definition: Int64.h:43
virtual OdCodePageId systemCodePage() const =0
virtual OdStreamBufPtr createFile(const OdString &filename, Oda::FileAccessMode accessMode=Oda::kFileRead, Oda::FileShareMode shareMode=Oda::kShareDenyNo, Oda::FileCreationDisposition creationDisposition=Oda::kOpenExisting)
static OdRxModule * loadModuleLib(const OdString &moduleFileName, bool silent)
virtual OdString formatMessage(unsigned int formatId, va_list *argList=0)=0
virtual void warning(const char *warnVisGroup, const OdString &message)
virtual OdInt64 getFileSize(const OdString &filename)=0
virtual void unloadModule(OdRxModule *pModuleObj)
virtual OdGUID createOdGUID()
virtual OdResult uninitModelerLibrary(OdRxDictionary *pDict)
virtual void warning(const OdString &message)
virtual bool accessFile(const OdString &filename, int accessMode)
virtual OdResult initModelerLibrary(OdRxDictionary *pDict)
virtual OdInt64 getFileMTime(const OdString &filename)=0
virtual OdRxModule * loadModule(const OdString &moduleFileName, bool silent)
virtual OdString createGuid()
virtual OdString formatMsg(unsigned int formatId,...)
virtual OdString findModule(const OdString &applicationName)
virtual OdInt64 getFileCTime(const OdString &filename)=0
FIRSTDLL_EXPORT_STATIC static const OdString kEmpty
Definition: OdString.h:98
Definition: TxDefs.h:48
@ kShareDenyRead
@ kShareDenyWrite
@ kShareDenyNo
@ kShareDenyReadWrite
FileCreationDisposition
@ kCreateNew
@ kOpenAlways
@ kCreateAlways
@ kTruncateExisting
@ kOpenExisting
@ kFileDelete
@ kFileWrite
@ kNoFlushWhenClosed