CFx SDK Documentation 2024 SP0
Loading...
Searching...
No Matches
DbRuntimeIO.h
Go to the documentation of this file.
1
2// Copyright (C) 2002-2022, 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 Open Design Alliance software pursuant to a license
16// agreement with Open Design Alliance.
17// Open Design Alliance Copyright (C) 2002-2022 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 _OdDbRuntimeIOModule_H_
26#define _OdDbRuntimeIOModule_H_
27
28//#ifdef DBRUNTIMEIO_EXPORTS
29//#define DBRTIO_EXPORT OD_TOOLKIT_EXPORT
30//#define DBRTIO_EXPORT_GLOBAL OD_DLL_EXPORT
31//#define DBRTIO_EXPORT_STATIC OD_STATIC_EXPORT
32//#else
33//#define DBRTIO_EXPORT OD_TOOLKIT_IMPORT
34//#define DBRTIO_EXPORT_GLOBAL OD_DLL_IMPORT
35//#define DBRTIO_EXPORT_STATIC OD_STATIC_IMPORT
36//#endif
37
38#include "RxModule.h"
39#include "SmartPtr.h"
40#include "OdArray.h"
41#include "RxSystemServices.h"
42#include "UInt64Array.h"
43#define STL_USING_QUEUE
44#include "OdaSTL.h"
45
46#include "TD_PackPush.h"
47#include "DbObjectId.h"
48
49class OdDbDatabase;
50
56protected:
57 virtual void initApp();
58 virtual void uninitApp();
59public:
60 virtual void writeFile(OdDbDatabase* db, const OdString& fileName);
61 virtual void readFile(OdDbDatabase* db, const OdString& fileName, bool lazyObjectLoading = false);
62};
63
65class OdDbStub;
66class OdDbObject;
68
73 kSoftPointer = 0, // Soft Pointer Reference
74 kHardPointer = 1, // Hard Pointer Reference
75 kSoftOwnership = 2, // Soft Ownership Reference
76 kHardOwnership = 3 // Hard Ownership Reference
77};
78
83template <class TReference>
85 typedef std::pair<TReference, OdDbReferenceType> TypedReference;
86 typedef std::queue<TypedReference> RefQueueImp;
87 RefQueueImp queue;
88 bool addHardRef, addOwnershipRef, addSoftRef;
89public:
90 OdDbReferenceQueue(bool addOwnershipRef = true, bool addHardRef = false, bool addSoftRef = false) {
91 this->addOwnershipRef = addOwnershipRef;
92 this->addHardRef = addHardRef;
93 this->addSoftRef = addHardRef;
94 }
95 size_t size() const { return queue.size(); }
96 bool push(const TReference& ref, OdDbReferenceType type = kSoftPointer);
97 TReference pop(OdDbReferenceType* type = 0);
98 void clear() { queue = RefQueueImp(); }
99};
100
106public:
108
109 virtual void reset(OdDbDatabase* db) = 0;
110
111 virtual OdDbDatabase* database() = 0;
112
113 virtual void writeDataFrame(OdStreamBuf& output) = 0;
114
115 virtual void closeInput(bool finishDataLoading = false) = 0;
116
117 // loads only index if no database
118 virtual void loadDataFrame(OdStreamBuf& input) = 0;
119
120 void writeFile(OdDbDatabase* db, const OdString& fileName) {
121 reset(db);
122 using namespace Oda;
123 writeDataFrame(*::odrxSystemServices()->createFile(fileName, kFileWrite, kShareDenyReadWrite, kCreateAlways));
124 closeInput();
125 }
126
127 void readFile(OdDbDatabase* db, const OdString& fileName, bool lazyObjectLoading) {
128 reset(db);
129 loadDataFrame(*::odrxSystemServices()->createFile(fileName));
130 closeInput();
131 }
132
134
135 virtual OdUInt64 lookupOffset(OdDbStub* id) = 0;
136
137 virtual OdUInt64 lookupOffset(OdUInt64 handle) = 0;
138
139 virtual OdUInt64 seekObject(OdUInt64 handle) = 0;
140
141 virtual void loadObjects(OdStreamBuf& objectStream, OdUInt64 endPos = 0xFFFFFFFFFFFFFFFFULL) = 0;
142
143 virtual void startDataFrame(OdStreamBuf& output, bool enableCopyMaping = true) = 0;
144
145 virtual void disableObjectCopyMapping(bool doIt = true) = 0;
146
149
150 virtual OdDbObjectPtr readObject(OdStreamBuf& objectInStream, IdRefQueue* refQueue = 0) = 0;
151 virtual void copyObjectStream(OdUInt64 handle, OdStreamBuf& output, RefQueue* refQueue = 0) = 0;
152 virtual void copyStream(OdStreamBuf& output, RefQueue* refQueue = 0) = 0;
153
154 virtual void copyObjectStream(const OdDbObjectId &id, OdStreamBuf& output, IdRefQueue* idrefQueue = 0) = 0;
155 virtual void copyStream(OdStreamBuf& output, IdRefQueue* idrefQueue = 0) = 0;
156
157 virtual OdUInt64 readObjectSize(OdStreamBuf& input) = 0; // reads and returns object data counter; curpos after counter
158 virtual OdUInt64 getObjectSize(OdStreamBuf& input) = 0; // restores input stream position after reading data counter
159 virtual OdUInt64 getObjectSize(OdUInt64 handle) = 0; // restores input stream position after reading data counter
160
161 virtual void finishDataFrame(OdStreamBuf& output) = 0;
162
163 virtual void writeDbRoot(OdStreamBuf* output = 0, OdDbRtFilerController::RefQueue* refQueue = 0) = 0;
164 virtual void writeObject(OdDbObject* obj, OdStreamBuf* output, RefQueue* refQueue = 0) = 0;
165};
166
168
169
170
171template <class TReference>
173 TReference referenceHandle;
174 if (!queue.empty()) {
175 TypedReference& reference = queue.front();
176 referenceHandle = reference.first;
177 if (type)
178 *type = reference.second;
179 ODA_ASSERT(referenceHandle != 0);
180 queue.pop();
181 }
182 return referenceHandle;
183}
184
185template <class TReference>
187 if ((const OdUInt64&)ref) {
188 if (addSoftRef || addHardRef && GETBIT(type, 1) || addOwnershipRef && GETBIT(type, 2)) {
189 queue.push(TypedReference(ref, type));
190 return true;
191 }
192 }
193 return false;
194}
195
196
197#include "TD_PackPop.h"
198
199#endif // _OdDbRuntimeIOModule_H_
OdSmartPtr< OdDbObject > OdDbObjectPtr
Definition: DbRuntimeIO.h:67
OdDbReferenceType
Definition: DbRuntimeIO.h:72
@ kHardPointer
Definition: DbRuntimeIO.h:74
@ kHardOwnership
Definition: DbRuntimeIO.h:76
@ kSoftOwnership
Definition: DbRuntimeIO.h:75
@ kSoftPointer
Definition: DbRuntimeIO.h:73
OdSmartPtr< OdDbRtFilerController > OdDbRtFilerControllerPtr
Definition: DbRuntimeIO.h:167
OdSmartPtr< OdDbRuntimeIOModule > OdDbRuntimeIOModulePtr
Definition: DbRuntimeIO.h:64
#define ODA_ASSERT(exp)
Definition: DebugStuff.h:57
#define GETBIT(flags, bit)
Definition: OdaDefs.h:517
FIRSTDLL_EXPORT OdRxSystemServices * odrxSystemServices()
size_t size() const
Definition: DbRuntimeIO.h:95
OdDbReferenceQueue(bool addOwnershipRef=true, bool addHardRef=false, bool addSoftRef=false)
Definition: DbRuntimeIO.h:90
bool push(const TReference &ref, OdDbReferenceType type=kSoftPointer)
Definition: DbRuntimeIO.h:186
TReference pop(OdDbReferenceType *type=0)
Definition: DbRuntimeIO.h:172
virtual void copyObjectStream(const OdDbObjectId &id, OdStreamBuf &output, IdRefQueue *idrefQueue=0)=0
virtual void copyStream(OdStreamBuf &output, RefQueue *refQueue=0)=0
virtual void disableObjectCopyMapping(bool doIt=true)=0
ODRX_DECLARE_MEMBERS(OdDbRtFilerController)
OdDbReferenceQueue< OdDbStub * > IdRefQueue
Definition: DbRuntimeIO.h:148
virtual OdStreamBufPtr openStream(const OdString &name, Oda::FileAccessMode mode)=0
virtual OdDbObjectPtr readObject(OdStreamBuf &objectInStream, IdRefQueue *refQueue=0)=0
virtual OdDbDatabase * database()=0
virtual OdUInt64 readObjectSize(OdStreamBuf &input)=0
virtual void loadObjects(OdStreamBuf &objectStream, OdUInt64 endPos=0xFFFFFFFFFFFFFFFFULL)=0
virtual void writeObject(OdDbObject *obj, OdStreamBuf *output, RefQueue *refQueue=0)=0
virtual void reset(OdDbDatabase *db)=0
virtual void writeDataFrame(OdStreamBuf &output)=0
OdDbReferenceQueue< OdUInt64 > RefQueue
Definition: DbRuntimeIO.h:147
virtual OdUInt64 getObjectSize(OdUInt64 handle)=0
virtual OdUInt64 seekObject(OdUInt64 handle)=0
virtual OdUInt64 getObjectSize(OdStreamBuf &input)=0
void writeFile(OdDbDatabase *db, const OdString &fileName)
Definition: DbRuntimeIO.h:120
virtual OdUInt64 lookupOffset(OdDbStub *id)=0
void readFile(OdDbDatabase *db, const OdString &fileName, bool lazyObjectLoading)
Definition: DbRuntimeIO.h:127
virtual void loadDataFrame(OdStreamBuf &input)=0
virtual void copyObjectStream(OdUInt64 handle, OdStreamBuf &output, RefQueue *refQueue=0)=0
virtual void finishDataFrame(OdStreamBuf &output)=0
virtual void copyStream(OdStreamBuf &output, IdRefQueue *idrefQueue=0)=0
virtual void closeInput(bool finishDataLoading=false)=0
virtual void startDataFrame(OdStreamBuf &output, bool enableCopyMaping=true)=0
virtual void writeDbRoot(OdStreamBuf *output=0, OdDbRtFilerController::RefQueue *refQueue=0)=0
virtual OdUInt64 lookupOffset(OdUInt64 handle)=0
virtual void readFile(OdDbDatabase *db, const OdString &fileName, bool lazyObjectLoading=false)
virtual void uninitApp()
virtual void initApp()
virtual void writeFile(OdDbDatabase *db, const OdString &fileName)
GLenum GLint ref
Definition: gles2_ext.h:262
GLuint const GLchar * name
Definition: gles2_ext.h:265
GLuint GLsizei GLsizei GLint GLenum * type
Definition: gles2_ext.h:274
Definition: TxDefs.h:49