1 // Copyright 2001-2019 Crytek GmbH / Crytek Group. All rights reserved.
5 #include "CrySerialization/BlackBox.h"
7 #include <CrySchematyc2/Script/IScriptFile.h>
8 #include <CrySchematyc2/Script/IScriptGraph.h>
9 #include <CrySchematyc2/Serialization/ISerializationContext.h>
13 namespace DocSerializationUtils
15 DECLARE_SHARED_POINTERS(IScriptElement
)
17 class CDocGraphFactory
// #SchematycTODO : Combine with CScriptElementFactory?
21 IDocGraphPtr
CreateGraph(IScriptFile
& file
, const SGUID
& guid
, const SGUID
& scopeGUID
, const char* szName
, EScriptGraphType type
, const SGUID
& contextGUID
);
24 // #SchematycTODO : Move to separate file .cpp and .h files and/or to IFramework?
25 // #SchematycTODO : Resolve disconnect between factory method used to construct elements during serialization and in place methods used when editing?
26 class CScriptElementFactory
30 CScriptElementFactory();
32 void SetDefaultElementType(EScriptElementType defaultElementType
);
33 IScriptElementPtr
CreateElement(IScriptFile
& file
, EScriptElementType elementType
);
34 IScriptElementPtr
CreateElement(Serialization::IArchive
& archive
, const char* szName
);
38 EScriptElementType m_defaultElementType
; // N.B. This is a hack to work around the fact that elements are located in discreet sections of each file. In future we should inline element type.
45 typedef std::vector
<size_t> DependencyIndices
;
51 void Serialize(Serialization::IArchive
& archive
);
53 IScriptElementPtr ptr
;
54 Serialization::SBlackBox blackBox
;
55 ESerializationPass serializationPass
;
56 DependencyIndices dependencyIndices
;
60 typedef std::vector
<SElement
> Elements
;
64 CInputBlock(IScriptFile
& file
);
66 void Serialize(Serialization::IArchive
& archive
);
67 void BuildElementHierarchy(IScriptElement
& root
);
68 void SortElementsByDependency();
69 Elements
& GetElements();
73 void AppendElements(Elements
& dst
, const Elements
& src
) const;
74 void EraseEmptyElements(Elements
&elements
) const;
75 void SortElementsByDependency(Elements
&elements
);
76 void VerifyElementDependencies(const Elements
&elements
);
84 extern CDocGraphFactory g_docGraphFactory
;
85 extern CScriptElementFactory g_scriptElementFactory
;