Skip to content

Commit

Permalink
gucefKAITAI: added some more wip skeleton code
Browse files Browse the repository at this point in the history
  • Loading branch information
LiberatorUSA committed Apr 21, 2024
1 parent b2c0b51 commit d53c1ab
Show file tree
Hide file tree
Showing 12 changed files with 640 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ class GUCEF_CORE_PUBLIC_CPP CUriResourceAccessorFactory : public CTAbstractFacto

virtual ~CUriResourceAccessorFactory( void );

/**
* Utility specialization of Create() which uses the contextually more natural Uri class
*/
TProductPtr CreateAccessor( const CUri& uri );

/**
* Utility shortcut version of GetResourceAccess() which instantiates the correct accessor
* first in order to obtain resource access.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ CUriResourceAccessorFactory::~CUriResourceAccessorFactory()

/*-------------------------------------------------------------------------*/

CUriResourceAccessorFactory::TProductPtr
CUriResourceAccessorFactory::CreateAccessor( const CUri& uri )
{GUCEF_TRACE;

return Create( uri.GetScheme() );
}

/*-------------------------------------------------------------------------*/

bool
CUriResourceAccessorFactory::GetResourceAccess( const CUri& uri ,
IOAccessPtr& accessToResource ,
Expand Down
8 changes: 5 additions & 3 deletions platform/gucefKAITAI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

set( HEADER_FILES
includes/gucefKAITAI.h
includes/gucefKAITAI_CGlobalKaitaiSchemaRegistry.h
includes/gucefKAITAI_CKaitaiGlobal.h
includes/gucefKAITAI_CKaitaiReader.h
includes/gucefKAITAI_CKaitaiSchema.h
Expand All @@ -26,6 +27,7 @@ set( HEADER_FILES
)

set( SOURCE_FILES
src/gucefKAITAI_CGlobalKaitaiSchemaRegistry.cpp
src/gucefKAITAI_CKaitaiGlobal.cpp
src/gucefKAITAI_CKaitaiReader.cpp
src/gucefKAITAI_CKaitaiSchema.cpp
Expand All @@ -46,11 +48,11 @@ set( ALL_FILES ${HEADER_FILES} ${SOURCE_FILES} ${PLATFORM_HEADER_FILES} ${PLATFO

set( MODULE_NAME "gucefKAITAI" )
add_library( ${MODULE_NAME} ${ALL_FILES} )
add_dependencies( ${MODULE_NAME} gucefCORE gucefMT )
target_link_libraries( ${MODULE_NAME} gucefCORE gucefMT )
add_dependencies( ${MODULE_NAME} gucefCORE gucefMT gucefVFS )
target_link_libraries( ${MODULE_NAME} gucefCORE gucefMT gucefVFS )
set_property( TARGET ${MODULE_NAME} APPEND_STRING PROPERTY COMPILE_DEFINITIONS "GUCEF_KAITAI_BUILD_MODULE" )

include_directories( ../../common/include ../gucefCORE/include ../gucefMT/include includes )
include_directories( ../../common/include ../gucefCORE/include ../gucefMT/include ../gucefVFS/include includes )

if ( ANDROID )
include_directories( ../gucefCORE/include/android )
Expand Down
2 changes: 2 additions & 0 deletions platform/gucefKAITAI/ModuleInfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
<Dependency Name="gucefHeaders" />
<Dependency Name="gucefMT" />
<Dependency Name="gucefCORE" />
<Dependency Name="gucefVFS" />
</Dependencies>
<Linker>
<Dependency Name="gucefMT" />
<Dependency Name="gucefCORE" />
<Dependency Name="gucefVFS" />
</Linker>
<Preprocessor>
<Define String="GUCEF_KAITAI_BUILD_MODULE" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/*
* gucefKAITAI: Platform module supporting the Kaitai binary description format
*
* Copyright (C) 1998 - 2023. 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_KAITAI_CGLOBALKAITAISCHEMAREGISTRY_H
#define GUCEF_KAITAI_CGLOBALKAITAISCHEMAREGISTRY_H

/*-------------------------------------------------------------------------//
// //
// INCLUDES //
// //
//-------------------------------------------------------------------------*/

#ifndef GUCEF_CORE_CTEVENTHANDLERFUNCTOR_H
#include "gucefCORE_CTEventHandlerFunctor.h"
#define GUCEF_CORE_CTEVENTHANDLERFUNCTOR_H
#endif /* GUCEF_CORE_CTEVENTHANDLERFUNCTOR_H ? */

#ifndef GUCEF_CORE_CGLOBALLYCONFIGURABLE_H
#include "gucefCORE_CGloballyConfigurable.h"
#define GUCEF_CORE_CGLOBALLYCONFIGURABLE_H
#endif /* GUCEF_CORE_CGLOBALLYCONFIGURABLE_H ? */

#ifndef GUCEF_KAITAI_CKAITAISCHEMAREGISTRY_H
#include "gucefKAITAI_CKaitaiSchemaRegistry.h"
#define GUCEF_KAITAI_CKAITAISCHEMAREGISTRY_H
#endif /* GUCEF_KAITAI_CKAITAISCHEMAREGISTRY_H ? */

/*-------------------------------------------------------------------------//
// //
// NAMESPACE //
// //
//-------------------------------------------------------------------------*/

namespace GUCEF {
namespace KAITAI {

/*-------------------------------------------------------------------------//
// //
// CLASSES //
// //
//-------------------------------------------------------------------------*/

class GUCEF_KAITAI_PRIVATE_CPP CGlobalKaitaiSchemaRegistry : public CKaitaiSchemaRegistry ,
public CORE::CGloballyConfigurable
{
public:

static const CORE::CString ClassTypeName;

virtual bool SaveConfig( CORE::CDataNode& cfg ) const GUCEF_VIRTUAL_OVERRIDE;

virtual bool LoadConfig( const CORE::CDataNode& cfg ) GUCEF_VIRTUAL_OVERRIDE;

virtual const CORE::CString& GetClassTypeName( void ) const GUCEF_VIRTUAL_OVERRIDE;

private:
friend class CKaitaiGlobal;

CGlobalKaitaiSchemaRegistry( void );

virtual ~CGlobalKaitaiSchemaRegistry();

private:

typedef CORE::CTEventHandlerFunctor< CGlobalKaitaiSchemaRegistry > TEventCallback;

CGlobalKaitaiSchemaRegistry( const CGlobalKaitaiSchemaRegistry& src ); /**< not implemented, don't use */
CGlobalKaitaiSchemaRegistry& operator=( const CGlobalKaitaiSchemaRegistry& src ); /**< not implemented, don't use */

bool LoadSchemasFromSources( void );

void RegisterEventHandlers( void );

void
OnVfsInitializationCompleted( CORE::CNotifier* notifier ,
const CORE::CEvent& eventId ,
CORE::CICloneable* eventData );

class GUCEF_KAITAI_PRIVATE_CPP SchemaSource
{
public:

SchemaSource();

CORE::CString location;
bool recursive;
CORE::CString family;
};

typedef std::vector< SchemaSource > SchemaSourceVector;

private:

bool m_vfsInitIsComplete;
SchemaSourceVector m_vfsSchemaSources;
SchemaSourceVector m_uriSchemaSources;
};

/*-------------------------------------------------------------------------//
// //
// NAMESPACE //
// //
//-------------------------------------------------------------------------*/

}; /* namespace KAITAI */
}; /* namespace GUCEF */

/*-------------------------------------------------------------------------*/

#endif /* GUCEF_KAITAI_CGLOBALKAITAISCHEMAREGISTRY_H ? */
10 changes: 10 additions & 0 deletions platform/gucefKAITAI/includes/gucefKAITAI_CKaitaiSchema.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,21 @@ class GUCEF_KAITAI_PUBLIC_CPP CKaitaiSchema : public CORE::CIDataNodeSerializabl
CKaitaiSchema( const CKaitaiSchema& src );
CKaitaiSchema& operator=( const CKaitaiSchema& src );

/*
* Utility function for loading a Kaitai schema
*/
bool LoadSchema( CORE::IOAccessPtr schemaResource );

/*
* Utility function for loading a Kaitai schema
*/
bool LoadSchema( const CORE::CUri& schemaResource );

/*
* Utility function for loading a Kaitai schema using the VFS
*/
bool LoadSchemaUsingVfs( const CORE::CString& schemaResourcePath );

virtual CORE::CICloneable* Clone( void ) const GUCEF_VIRTUAL_OVERRIDE;
virtual const CORE::CString& GetClassTypeName( void ) const GUCEF_VIRTUAL_OVERRIDE;

Expand Down
16 changes: 13 additions & 3 deletions platform/gucefKAITAI/includes/gucefKAITAI_CKaitaiSchemaRegistry.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,29 @@ class GUCEF_KAITAI_PUBLIC_CPP CKaitaiSchemaRegistry : public CORE::CTONRegistry<
TSchemaPtr TryGetSchema( const CORE::CString& schemaFamily ,
const CORE::CString& schemaName ) const;

bool RegisterSchema( TSchemaPtr schema ,
const CORE::CString& schemaFamily );

bool LoadSchema( const CORE::CUri& schemaResource ,
const CORE::CString& schemaFamily );

bool LoadSchemas( const CORE::CUri& schemaResourceRoot ,
const CORE::CString& schemaFamily ,
bool recursive );

bool LoadSchemaUsingVfs( const CORE::CString& schemaResourcePath ,
const CORE::CString& schemaFamily );

bool LoadSchemasUsingVfs( const CORE::CString& schemaResourcesRoot ,
const CORE::CString& schemaFamily ,
bool recursive );

protected:

virtual MT::TLockStatus Lock( UInt32 lockWaitTimeoutInMs = GUCEF_MT_DEFAULT_LOCK_TIMEOUT_IN_MS ) const GUCEF_VIRTUAL_OVERRIDE;

virtual MT::TLockStatus Unlock( void ) const GUCEF_VIRTUAL_OVERRIDE;

private:
friend class CKaitaiGlobal;

CKaitaiSchemaRegistry( void );

virtual ~CKaitaiSchemaRegistry();
Expand Down
Loading

0 comments on commit d53c1ab

Please sign in to comment.