Blender V5.0
WriteData Struct Reference

Public Attributes

const SDNAsdna
std::ostream * debug_dst = nullptr
struct { 
   uchar *   buf 
   size_t   used_len 
   size_t   max_size 
   size_t   chunk_size 
buffer
bool is_writing_id
struct { 
   bool   critical_error 
   blender::Set< const void * >   per_id_addresses_set 
validation_data
struct { 
   std::unique_ptr< blender::dna::pointers::PointersInDNA >   sdna_pointers 
   blender::Map< const void *, uint64_t >   pointer_map 
   blender::Set< uint64_t >   used_ids 
   uint64_t   next_id_hint = 0 
stable_address_ids
blender::Set< const void * > per_id_written_shared_addresses
MemFileWriteData mem
bool use_memfile
WriteWrapww

Detailed Description

Definition at line 414 of file writefile.cc.

Member Data Documentation

◆ buf

uchar* WriteData::buf

Use for file and memory writing (size stored in max_size).

Definition at line 420 of file writefile.cc.

Referenced by mywrite(), mywrite_end(), mywrite_flush(), writedata_free(), and writedata_new().

◆ [struct]

struct { ... } WriteData::buffer

◆ chunk_size

size_t WriteData::chunk_size

Threshold above which writes get their own chunk.

Definition at line 427 of file writefile.cc.

Referenced by mywrite(), and writedata_new().

◆ critical_error

bool WriteData::critical_error

Set on unlikely case of an error (ignores further file writing). Only used for very low-level errors (like if the actual write on file fails).

Definition at line 444 of file writefile.cc.

Referenced by mywrite(), mywrite_end(), and writedata_do_write().

◆ debug_dst

std::ostream* WriteData::debug_dst = nullptr

◆ is_writing_id

bool WriteData::is_writing_id

Whether writefile code is currently writing an ID.

Definition at line 436 of file writefile.cc.

Referenced by mywrite_id_begin(), mywrite_id_end(), and write_at_address_validate().

◆ max_size

size_t WriteData::max_size

Maximum size of the buffer.

Definition at line 425 of file writefile.cc.

Referenced by mywrite(), and writedata_new().

◆ mem

MemFileWriteData WriteData::mem

MemFile writing (used for undo).

Definition at line 499 of file writefile.cc.

Referenced by BLO_write_shared(), mywrite_begin(), mywrite_end(), mywrite_id_begin(), mywrite_id_end(), and writedata_do_write().

◆ next_id_hint

uint64_t WriteData::next_id_hint = 0

The next stable address id is derived from this. This is modified in two cases:

  • A new stable address is needed, in which case this is just incremented.
  • A new "section" of the .blend file starts. In this case, this should be reinitialized with some hash of an identifier of the next section. This makes sure that if the number of pointers in the previous section is modified, the pointers in the new section are not affected. A "section" can be anything, but currently a section simply starts when a new data-block starts. In the future, an API could be added that allows sections to start within a data-block which could isolate stable pointer ids even more.

When creating the new address id, keep in mind that this may be 0 and it may collide with previous hints.

Definition at line 489 of file writefile.cc.

Referenced by get_address_id_int(), and mywrite_id_begin().

◆ per_id_addresses_set

blender::Set<const void *> WriteData::per_id_addresses_set

A set of all 'old' addresses used as UID of written blocks for the current ID. Allows detecting invalid re-uses of the same address multiple times.

Definition at line 449 of file writefile.cc.

Referenced by mywrite_id_begin(), mywrite_id_end(), and write_at_address_validate().

◆ per_id_written_shared_addresses

blender::Set<const void *> WriteData::per_id_written_shared_addresses

Keeps track of which shared data has been written for the current ID. This is necessary to avoid writing the same data more than once.

Definition at line 496 of file writefile.cc.

Referenced by BLO_write_shared(), and mywrite_id_end().

◆ pointer_map

blender::Map<const void *, uint64_t> WriteData::pointer_map

Maps each runtime-pointer to a unique identifier that's written in the .blend file.

Currently, no pointers are ever removed from this map during writing of a single file. Correctness wise, this is fine. However, when some data-blocks write temporary addresses, those may be reused across IDs while actually pointing to different data. This can break address id stability in some situations. In the future this could be improved by clearing such temporary pointers before writing the next data-block.

Definition at line 467 of file writefile.cc.

Referenced by BLO_write_shared_tag(), get_address_id_int(), and prepare_stable_data_block_ids().

◆ sdna

const SDNA* WriteData::sdna

◆ sdna_pointers

std::unique_ptr<blender::dna::pointers::PointersInDNA> WriteData::sdna_pointers

Knows which DNA members are pointers. Those members are overridden when serializing the .blend file to get more stable pointer identifiers.

Definition at line 457 of file writefile.cc.

Referenced by writedata_new(), and writestruct_at_address_nr().

◆ [struct]

◆ use_memfile

◆ used_ids

blender::Set<uint64_t> WriteData::used_ids

Contains all the #pointer_map.values(). This is used to make sure that the same id is never reused for a different pointer. While this is technically allowed in .blend files (when the pointers are local data of different objects), we currently don't always know what type a pointer points to when writing it. So we can't determine if a pointer is local or not.

Definition at line 474 of file writefile.cc.

Referenced by get_next_stable_address_id().

◆ used_len

size_t WriteData::used_len

Number of bytes used in WriteData.buf (flushed when exceeded).

Definition at line 422 of file writefile.cc.

Referenced by mywrite(), mywrite_end(), and mywrite_flush().

◆ [struct]

struct { ... } WriteData::validation_data

Some validation and error handling data.

Referenced by mywrite(), mywrite_end(), mywrite_id_begin(), mywrite_id_end(), write_at_address_validate(), and writedata_do_write().

◆ ww

WriteWrap* WriteData::ww

Wrap writing, so we can use zstd or other compression types later, see: G_FILE_COMPRESS Will be nullptr for UNDO.

Definition at line 508 of file writefile.cc.

Referenced by writedata_do_write(), and writedata_new().


The documentation for this struct was generated from the following file: