OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
C4ObjectPtr Class Reference

#include <C4ObjectPtr.h>

Collaboration diagram for C4ObjectPtr:
[legend]

Public Member Functions

 C4ObjectPtr ()=default
 
 C4ObjectPtr (C4Object *pObj)
 
void CompileFunc (StdCompiler *pComp)
 
void DenumeratePointers ()
 
bool operator! () const
 
bool operator== (C4Object *other) const
 
bool operator== (const C4ObjectPtr &other) const
 
bool operator!= (C4Object *other) const
 
bool operator!= (const C4ObjectPtr &other) const
 
C4ObjectPtr operator= (C4Object *object)
 
C4Objectoperator* () const
 
C4Objectoperator-> () const
 
 operator C4Object * () const
 

Static Public Attributes

static const C4ObjectPtr Null
 

Protected Attributes

bool fDenumerated
 
union {
C4Objectptr
 
intptr_t nptr
 
data
 

Detailed Description

Definition at line 22 of file C4ObjectPtr.h.

Constructor & Destructor Documentation

C4ObjectPtr::C4ObjectPtr ( )
default
C4ObjectPtr::C4ObjectPtr ( C4Object pObj)
inline

Definition at line 32 of file C4ObjectPtr.h.

References data.

34  : fDenumerated(true)
35 #endif
36  {
37  data.ptr = pObj;
38  }
bool fDenumerated
Definition: C4ObjectPtr.h:64
union C4ObjectPtr::@78 data

Member Function Documentation

void C4ObjectPtr::CompileFunc ( StdCompiler pComp)

Definition at line 28 of file C4ObjectPtr.cpp.

References data, fDenumerated, StdCompiler::isDeserializer(), and StdCompiler::Value().

29 {
30  // Pointer needs to be denumerated when decompiling
31  assert(fDenumerated);
32 
33  int32_t nptr = 0;
34  if (!pComp->isDeserializer() && data.ptr)
35  nptr = data.ptr->Number;
36  pComp->Value(nptr);
37  if (pComp->isDeserializer())
38  {
39  data.nptr = nptr;
40 #ifndef NDEBUG
41  // After having read a value the pointer is enumerated
42  fDenumerated = false;
43 #endif
44  }
45 }
bool fDenumerated
Definition: C4ObjectPtr.h:64
union C4ObjectPtr::@78 data
void Value(const T &rStruct)
Definition: StdCompiler.h:161
virtual bool isDeserializer()
Definition: StdCompiler.h:53

Here is the call graph for this function:

void C4ObjectPtr::DenumeratePointers ( )

Definition at line 47 of file C4ObjectPtr.cpp.

References data, fDenumerated, C4GameObjects::ObjectPointer(), and Objects.

Referenced by C4Command::Denumerate(), C4Object::Denumerate(), C4MeshDenumerator::DenumeratePointers(), C4ValueProviderX::DenumeratePointers(), C4ValueProviderY::DenumeratePointers(), C4ValueProviderR::DenumeratePointers(), C4ValueProviderAbsX::DenumeratePointers(), C4ValueProviderAbsY::DenumeratePointers(), C4ValueProviderDist::DenumeratePointers(), C4ValueProviderXDir::DenumeratePointers(), C4Player::DenumeratePointers(), C4ValueProviderYDir::DenumeratePointers(), C4GraphicsOverlay::DenumeratePointers(), C4ValueProviderRDir::DenumeratePointers(), C4ValueProviderAbsRDir::DenumeratePointers(), C4ValueProviderCosR::DenumeratePointers(), C4ValueProviderSinR::DenumeratePointers(), C4ValueProviderCosV::DenumeratePointers(), C4ValueProviderSinV::DenumeratePointers(), and C4ValueProviderAction::DenumeratePointers().

48 {
49  assert(!fDenumerated || !data.ptr);
50 
51  assert(data.nptr < std::numeric_limits<int32_t>::max());
52  data.ptr = ::Objects.ObjectPointer(static_cast<int32_t>(data.nptr));
53 
54 #ifndef NDEBUG
55  fDenumerated = true;
56 #endif
57 }
bool fDenumerated
Definition: C4ObjectPtr.h:64
union C4ObjectPtr::@78 data
C4Object * ObjectPointer(int32_t iNumber)
C4GameObjects Objects
Definition: C4Globals.cpp:48

Here is the call graph for this function:

Here is the caller graph for this function:

C4ObjectPtr::operator C4Object * ( ) const
inline

Definition at line 60 of file C4ObjectPtr.h.

References data, and fDenumerated.

60 { assert(fDenumerated); return data.ptr; }
bool fDenumerated
Definition: C4ObjectPtr.h:64
union C4ObjectPtr::@78 data
bool C4ObjectPtr::operator! ( ) const
inline

Definition at line 43 of file C4ObjectPtr.h.

References data, and fDenumerated.

43 { assert(fDenumerated); return !data.ptr; }
bool fDenumerated
Definition: C4ObjectPtr.h:64
union C4ObjectPtr::@78 data
bool C4ObjectPtr::operator!= ( C4Object other) const
inline

Definition at line 46 of file C4ObjectPtr.h.

References data, and fDenumerated.

46 { assert(fDenumerated); return data.ptr != other; }
bool fDenumerated
Definition: C4ObjectPtr.h:64
union C4ObjectPtr::@78 data
bool C4ObjectPtr::operator!= ( const C4ObjectPtr other) const
inline

Definition at line 47 of file C4ObjectPtr.h.

References data, and fDenumerated.

47 { assert(fDenumerated == other.fDenumerated); return data.ptr != other.data.ptr; }
bool fDenumerated
Definition: C4ObjectPtr.h:64
union C4ObjectPtr::@78 data
C4Object& C4ObjectPtr::operator* ( ) const
inline

Definition at line 58 of file C4ObjectPtr.h.

References data, and fDenumerated.

58 { assert(fDenumerated); return *data.ptr; }
bool fDenumerated
Definition: C4ObjectPtr.h:64
union C4ObjectPtr::@78 data
C4Object* C4ObjectPtr::operator-> ( ) const
inline

Definition at line 59 of file C4ObjectPtr.h.

References data, and fDenumerated.

59 { assert(fDenumerated); return data.ptr; }
bool fDenumerated
Definition: C4ObjectPtr.h:64
union C4ObjectPtr::@78 data
C4ObjectPtr C4ObjectPtr::operator= ( C4Object object)
inline

Definition at line 49 of file C4ObjectPtr.h.

References data, and fDenumerated.

50  {
51 #ifndef NDEBUG
52  fDenumerated = true;
53 #endif
54  data.ptr = object;
55  return *this;
56  }
bool fDenumerated
Definition: C4ObjectPtr.h:64
union C4ObjectPtr::@78 data
bool C4ObjectPtr::operator== ( C4Object other) const
inline

Definition at line 44 of file C4ObjectPtr.h.

References data, and fDenumerated.

44 { assert(fDenumerated); return data.ptr == other; }
bool fDenumerated
Definition: C4ObjectPtr.h:64
union C4ObjectPtr::@78 data
bool C4ObjectPtr::operator== ( const C4ObjectPtr other) const
inline

Definition at line 45 of file C4ObjectPtr.h.

References data, and fDenumerated.

45 { assert(fDenumerated == other.fDenumerated); return data.ptr == other.data.ptr; }
bool fDenumerated
Definition: C4ObjectPtr.h:64
union C4ObjectPtr::@78 data

Member Data Documentation

bool C4ObjectPtr::fDenumerated
protected
const C4ObjectPtr C4ObjectPtr::Null
static

Definition at line 28 of file C4ObjectPtr.h.

Referenced by C4Player::CompileFunc(), and C4Object::CompileFunc().


The documentation for this class was generated from the following files: