6#include "BaseClassIO.h"
54struct BaseClassElement {
79 unsigned short CachedIndex;
81 void fill(
void* _Ptr,
void* _Extra,
bool _vis,
bool _ui,
bool OnlyPointersMode);
83 void reset(
bool initmask=
true);
99 friend BaseClassElement;
116 DWORD& ClassMask() {
return _ClassMask; }
134 virtual void CountObjects(
int& required_index,
int* counter, HashSummator* hash, BaseClassElement* result,
const std::function<
bool(BaseClassElement*)>* ForEachElem =
nullptr,
bool OnlyPointersMode =
false) { }
141 void ForEach(
const std::function<
bool(BaseClassElement* el)>& fn,
bool OnlyPointsers =
false);
175 virtual bool FullCopy(
const void* SrcData,
const void* SrcDataExtra,
BaseClass* Dest,
void* DestData,
void* DstDataExtra, CECopyContext* C);
184 virtual void SaveBin(
void* Data,
void* Extra, BinStream* Out, Enumerator* ExDictionary, Enumerator* SkipList);
192 virtual void LoadBin(
void* Data,
void* Extra, BinStream* In, Enumerator* ExDictionary);
200 virtual void UpdateHash(HashSummator& S,
void* data =
nullptr,
void* extra =
nullptr);
248 virtual bool GetElement(BaseClassElement& res,
int idx,
const void* Ptr =
nullptr,
const void* Extra =
nullptr);
257 bool GetElementByName(
const char* Name,
void* Ptr,
void* Extra, BaseClassElement& res,
bool UI =
false,
bool Serialize =
true);
258 bool GetElementByNameAndType(
const char* Name,
const char* Type,
void* Ptr,
void* Extra, BaseClassElement& res,
bool UI =
false,
bool Serialize =
true);
270 virtual int ExpandWith(
const char* ElmName,
void* base){
return -1; }
278 template<
class Type = BaseClass>
281 bool valid<BaseClass>()
const;
308 virtual bool ReadFromFile (
const char* Name,
bool very_safe_with_backup =
false);
309 virtual bool WriteToFile (
const char* Name);
310 virtual bool WriteToFileIfChanged (
const char* Name);
313 virtual void ToBS(BinStream& bs,
bool IncludeLength);
314 virtual void FromBS(BinStream& bs);
315 virtual void ToBS(BinStream& bs,
void* data,
void* extra,
bool IncludeLength);
316 virtual void FromBS(BinStream& bs,
void* data,
void* extra);
318 virtual void ToStr(comms::cStr& bs);
329 virtual BaseClass* GetParent()
const {
return ParentBC;}
330 template <
typename type> type* FindParent();
336 virtual bool MayBeParent() {
return true; }
368 virtual int GetElementLevel(
const char* EName){
return 0;}
389 virtual void OnModifyControl(
const char* FieldName, BaseWidget* W, ClassEditorContext& Context){};
395 virtual bool CanBeDragged(
const char* MemberID,
int& dx,
int& dy){
return false;}
401 virtual bool OnEndDrag(
const char* MemberID ){
return false; }
403 virtual bool OnAcceptDrag(
BaseClass* DraggedItemParent,
const char* DraggedMemberID,
const char* AcceptorMemberID, iRct MyRect ){
return false; }
404 virtual bool UsePointerInHashCalculation() {
return false; }
405 virtual bool SkipHash(){
return false;}
406 virtual bool IsArray()
const {
return false; }
407 virtual const char* GetCmdID(){
return NULL;}
414 static const char* GetCurrentSaveFile();
419 virtual void UpdateClassMembersAndMask(
bool recursive );
421 static bool SaveInShortForm;
423 virtual bool CallFromScript()
const {
return bCallFromScript; }
424 virtual void CallFromScript(
const bool& b) { bCallFromScript = b; }
426 static bool& UI_definition();
427 static bool& Serialization();
429 bool bCallFromScript;
430 void test_presence_integrity();
434 static uni_hash<_empty, cPtrDiff, (1 << 18), 2048>&
presence();
435 void register_this();
439 SG::SG_Object* sgObj;
441 template <
class T> T* toCastSGObj()
const {
442 return static_cast<T*
>(sgObj);
445 SG::SG_Object* GetSGObj()
const {
return sgObj; }
446 virtual void SetSGObj(SG::SG_Object* obj,
bool bInit =
false);
447 virtual void OnSetupSG() { ; }
448 virtual bool OnScriptRecorder(
BaseClass* MembClass,
void* MembPtr,
void* MembExtra,
const char* MembName);
453inline void HashSummator::operator+=(
BaseClass* value) {
Use this class for build a class for UI or serialization. see class_reg.h for details about the class...
Definition BaseClass.h:91
virtual bool CheckIfFunction() const
Special function for integrating in editor.
Definition BaseClass.h:325
bool valid() const
call it to check if this BaseClass pointer is valid
static std::mutex & get_bc_mutex()
mutex for register_this / remove_this
virtual void LoadBin(void *Data, void *Extra, BinStream *In, Enumerator *ExDictionary)
Load the class from the memory. Use only for temporary storage in memory!!!
virtual bool HandleKey(int code)
Editor will call next function when key pressed.
Definition BaseClass.h:355
virtual bool CopyBaseClass(BaseClass *Dest, bool Add=false)
Copy base class to other class uning names correspondence.
virtual bool ProcessInEditor(BaseClass *Parent)
Editor will call next function always when it is visible in tree. Return true if overriden.
Definition BaseClass.h:345
virtual BaseWidget * OnCreateControlFromScratch(const ClassEditorContext &Context, Rct &Rect)
Create completely own control for ClassEditor.
Definition BaseClass.h:379
virtual bool OnStartDrag(const char *MemberID)
Definition BaseClass.h:399
virtual bool CheckCompartabilityWith(const char *TypeName, int TypeSize)
Checking for errors of registration.
Definition BaseClass.h:339
virtual DWORD GetClassMask()
Masking elements of class. Each member has mask. Element is serializable/visible only if (it's_mask &...
Definition BaseClass.h:115
void SetParents()
set parents to this for all child members
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.
static const char * CurrentSaveFile
If user triggers saving class to file, last filename stored there.
Definition BaseClass.h:417
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 OnAcceptDrag(BaseClass *DraggedItemParent, const char *DraggedMemberID, const char *AcceptorMemberID, iRct MyRect)
Definition BaseClass.h:403
static uni_hash< _empty, cPtrDiff,(1<< 18), 2048 > & presence()
each BaseClass registered in this list
virtual bool ReadFromFile(const char *Name, bool very_safe_with_backup=false)
Save the object to file or binary stream. Example.
virtual int GetAmountOfElementsInUI()
return amount of elements represented in UI
virtual void FromStr(const comms::cStr &bs)
virtual bool DelElement(int Index)
removes element if the operation supported
Definition BaseClass.h:272
virtual cStruct * pySerialize()
returns a list of python-generated properties for serialization and UI
Definition BaseClass.h:210
virtual int GetClassSize() const
return actual size of this class
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.
Definition BaseClass.h:361
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.
BaseClass * GetRoot()
BaseClass is like a tree, and you always can get the root of the tree using this function.
virtual void BeforeChangeMember(BaseClass *MembClass, void *MembPtr, void *MembExtra, const char *MembName)
Editor will call it every time before the changes.
Definition BaseClass.h:367
virtual BaseClass * new_element() const
construct pointer to class of the same type like this. Elements will not be copied into the new place
virtual bool Load(TagsList &xml, void *ClassPtr, void *Extra=NULL)
Load the class from the XML structure.
virtual bool ShouldSaveInShortForm()
Return true if class should be saved in short form mandatory.
Definition BaseClass.h:265
virtual bool CanBeDragged(const char *MemberID, int &dx, int &dy)
Use it for build a Drag & Drop element.
Definition BaseClass.h:395
virtual void reset_class(void *DataPtr=nullptr)
Clearing all registered content of the class. If DataPtr is nullptr, this class will be cleared.
virtual void OnModifyControl(const char *FieldName, BaseWidget *W, ClassEditorContext &Context)
Call for every member of registered class registered class.
Definition BaseClass.h:389
virtual void SetParent(BaseClass *Parent)
set parent recursively
virtual const char * GetClassName() const
return class name there if need. Usually you don't need, if you are using AUTONEW or SERIALIZE
virtual void SaveBin(void *Data, void *Extra, BinStream *Out, Enumerator *ExDictionary, Enumerator *SkipList)
Save in binaly form. Use only for temporary storage in memory!!!
virtual int GetAmountOfElements()
return complete amount of elements. Even invisible, masked and non-serialized elements will be counte...
virtual bool CanAcceptDrag(const char *MemberID)
Definition BaseClass.h:397
virtual void Save(TagsList &xml, void *ClassPtr, void *Extra=NULL)
Save class to the XML structure.
DWORD _ClassMask
Result of GetClassMask() written there. GetClassMask() is not const, so can't use it in const functio...
Definition BaseClass.h:96
virtual ~BaseClass()
virtual destructor
virtual int GetAmountOfElementsInXML()
return amount of elements taht will be stored in XML
virtual bool RenderInScene(BaseClass *Parent)
Editor will call next function to render in-scene controls always when it is visible in tree....
Definition BaseClass.h:349
virtual void CountObjects(int &required_index, int *counter, HashSummator *hash, BaseClassElement *result, const std::function< bool(BaseClassElement *)> *ForEachElem=nullptr, bool OnlyPointersMode=false)
This is the main function used for the access to class members. Each class that has SERIALIZE section...
Definition BaseClass.h:134
virtual bool GetElement(BaseClassElement &res, int idx, const void *Ptr=nullptr, const void *Extra=nullptr)
virtual void SimplySetParent(BaseClass *Parent)
set parent directly to this, not affecting members
virtual bool FullCopy(const void *SrcData, const void *SrcDataExtra, BaseClass *Dest, void *DestData, void *DstDataExtra, CECopyContext *C)
Fast copy from one BaseClass to another. Names and types correspondence used to copy.
void SetParentsSafe()
set parents to this for all child members, each child will be tested for validity
BaseClass * auto_cast(void *ptr) const
if class is directly castable the function returns ptr cased to BaseClass, othervice this pointrer re...
virtual bool OnEndDrag(const char *MemberID)
Definition BaseClass.h:401
virtual bool CheckDirectCasting() const
Definition BaseClass.h:227
BaseClass * ParentBC
pointer to the parent class in the tree
Definition BaseClass.h:94
virtual int ExpandWith(const char *ElmName, void *base)
Expand array with class ElmName.
Definition BaseClass.h:270
virtual void UpdateHash(HashSummator &S, void *data=nullptr, void *extra=nullptr)
returns hash value dependent on data fields of this class
virtual int condition_call(void *ptr)
return -1 to do nothing, 0 if you want to hide everything after this registered member,...
Definition BaseClass.h:327
virtual void RegisterMembers()
Reload this function to register members. Usually you don't need to do this if you are using any of S...
The pointer to the allocated class derived from the BaseClass. It allows serialization/presentation i...
Definition classlist.h:565