3DCoat Core API
The 3DCoat API documentation.
Loading...
Searching...
No Matches
ClassPtr< X > Class Template Reference

The pointer to the allocated class derived from the BaseClass. It allows serialization/presentation in UI the elements derived from the BaseClass. More...

#include <classlist.h>

Inheritance diagram for ClassPtr< X >:
BaseClass

Public Member Functions

virtual bool FullCopy (const void *SrcData, const void *SrcDataExtra, BaseClass *Dest, void *DestData, void *DestExtraPtr, CECopyContext *C) override
 Fast copy from one BaseClass to another. Names and types correspondence used to copy.
 
virtual void SaveBin (void *Data, void *Extra, BinStream *Out, Enumerator *ExDictionary, Enumerator *SkipList) override
 Save in binaly form. Use only for temporary storage in memory!!!
 
virtual void LoadBin (void *Data, void *Extra, BinStream *In, Enumerator *ExDictionary) override
 Load the class from the memory. Use only for temporary storage in memory!!!
 
X * Get ()
 
void Set (X *x)
 
virtual void reset_class (void *p)
 Clearing all registered content of the class. If DataPtr is nullptr, this class will be cleared.
 
void Clear ()
 
const char * GetClassName () const override
 return class name there if need. Usually you don't need, if you are using AUTONEW or SERIALIZE
 
int GetAmountOfElements () override
 return complete amount of elements. Even invisible, masked and non-serialized elements will be counted
 
virtual bool GetElement (BaseClassElement &res, int idx, const void *Ptr, const void *Extra) override
 
virtual int ExpandWith (const char *ElmName, void *base)
 Expand array with class ElmName.
 
virtual bool DelElement (int index)
 removes element if the operation supported
 
virtual bool CheckDirectCasting () const override
 
virtual bool ForceProperty ()
 
virtual void CountObjects (int &required_index, int *counter, HashSummator *hash, BaseClassElement *result, const std::function< bool(BaseClassElement *)> *ForEachElem, bool OnlyPointersMode) override
 This is the main function used for the access to class members. Each class that has SERIALIZE section creates this function automatically.
It may count members, return hash, give element-wise access to any member. Instead of keeping registered fields that routine gives fast dynamic access to any member.
If you making own container, you should create this function as well, othervice your class will not be serialized correctly even if you will make GetElement(...) function.
 
 AUTONEW (ClassPtr)
 
- Public Member Functions inherited from BaseClass
BaseClassGetRoot ()
 BaseClass is like a tree, and you always can get the root of the tree using this function.
 
 BaseClass (const BaseClass &)
 
virtual ~BaseClass ()
 virtual destructor
 
virtual DWORD GetClassMask ()
 Masking elements of class. Each member has mask. Element is serializable/visible only if (it's_mask & hosting_class_mask) != 0.
 
DWORD & ClassMask ()
 
void ForEach (const std::function< bool(BaseClassElement *el)> &fn, bool OnlyPointsers=false)
 Calls function for each class member. This function used in _EACH ... _EACH_END cycle.
 
virtual bool CopyBaseClass (BaseClass *Dest, bool Add=false)
 Copy base class to other class uning names correspondence.
 
virtual void Save (TagsList &xml, void *ClassPtr, void *Extra=NULL)
 Save class to the XML structure.
 
virtual bool Load (TagsList &xml, void *ClassPtr, void *Extra=NULL)
 Load the class from the XML structure.
 
virtual void UpdateHash (HashSummator &S, void *data=nullptr, void *extra=nullptr)
 returns hash value dependent on data fields of this class
 
virtual int GetAmountOfElementsInUI ()
 return amount of elements represented in UI
 
virtual int GetAmountOfElementsInXML ()
 return amount of elements taht will be stored in XML
 
virtual cStruct * pySerialize ()
 returns a list of python-generated properties for serialization and UI
 
virtual void RegisterMembers ()
 Reload this function to register members. Usually you don't need to do this if you are using any of SERIALIZE methods of registration.
 
virtual int GetClassSize () const
 return actual size of this class
 
virtual BaseClassnew_element () const
 construct pointer to class of the same type like this. Elements will not be copied into the new place
 
bool GetElementByName (const char *Name, void *Ptr, void *Extra, BaseClassElement &res, bool UI=false, bool Serialize=true)
 The function returns complete information about the member by it's name.
 
bool GetElementByNameAndType (const char *Name, const char *Type, void *Ptr, void *Extra, BaseClassElement &res, bool UI=false, bool Serialize=true)
 
void DeleteDefaultSubFields (TagsList &xml, void *ClassPtr, void *Extra=NULL)
 Short form saving. Fields that are unchanged in comparison to default will be skipped in XML.
 
virtual bool ShouldSaveInShortForm ()
 Return true if class should be saved in short form mandatory.
 
template<class Type = BaseClass>
bool valid () const
 call it to check if this BaseClass pointer is valid
 
template<>
bool valid () const
 
BaseClassauto_cast (void *ptr) const
 if class is directly castable the function returns ptr cased to BaseClass, othervice this pointrer returned. If NULL returned - something is wrong.
 
virtual bool ReadFromFile (const char *Name, bool very_safe_with_backup=false)
 Save the object to file or binary stream. Example.
 
virtual bool WriteToFile (const char *Name)
 
virtual bool WriteToFileIfChanged (const char *Name)
 
virtual void ToBS (BinStream &bs, bool IncludeLength)
 
virtual void FromBS (BinStream &bs)
 
virtual void ToBS (BinStream &bs, void *data, void *extra, bool IncludeLength)
 
virtual void FromBS (BinStream &bs, void *data, void *extra)
 
virtual void ToStr (comms::cStr &bs)
 
virtual void FromStr (const comms::cStr &bs)
 
virtual bool CheckIfFunction () const
 Special function for integrating in editor.
 
virtual int condition_call (void *ptr)
 return -1 to do nothing, 0 if you want to hide everything after this registered member, 1 if you want to show
 
virtual BaseClassGetParent () const
 
template<typename type >
type * FindParent ()
 
virtual void SetParent (BaseClass *Parent)
 set parent recursively
 
virtual void SimplySetParent (BaseClass *Parent)
 set parent directly to this, not affecting members
 
virtual bool MayBeParent ()
 
virtual bool CheckCompartabilityWith (const char *TypeName, int TypeSize)
 Checking for errors of registration.
 
virtual bool ProcessInEditor (BaseClass *Parent)
 Editor will call next function always when it is visible in tree. Return true if overriden.
 
virtual bool RenderInScene (BaseClass *Parent)
 Editor will call next function to render in-scene controls always when it is visible in tree. Return true if overriden.
 
virtual bool HandleKey (int code)
 Editor will call next function when key pressed.
 
virtual bool OnChangeMember (BaseClass *MembClass, void *MembPtr, void *MembExtra, const char *MembName)
 Editor will call it every time when member changes and editor is able to recognise it.
 
virtual void BeforeChangeMember (BaseClass *MembClass, void *MembPtr, void *MembExtra, const char *MembName)
 Editor will call it every time before the changes.
 
virtual int GetElementLevel (const char *EName)
 
virtual BaseWidget * OnCreateControlFromScratch (const ClassEditorContext &Context, Rct &Rect)
 Create completely own control for ClassEditor.
 
virtual void OnModifyControl (const char *FieldName, BaseWidget *W, ClassEditorContext &Context)
 Call for every member of registered class registered class.
 
virtual bool CanBeDragged (const char *MemberID, int &dx, int &dy)
 Use it for build a Drag & Drop element.
 
virtual bool CanAcceptDrag (const char *MemberID)
 
virtual bool OnStartDrag (const char *MemberID)
 
virtual bool OnEndDrag (const char *MemberID)
 
virtual bool OnAcceptDrag (BaseClass *DraggedItemParent, const char *DraggedMemberID, const char *AcceptorMemberID, iRct MyRect)
 
virtual bool UsePointerInHashCalculation ()
 
virtual bool SkipHash ()
 
virtual bool IsArray () const
 
virtual const char * GetCmdID ()
 
void SetParents ()
 set parents to this for all child members
 
void SetParentsSafe ()
 set parents to this for all child members, each child will be tested for validity
 
virtual void UpdateClassMembersAndMask (bool recursive)
 
virtual bool CallFromScript () const
 
virtual void CallFromScript (const bool &b)
 

Additional Inherited Members

- Static Public Member Functions inherited from BaseClass
static const char * GetCurrentSaveFile ()
 
static bool & UI_definition ()
 
static bool & Serialization ()
 
- Static Public Attributes inherited from BaseClass
static const char * CurrentSaveFile
 If user triggers saving class to file, last filename stored there.
 
static bool SaveInShortForm
 
- Protected Member Functions inherited from BaseClass
void test_presence_integrity ()
 
void register_this ()
 
void remove_this ()
 
- Static Protected Member Functions inherited from BaseClass
static std::mutex & get_bc_mutex ()
 mutex for register_this / remove_this
 
static uni_hash< _empty, cPtrDiff,(1<< 18), 2048 > & presence ()
 each BaseClass registered in this list
 
- Protected Attributes inherited from BaseClass
BaseClassParentBC
 pointer to the parent class in the tree
 
DWORD _ClassMask
 Result of GetClassMask() written there. GetClassMask() is not const, so can't use it in const functions. The field introduced to use masking in const functions.
 
bool bCallFromScript
 

Detailed Description

template<class X>
class ClassPtr< X >

The pointer to the allocated class derived from the BaseClass. It allows serialization/presentation in UI the elements derived from the BaseClass.

Template Parameters
X

Member Function Documentation

◆ CheckDirectCasting()

template<class X >
virtual bool ClassPtr< X >::CheckDirectCasting ( ) const
inlineoverridevirtual

BaseClass corresponds to some other data type. For example _int correctonds to int, etc... In this case you can't cast pointer to data to BaseClass*. But in some cases BaseClass may be directlt castable, for example if it has registered members, or it is ClassArray. This function is to define if class is directly castable.

Returns
Return true if void* ClassPtr may be directly casted to BaseClass*

Reimplemented from BaseClass.

◆ CountObjects()

template<class X >
virtual void ClassPtr< X >::CountObjects ( int & required_index,
int * counter,
HashSummator * hash,
BaseClassElement * result,
const std::function< bool(BaseClassElement *)> * ForEachElem,
bool OnlyPointersMode )
inlineoverridevirtual

This is the main function used for the access to class members. Each class that has SERIALIZE section creates this function automatically.
It may count members, return hash, give element-wise access to any member. Instead of keeping registered fields that routine gives fast dynamic access to any member.
If you making own container, you should create this function as well, othervice your class will not be serialized correctly even if you will make GetElement(...) function.

Parameters
required_indexIndex of required element if result != nullptr
counterif nonzero, the elements count returned there.
hashif nonzero, returns hash value for this class.
resultif nonzero, gives access to the member with index required_index.
ForEachElemif nonzero, the function will be called for each class element.
OnlyPointersModeIf true, the field name will not be filled for speed purposes.

Reimplemented from BaseClass.

◆ DelElement()

template<class X >
virtual bool ClassPtr< X >::DelElement ( int Index)
inlinevirtual

removes element if the operation supported

Reimplemented from BaseClass.

◆ ExpandWith()

template<class X >
virtual int ClassPtr< X >::ExpandWith ( const char * ElmName,
void * base )
inlinevirtual

Expand array with class ElmName.

Reimplemented from BaseClass.

◆ FullCopy()

template<class X >
virtual bool ClassPtr< X >::FullCopy ( const void * SrcData,
const void * SrcDataExtra,
BaseClass * Dest,
void * DestData,
void * DstDataExtra,
CECopyContext * C )
inlineoverridevirtual

Fast copy from one BaseClass to another. Names and types correspondence used to copy.

Parameters
SrcDataData data pointer
SrcDataExtraSrc extra
DestDestination class
DestDataDestination data
DstDataExtraDestination extra
Ccopy context
Returns
true if successful

Reimplemented from BaseClass.

◆ GetAmountOfElements()

template<class X >
int ClassPtr< X >::GetAmountOfElements ( )
inlineoverridevirtual

return complete amount of elements. Even invisible, masked and non-serialized elements will be counted

Reimplemented from BaseClass.

◆ GetClassName()

template<class X >
const char * ClassPtr< X >::GetClassName ( ) const
inlineoverridevirtual

return class name there if need. Usually you don't need, if you are using AUTONEW or SERIALIZE

Reimplemented from BaseClass.

◆ GetElement()

template<class X >
virtual bool ClassPtr< X >::GetElement ( BaseClassElement & res,
int idx,
const void * Ptr,
const void * Extra )
inlineoverridevirtual

\briefThe The function returns complete information about the member by it's index. If you want to walk through all members use _EACH ... _EACH_END loop.

Parameters
resAll data gathered there
idxIndex of the member
PtrPointer to data (if class is direcly castable it is equal to this, othervice it points to placement of data in memory). If NULL passed, this will be used
ExtraExtra data, used for enumerators and sliders (mostly)
Returns
return true if element exists and visible

Reimplemented from BaseClass.

◆ LoadBin()

template<class X >
virtual void ClassPtr< X >::LoadBin ( void * Data,
void * Extra,
BinStream * In,
Enumerator * ExDictionary )
inlineoverridevirtual

Load the class from the memory. Use only for temporary storage in memory!!!

Parameters
DataPointer to the class data
ExtraExtra data
Inbinary stream to read data from
ExDictionaryAdditional dictionary

Reimplemented from BaseClass.

◆ reset_class()

template<class X >
virtual void ClassPtr< X >::reset_class ( void * DataPtr)
inlinevirtual

Clearing all registered content of the class. If DataPtr is nullptr, this class will be cleared.

Reimplemented from BaseClass.

◆ SaveBin()

template<class X >
virtual void ClassPtr< X >::SaveBin ( void * Data,
void * Extra,
BinStream * Out,
Enumerator * ExDictionary,
Enumerator * SkipList )
inlineoverridevirtual

Save in binaly form. Use only for temporary storage in memory!!!

Parameters
Datadata pointer
Extraextra pointer
OutOutput stream
ExDictionaryDictionary for enumerators
SkipListSkip list for enumerators

Reimplemented from BaseClass.


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