From 2b36a623513e506d012c14e53260a454a6842ba9 Mon Sep 17 00:00:00 2001 From: Dinand Vanvelzen Date: Sat, 3 Aug 2024 11:19:48 -0500 Subject: [PATCH] - VFS: Now takes app shutdown into account as earlier trigger for plugin unloads to help with clean shutdowns - CORE: Added some DataNode related classes related to upcoming restructure for data node plugins, not used yet - GucefArchiver: Call app stop before exit to allow for a clean shutdown --- platform/gucefCORE/Android.mk | 2 + platform/gucefCORE/CMakeLists.txt | 4 + platform/gucefCORE/include/CDataNode.h | 4 +- .../gucefCORE_CDataNodeDocumentBuilder.h | 95 ++++++++ .../gucefCORE_CIDocumentParserCallbacks.h | 95 ++++++++ platform/gucefCORE/premake4.lua | 4 + platform/gucefCORE/premake5.lua | 4 + .../gucefCORE_CDataNodeDocumentBuilder.cpp | 210 ++++++++++++++++++ .../gucefCORE_CIDocumentParserCallbacks.cpp | 79 +++++++ platform/gucefKAITAI/Android.mk | 1 + platform/gucefKAITAI/CMakeLists.txt | 2 + platform/gucefKAITAI/premake4.lua | 2 + platform/gucefKAITAI/premake5.lua | 2 + platform/gucefVFS/include/gucefVFS_CVFS.h | 4 + platform/gucefVFS/src/gucefVFS_CVFS.cpp | 23 ++ tools/GucefArchiver/src/main.cpp | 6 + 16 files changed, 535 insertions(+), 2 deletions(-) create mode 100644 platform/gucefCORE/include/gucefCORE_CDataNodeDocumentBuilder.h create mode 100644 platform/gucefCORE/include/gucefCORE_CIDocumentParserCallbacks.h create mode 100644 platform/gucefCORE/src/gucefCORE_CDataNodeDocumentBuilder.cpp create mode 100644 platform/gucefCORE/src/gucefCORE_CIDocumentParserCallbacks.cpp diff --git a/platform/gucefCORE/Android.mk b/platform/gucefCORE/Android.mk index a52c36f3c..a8e89a353 100644 --- a/platform/gucefCORE/Android.mk +++ b/platform/gucefCORE/Android.mk @@ -142,6 +142,7 @@ LOCAL_SRC_FILES := \ src/gucefCORE_CDStoreBinaryCodec.cpp \ src/gucefCORE_CDataNodeBinarySerializer.cpp \ src/gucefCORE_CDataNodeDefinition.cpp \ + src/gucefCORE_CDataNodeDocumentBuilder.cpp \ src/gucefCORE_CDataNodeSerializableDataNode.cpp \ src/gucefCORE_CDataNodeSerializableSettings.cpp \ src/gucefCORE_CDate.cpp \ @@ -163,6 +164,7 @@ LOCAL_SRC_FILES := \ src/gucefCORE_CIDataNodeSerializableTaskData.cpp \ src/gucefCORE_CIDate.cpp \ src/gucefCORE_CIDirectoryWatcher.cpp \ + src/gucefCORE_CIDocumentParserCallbacks.cpp \ src/gucefCORE_CIEnumerable.cpp \ src/gucefCORE_CIEventHandlerFunctorBase.cpp \ src/gucefCORE_CIFunction.cpp \ diff --git a/platform/gucefCORE/CMakeLists.txt b/platform/gucefCORE/CMakeLists.txt index 74d2ab62a..3da0822af 100644 --- a/platform/gucefCORE/CMakeLists.txt +++ b/platform/gucefCORE/CMakeLists.txt @@ -148,6 +148,7 @@ set( HEADER_FILES include/gucefCORE_CDStoreBinaryCodec.h include/gucefCORE_CDataNodeBinarySerializer.h include/gucefCORE_CDataNodeDefinition.h + include/gucefCORE_CDataNodeDocumentBuilder.h include/gucefCORE_CDataNodeSerializableDataNode.h include/gucefCORE_CDataNodeSerializableSettings.h include/gucefCORE_CDate.h @@ -171,6 +172,7 @@ set( HEADER_FILES include/gucefCORE_CIDataNodeSerializableTaskData.h include/gucefCORE_CIDate.h include/gucefCORE_CIDirectoryWatcher.h + include/gucefCORE_CIDocumentParserCallbacks.h include/gucefCORE_CIEnumerable.h include/gucefCORE_CIEventHandlerFunctorBase.h include/gucefCORE_CIFunction.h @@ -388,6 +390,7 @@ set( SOURCE_FILES src/gucefCORE_CDStoreBinaryCodec.cpp src/gucefCORE_CDataNodeBinarySerializer.cpp src/gucefCORE_CDataNodeDefinition.cpp + src/gucefCORE_CDataNodeDocumentBuilder.cpp src/gucefCORE_CDataNodeSerializableDataNode.cpp src/gucefCORE_CDataNodeSerializableSettings.cpp src/gucefCORE_CDate.cpp @@ -409,6 +412,7 @@ set( SOURCE_FILES src/gucefCORE_CIDataNodeSerializableTaskData.cpp src/gucefCORE_CIDate.cpp src/gucefCORE_CIDirectoryWatcher.cpp + src/gucefCORE_CIDocumentParserCallbacks.cpp src/gucefCORE_CIEnumerable.cpp src/gucefCORE_CIEventHandlerFunctorBase.cpp src/gucefCORE_CIFunction.cpp diff --git a/platform/gucefCORE/include/CDataNode.h b/platform/gucefCORE/include/CDataNode.h index 10f3cc67a..19829eb1a 100644 --- a/platform/gucefCORE/include/CDataNode.h +++ b/platform/gucefCORE/include/CDataNode.h @@ -82,8 +82,8 @@ class GUCEF_CORE_PUBLIC_CPP CDataNode : public CIEnumerable { public: - typedef std::vector< CString, gucef_allocator< CString > > TStringVector; - typedef std::set< CString, std::less< CString >, gucef_allocator< CString > > TStringSet; + typedef CString::StringVector TStringVector; + typedef CString::StringSet TStringSet; typedef std::pair< const CString, CVariant > TKeyValuePair; typedef std::set< CDataNode*, std::less< CDataNode* >, gucef_allocator< CDataNode* > > TDataNodeSet; typedef std::list< CDataNode*, gucef_allocator< CDataNode* > > TDataNodeList; diff --git a/platform/gucefCORE/include/gucefCORE_CDataNodeDocumentBuilder.h b/platform/gucefCORE/include/gucefCORE_CDataNodeDocumentBuilder.h new file mode 100644 index 000000000..bd1e3c22c --- /dev/null +++ b/platform/gucefCORE/include/gucefCORE_CDataNodeDocumentBuilder.h @@ -0,0 +1,95 @@ +/* + * gucefCORE: GUCEF module providing O/S abstraction and generic solutions + * + * Copyright (C) 1998 - 2024. Dinand Vanvelzen + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef GUCEF_CORE_CDATANODEDOCUMENTBUILDER_H +#define GUCEF_CORE_CDATANODEDOCUMENTBUILDER_H + +/*-------------------------------------------------------------------------// +// // +// INCLUDES // +// // +//-------------------------------------------------------------------------*/ + +#ifndef GUCEF_CORE_CIDOCUMENTPARSERCALLBACKS_H +#include "gucefCORE_CIDocumentParserCallbacks.h" +#define GUCEF_CORE_CIDOCUMENTPARSERCALLBACKS_H +#endif /* GUCEF_CORE_CIDOCUMENTPARSERCALLBACKS_H ? */ + +#ifndef GUCEF_CORE_CDATANODE_H +#include "CDataNode.h" +#define GUCEF_CORE_CDATANODE_H +#endif /* GUCEF_CORE_CDATANODE_H ? */ + +/*-------------------------------------------------------------------------// +// // +// NAMESPACE // +// // +//-------------------------------------------------------------------------*/ + +namespace GUCEF { +namespace CORE { + +/*-------------------------------------------------------------------------// +// // +// CLASSES // +// // +//-------------------------------------------------------------------------*/ + +/** + * Implementation which uses document parser callbacks to contruct a DataNode class based tree + */ +class GUCEF_CORE_PUBLIC_CPP CDataNodeDocumentBuilder : public CIDocumentParserCallbacks +{ + public: + + CDataNodeDocumentBuilder( void ); + CDataNodeDocumentBuilder( const CDataNodeDocumentBuilder& src ); + virtual ~CDataNodeDocumentBuilder(); + CDataNodeDocumentBuilder& operator=( const CDataNodeDocumentBuilder& src ); + + virtual void OnDocumentBegin( void ) GUCEF_VIRTUAL_OVERRIDE; + virtual void OnDocumentEnd( void ) GUCEF_VIRTUAL_OVERRIDE; + virtual void OnNodeBegin( const CVariant& nodeId, int nodeType ) GUCEF_VIRTUAL_OVERRIDE; + virtual void OnNodeEnd( const CVariant& nodeId ) GUCEF_VIRTUAL_OVERRIDE; + virtual void OnNodeAttribute( const CVariant& nodeId, const CVariant& attributeId, const CVariant& attributeValue ) GUCEF_VIRTUAL_OVERRIDE; + virtual void OnNodeValue( const CVariant& nodeId, const CVariant& nodeValue ) GUCEF_VIRTUAL_OVERRIDE; + virtual void OnNodeChildrenBegin( const CVariant& nodeId ) GUCEF_VIRTUAL_OVERRIDE; + virtual void OnNodeChildrenEnd( const CVariant& nodeId ) GUCEF_VIRTUAL_OVERRIDE; + virtual void OnParseError( Int32 errorCode, const CString& description ) GUCEF_VIRTUAL_OVERRIDE; + + CDataNode document; + + private: + + CDataNode* m_nodeCursor; +}; + +/*-------------------------------------------------------------------------// +// // +// NAMESPACE // +// // +//-------------------------------------------------------------------------*/ + +}; /* namespace CORE */ +}; /* namespace GUCEF */ + +/*-------------------------------------------------------------------------*/ + +#endif /* GUCEF_CORE_CDATANODEDOCUMENTBUILDER_H ? */ + +/*-------------------------------------------------------------------------*/ diff --git a/platform/gucefCORE/include/gucefCORE_CIDocumentParserCallbacks.h b/platform/gucefCORE/include/gucefCORE_CIDocumentParserCallbacks.h new file mode 100644 index 000000000..e760e9e61 --- /dev/null +++ b/platform/gucefCORE/include/gucefCORE_CIDocumentParserCallbacks.h @@ -0,0 +1,95 @@ +/* + * gucefCORE: GUCEF module providing O/S abstraction and generic solutions + * + * Copyright (C) 1998 - 2024. Dinand Vanvelzen + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef GUCEF_CORE_CIDOCUMENTPARSERCALLBACKS_H +#define GUCEF_CORE_CIDOCUMENTPARSERCALLBACKS_H + +/*-------------------------------------------------------------------------// +// // +// INCLUDES // +// // +//-------------------------------------------------------------------------*/ + +#ifndef GUCEF_CORE_CSTRING_H +#include "gucefCORE_CString.h" /* framework string implementation */ +#define GUCEF_CORE_CSTRING_H +#endif /* GUCEF_CORE_CSTRING_H ? */ + +#ifndef GUCEF_CORE_CVARIANT_H +#include "gucefCORE_CVariant.h" /* framework variant implementation */ +#define GUCEF_CORE_CVARIANT_H +#endif /* GUCEF_CORE_CVARIANT_H ? */ + +/*-------------------------------------------------------------------------// +// // +// NAMESPACE // +// // +//-------------------------------------------------------------------------*/ + +namespace GUCEF { +namespace CORE { + +/*-------------------------------------------------------------------------// +// // +// CLASSES // +// // +//-------------------------------------------------------------------------*/ + +/** + * Interface class for document parse callbacks + * In XML lingo these are referred to as SAX parsers + * + * Implementing this type of interface allows you to interpret a varied range of schema formats + * due to the abstraction provided. You dont need to know if you are dealing with a JSON or XML or YAML or whatever document + * What matters is the information contained within the document itself, which can be accessed through this type of parser + */ +class GUCEF_CORE_PUBLIC_CPP CIDocumentParserCallbacks +{ + public: + + CIDocumentParserCallbacks( void ); + CIDocumentParserCallbacks( const CIDocumentParserCallbacks& src ); + virtual ~CIDocumentParserCallbacks(); + CIDocumentParserCallbacks& operator=( const CIDocumentParserCallbacks& src ); + + virtual void OnDocumentBegin( void ) = 0; + virtual void OnDocumentEnd( void ) = 0; + virtual void OnNodeBegin( const CVariant& nodeId, int nodeType ) = 0; + virtual void OnNodeEnd( const CVariant& nodeId ) = 0; + virtual void OnNodeAttribute( const CVariant& nodeId, const CVariant& attributeId, const CVariant& attributeValue ) = 0; + virtual void OnNodeValue( const CVariant& nodeId, const CVariant& nodeValue ) = 0; + virtual void OnNodeChildrenBegin( const CVariant& nodeId ) = 0; + virtual void OnNodeChildrenEnd( const CVariant& nodeId ) = 0; + virtual void OnParseError( Int32 errorCode, const CString& description ) = 0; + +}; + +/*-------------------------------------------------------------------------// +// // +// NAMESPACE // +// // +//-------------------------------------------------------------------------*/ + +}; /* namespace CORE */ +}; /* namespace GUCEF */ + +/*-------------------------------------------------------------------------*/ + +#endif /* GUCEF_CORE_CIDOCUMENTPARSERCALLBACKS_H ? */ + +/*-------------------------------------------------------------------------*/ diff --git a/platform/gucefCORE/premake4.lua b/platform/gucefCORE/premake4.lua index dfda573d0..b4fa8a360 100644 --- a/platform/gucefCORE/premake4.lua +++ b/platform/gucefCORE/premake4.lua @@ -181,6 +181,7 @@ files( { "include/gucefCORE_CDStoreBinaryCodec.h", "include/gucefCORE_CDataNodeBinarySerializer.h", "include/gucefCORE_CDataNodeDefinition.h", + "include/gucefCORE_CDataNodeDocumentBuilder.h", "include/gucefCORE_CDataNodeSerializableDataNode.h", "include/gucefCORE_CDataNodeSerializableSettings.h", "include/gucefCORE_CDate.h", @@ -204,6 +205,7 @@ files( { "include/gucefCORE_CIDataNodeSerializableTaskData.h", "include/gucefCORE_CIDate.h", "include/gucefCORE_CIDirectoryWatcher.h", + "include/gucefCORE_CIDocumentParserCallbacks.h", "include/gucefCORE_CIEnumerable.h", "include/gucefCORE_CIEventHandlerFunctorBase.h", "include/gucefCORE_CIFunction.h", @@ -425,6 +427,7 @@ files( { "src/gucefCORE_CDStoreBinaryCodec.cpp", "src/gucefCORE_CDataNodeBinarySerializer.cpp", "src/gucefCORE_CDataNodeDefinition.cpp", + "src/gucefCORE_CDataNodeDocumentBuilder.cpp", "src/gucefCORE_CDataNodeSerializableDataNode.cpp", "src/gucefCORE_CDataNodeSerializableSettings.cpp", "src/gucefCORE_CDate.cpp", @@ -446,6 +449,7 @@ files( { "src/gucefCORE_CIDataNodeSerializableTaskData.cpp", "src/gucefCORE_CIDate.cpp", "src/gucefCORE_CIDirectoryWatcher.cpp", + "src/gucefCORE_CIDocumentParserCallbacks.cpp", "src/gucefCORE_CIEnumerable.cpp", "src/gucefCORE_CIEventHandlerFunctorBase.cpp", "src/gucefCORE_CIFunction.cpp", diff --git a/platform/gucefCORE/premake5.lua b/platform/gucefCORE/premake5.lua index 29828ea75..65e36e67d 100644 --- a/platform/gucefCORE/premake5.lua +++ b/platform/gucefCORE/premake5.lua @@ -181,6 +181,7 @@ files( { "include/gucefCORE_CDStoreBinaryCodec.h", "include/gucefCORE_CDataNodeBinarySerializer.h", "include/gucefCORE_CDataNodeDefinition.h", + "include/gucefCORE_CDataNodeDocumentBuilder.h", "include/gucefCORE_CDataNodeSerializableDataNode.h", "include/gucefCORE_CDataNodeSerializableSettings.h", "include/gucefCORE_CDate.h", @@ -204,6 +205,7 @@ files( { "include/gucefCORE_CIDataNodeSerializableTaskData.h", "include/gucefCORE_CIDate.h", "include/gucefCORE_CIDirectoryWatcher.h", + "include/gucefCORE_CIDocumentParserCallbacks.h", "include/gucefCORE_CIEnumerable.h", "include/gucefCORE_CIEventHandlerFunctorBase.h", "include/gucefCORE_CIFunction.h", @@ -425,6 +427,7 @@ files( { "src/gucefCORE_CDStoreBinaryCodec.cpp", "src/gucefCORE_CDataNodeBinarySerializer.cpp", "src/gucefCORE_CDataNodeDefinition.cpp", + "src/gucefCORE_CDataNodeDocumentBuilder.cpp", "src/gucefCORE_CDataNodeSerializableDataNode.cpp", "src/gucefCORE_CDataNodeSerializableSettings.cpp", "src/gucefCORE_CDate.cpp", @@ -446,6 +449,7 @@ files( { "src/gucefCORE_CIDataNodeSerializableTaskData.cpp", "src/gucefCORE_CIDate.cpp", "src/gucefCORE_CIDirectoryWatcher.cpp", + "src/gucefCORE_CIDocumentParserCallbacks.cpp", "src/gucefCORE_CIEnumerable.cpp", "src/gucefCORE_CIEventHandlerFunctorBase.cpp", "src/gucefCORE_CIFunction.cpp", diff --git a/platform/gucefCORE/src/gucefCORE_CDataNodeDocumentBuilder.cpp b/platform/gucefCORE/src/gucefCORE_CDataNodeDocumentBuilder.cpp new file mode 100644 index 000000000..a63aa66d3 --- /dev/null +++ b/platform/gucefCORE/src/gucefCORE_CDataNodeDocumentBuilder.cpp @@ -0,0 +1,210 @@ +/* + * gucefCORE: GUCEF module providing O/S abstraction and generic solutions + * + * Copyright (C) 1998 - 2024. Dinand Vanvelzen + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*-------------------------------------------------------------------------// +// // +// INCLUDES // +// // +//-------------------------------------------------------------------------*/ + +#include "gucefCORE_CDataNodeDocumentBuilder.h" + +/*-------------------------------------------------------------------------// +// // +// NAMESPACE // +// // +//-------------------------------------------------------------------------*/ + +namespace GUCEF { +namespace CORE { + +/*-------------------------------------------------------------------------// +// // +// IMPLEMENTATION // +// // +//-------------------------------------------------------------------------*/ + +CDataNodeDocumentBuilder::CDataNodeDocumentBuilder( void ) + : CIDocumentParserCallbacks() + , document() + , m_nodeCursor( GUCEF_NULL ) +{GUCEF_TRACE; + +} + +/*-------------------------------------------------------------------------*/ + +CDataNodeDocumentBuilder::CDataNodeDocumentBuilder( const CDataNodeDocumentBuilder& src ) + : CIDocumentParserCallbacks() + , document( src.document ) + , m_nodeCursor( GUCEF_NULL ) +{GUCEF_TRACE; + +} + +/*-------------------------------------------------------------------------*/ + +CDataNodeDocumentBuilder::~CDataNodeDocumentBuilder() +{GUCEF_TRACE; + + m_nodeCursor = GUCEF_NULL; + document.Clear(); +} + +/*-------------------------------------------------------------------------*/ + +CDataNodeDocumentBuilder& +CDataNodeDocumentBuilder::operator=( const CDataNodeDocumentBuilder& src ) +{GUCEF_TRACE; + + if ( this != &src ) + { + document = src.document; + } + return *this; +} + +/*-------------------------------------------------------------------------*/ + +void +CDataNodeDocumentBuilder::OnDocumentBegin( void ) +{GUCEF_TRACE; + + m_nodeCursor = GUCEF_NULL; +} + +/*-------------------------------------------------------------------------*/ + +void +CDataNodeDocumentBuilder::OnDocumentEnd( void ) +{GUCEF_TRACE; + + m_nodeCursor = GUCEF_NULL; +} + +/*-------------------------------------------------------------------------*/ + +void +CDataNodeDocumentBuilder::OnNodeBegin( const CVariant& nodeId, int nodeType ) +{GUCEF_TRACE; + + if ( GUCEF_NULL != m_nodeCursor ) + { + m_nodeCursor = m_nodeCursor->AddChild( nodeId, nodeType ); + return; + } + + // First node + m_nodeCursor = &document; + m_nodeCursor->SetName( nodeId ); + m_nodeCursor->SetNodeType( nodeType ); +} + +/*-------------------------------------------------------------------------*/ + +void +CDataNodeDocumentBuilder::OnNodeEnd( const CVariant& nodeId ) +{GUCEF_TRACE; + + if ( GUCEF_NULL != m_nodeCursor ) + { + m_nodeCursor = m_nodeCursor->GetParent(); + } +} + +/*-------------------------------------------------------------------------*/ + +void +CDataNodeDocumentBuilder::OnNodeAttribute( const CVariant& nodeId , + const CVariant& attributeId , + const CVariant& attributeValue ) +{GUCEF_TRACE; + + if ( GUCEF_NULL != m_nodeCursor ) + { + if ( attributeValue != CVariant::Empty ) + { + if ( attributeId != CVariant::Empty ) + { + m_nodeCursor->SetAttribute( attributeId, attributeValue ); + } + else + { + if ( GUCEF_DATATYPE_ARRAY == m_nodeCursor->GetNodeType() ) + m_nodeCursor->AddValueAsChild( attributeValue ); + else + m_nodeCursor->SetValue( attributeValue ); + } + } + } +} + +/*-------------------------------------------------------------------------*/ + +void +CDataNodeDocumentBuilder::OnNodeValue( const CVariant& nodeId , + const CVariant& nodeValue ) +{GUCEF_TRACE; + + if ( GUCEF_NULL != m_nodeCursor ) + { + if ( nodeValue != CVariant::Empty ) + { + if ( GUCEF_DATATYPE_ARRAY == m_nodeCursor->GetNodeType() ) + m_nodeCursor->AddValueAsChild( nodeValue ); + else + m_nodeCursor->SetValue( nodeValue ); + } + } +} + +/*-------------------------------------------------------------------------*/ + +void +CDataNodeDocumentBuilder::OnNodeChildrenBegin( const CVariant& nodeId ) +{GUCEF_TRACE; + +} + +/*-------------------------------------------------------------------------*/ + +void +CDataNodeDocumentBuilder::OnNodeChildrenEnd( const CVariant& nodeId ) +{GUCEF_TRACE; + +} + +/*-------------------------------------------------------------------------*/ + +void +CDataNodeDocumentBuilder::OnParseError( Int32 errorCode , + const CString& description ) +{GUCEF_TRACE; + +} + +/*-------------------------------------------------------------------------// +// // +// NAMESPACE // +// // +//-------------------------------------------------------------------------*/ + +}; /* namespace CORE */ +}; /* namespace GUCEF */ + +/*-------------------------------------------------------------------------*/ diff --git a/platform/gucefCORE/src/gucefCORE_CIDocumentParserCallbacks.cpp b/platform/gucefCORE/src/gucefCORE_CIDocumentParserCallbacks.cpp new file mode 100644 index 000000000..29d3e4e86 --- /dev/null +++ b/platform/gucefCORE/src/gucefCORE_CIDocumentParserCallbacks.cpp @@ -0,0 +1,79 @@ +/* + * gucefCORE: GUCEF module providing O/S abstraction and generic solutions + * + * Copyright (C) 1998 - 2024. Dinand Vanvelzen + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/*-------------------------------------------------------------------------// +// // +// INCLUDES // +// // +//-------------------------------------------------------------------------*/ + +#include "gucefCORE_CIDocumentParserCallbacks.h" + +/*-------------------------------------------------------------------------// +// // +// NAMESPACE // +// // +//-------------------------------------------------------------------------*/ + +namespace GUCEF { +namespace CORE { + +/*-------------------------------------------------------------------------// +// // +// IMPLEMENTATION // +// // +//-------------------------------------------------------------------------*/ + +CIDocumentParserCallbacks::CIDocumentParserCallbacks( void ) +{GUCEF_TRACE; + +} + +/*-------------------------------------------------------------------------*/ + +CIDocumentParserCallbacks::CIDocumentParserCallbacks( const CIDocumentParserCallbacks& src ) +{GUCEF_TRACE; + +} + +/*-------------------------------------------------------------------------*/ + +CIDocumentParserCallbacks::~CIDocumentParserCallbacks() +{GUCEF_TRACE; + +} + +/*-------------------------------------------------------------------------*/ + +CIDocumentParserCallbacks& +CIDocumentParserCallbacks::operator=( const CIDocumentParserCallbacks& src ) +{GUCEF_TRACE; + + return *this; +} + +/*-------------------------------------------------------------------------// +// // +// NAMESPACE // +// // +//-------------------------------------------------------------------------*/ + +}; /* namespace CORE */ +}; /* namespace GUCEF */ + +/*-------------------------------------------------------------------------*/ diff --git a/platform/gucefKAITAI/Android.mk b/platform/gucefKAITAI/Android.mk index dbc286044..06145e321 100644 --- a/platform/gucefKAITAI/Android.mk +++ b/platform/gucefKAITAI/Android.mk @@ -29,6 +29,7 @@ LOCAL_SRC_FILES := \ src/gucefKAITAI_CKaitaiSchemaEnumDefinition.cpp \ src/gucefKAITAI_CKaitaiSchemaFieldDefinition.cpp \ src/gucefKAITAI_CKaitaiSchemaRegistry.cpp \ + src/gucefKAITAI_CKaitaiSerializer.cpp \ src/gucefKAITAI_CModule.cpp LOCAL_C_INCLUDES := \ diff --git a/platform/gucefKAITAI/CMakeLists.txt b/platform/gucefKAITAI/CMakeLists.txt index c0facff52..f48ee9e1b 100644 --- a/platform/gucefKAITAI/CMakeLists.txt +++ b/platform/gucefKAITAI/CMakeLists.txt @@ -20,6 +20,7 @@ set( HEADER_FILES includes/gucefKAITAI_CKaitaiSchemaEnumDefinition.h includes/gucefKAITAI_CKaitaiSchemaFieldDefinition.h includes/gucefKAITAI_CKaitaiSchemaRegistry.h + includes/gucefKAITAI_CKaitaiSerializer.h includes/gucefKAITAI_CModule.h includes/gucefKAITAI_ETypes.h includes/gucefKAITAI_config.h @@ -34,6 +35,7 @@ set( SOURCE_FILES src/gucefKAITAI_CKaitaiSchemaEnumDefinition.cpp src/gucefKAITAI_CKaitaiSchemaFieldDefinition.cpp src/gucefKAITAI_CKaitaiSchemaRegistry.cpp + src/gucefKAITAI_CKaitaiSerializer.cpp src/gucefKAITAI_CModule.cpp ) diff --git a/platform/gucefKAITAI/premake4.lua b/platform/gucefKAITAI/premake4.lua index 261e6d6f1..5e845c9cc 100644 --- a/platform/gucefKAITAI/premake4.lua +++ b/platform/gucefKAITAI/premake4.lua @@ -48,6 +48,7 @@ files( { "includes/gucefKAITAI_CKaitaiSchemaEnumDefinition.h", "includes/gucefKAITAI_CKaitaiSchemaFieldDefinition.h", "includes/gucefKAITAI_CKaitaiSchemaRegistry.h", + "includes/gucefKAITAI_CKaitaiSerializer.h", "includes/gucefKAITAI_CModule.h", "includes/gucefKAITAI_ETypes.h", "includes/gucefKAITAI_config.h", @@ -66,6 +67,7 @@ files( { "src/gucefKAITAI_CKaitaiSchemaEnumDefinition.cpp", "src/gucefKAITAI_CKaitaiSchemaFieldDefinition.cpp", "src/gucefKAITAI_CKaitaiSchemaRegistry.cpp", + "src/gucefKAITAI_CKaitaiSerializer.cpp", "src/gucefKAITAI_CModule.cpp" } ) diff --git a/platform/gucefKAITAI/premake5.lua b/platform/gucefKAITAI/premake5.lua index 395590678..17b5080a5 100644 --- a/platform/gucefKAITAI/premake5.lua +++ b/platform/gucefKAITAI/premake5.lua @@ -48,6 +48,7 @@ files( { "includes/gucefKAITAI_CKaitaiSchemaEnumDefinition.h", "includes/gucefKAITAI_CKaitaiSchemaFieldDefinition.h", "includes/gucefKAITAI_CKaitaiSchemaRegistry.h", + "includes/gucefKAITAI_CKaitaiSerializer.h", "includes/gucefKAITAI_CModule.h", "includes/gucefKAITAI_ETypes.h", "includes/gucefKAITAI_config.h", @@ -66,6 +67,7 @@ files( { "src/gucefKAITAI_CKaitaiSchemaEnumDefinition.cpp", "src/gucefKAITAI_CKaitaiSchemaFieldDefinition.cpp", "src/gucefKAITAI_CKaitaiSchemaRegistry.cpp", + "src/gucefKAITAI_CKaitaiSerializer.cpp", "src/gucefKAITAI_CModule.cpp" } ) diff --git a/platform/gucefVFS/include/gucefVFS_CVFS.h b/platform/gucefVFS/include/gucefVFS_CVFS.h index 88aad2aed..99b9e6fb7 100644 --- a/platform/gucefVFS/include/gucefVFS_CVFS.h +++ b/platform/gucefVFS/include/gucefVFS_CVFS.h @@ -722,6 +722,10 @@ class GUCEF_VFS_PUBLIC_CPP CVFS : public CORE::CTSGNotifier , CORE::CICloneable* eventdata ); bool LoadVfsSystemConfig( const CORE::CDataNode& cfg ); + + void OnAppShutdownCompleted( CORE::CNotifier* notifier , + const CORE::CEvent& eventid , + CORE::CICloneable* eventdata = GUCEF_NULL ); private: diff --git a/platform/gucefVFS/src/gucefVFS_CVFS.cpp b/platform/gucefVFS/src/gucefVFS_CVFS.cpp index 507472a9f..6dab1b7e1 100644 --- a/platform/gucefVFS/src/gucefVFS_CVFS.cpp +++ b/platform/gucefVFS/src/gucefVFS_CVFS.cpp @@ -98,6 +98,11 @@ #define GUCEF_CORE_CONFIGSTORE_H #endif /* GUCEF_CORE_CONFIGSTORE_H ? */ +#ifndef GUCEF_CORE_CGUCEFAPPLICATION_H +#include "CGUCEFApplication.h" +#define GUCEF_CORE_CGUCEFAPPLICATION_H +#endif /* GUCEF_CORE_CGUCEFAPPLICATION_H ? */ + #ifndef DVCPPSTRINGUTILS_H #include "dvcppstringutils.h" /* C++ string utils */ #define DVCPPSTRINGUTILS_H @@ -212,6 +217,10 @@ CVFS::RegisterEventHandlers( void ) SubscribeTo( &CORE::CCoreGlobal::Instance()->GetConfigStore() , CORE::CConfigStore::GlobalConfigLoadFailedEvent , callback2 ); + TEventCallback callback3( this, &CVFS::OnAppShutdownCompleted ); + SubscribeTo( &CORE::CCoreGlobal::Instance()->GetApplication() , + CORE::CGUCEFApplication::AppShutdownCompleteEvent , + callback3 ); } /*-------------------------------------------------------------------------*/ @@ -533,6 +542,20 @@ CVFS::OnGlobalConfigLoadFinished( CORE::CNotifier* notifier , /*-------------------------------------------------------------------------*/ +void +CVFS::OnAppShutdownCompleted( CORE::CNotifier* notifier , + const CORE::CEvent& eventid , + CORE::CICloneable* eventdata ) +{GUCEF_TRACE; + + MT::CScopeWriterLock lock( m_rwdataLock ); + + UnmountAllArchives(); + UnregisterAllArchiveFactories(); +} + +/*-------------------------------------------------------------------------*/ + bool CVFS::DeleteFile( const CString& filePath, bool okIfItDoesNotExist ) {GUCEF_TRACE; diff --git a/tools/GucefArchiver/src/main.cpp b/tools/GucefArchiver/src/main.cpp index 581ead943..bcebe9dee 100644 --- a/tools/GucefArchiver/src/main.cpp +++ b/tools/GucefArchiver/src/main.cpp @@ -60,6 +60,11 @@ #define GUCEF_CORE_CONFIGSTORE_H #endif /* GUCEF_CORE_CONFIGSTORE_H ? */ +#ifndef GUCEF_CORE_CGUCEFAPPLICATION_H +#include "CGUCEFApplication.h" +#define GUCEF_CORE_CGUCEFAPPLICATION_H +#endif /* GUCEF_CORE_CGUCEFAPPLICATION_H ? */ + #ifndef GUCEF_CORE_DVCPPSTRINGUTILS_H #include "dvcppstringutils.h" #define GUCEF_CORE_DVCPPSTRINGUTILS_H @@ -438,6 +443,7 @@ GUCEF_OSMAIN_BEGIN GUCEF_LOG( CORE::LOGLEVEL_NORMAL, "Wrote log file to: " + logFilename ); + CORE::CCoreGlobal::Instance()->GetApplication().Stop(); CORE::CCoreGlobal::Instance()->GetLogManager().ClearLoggers(); return 0;