diff options
Diffstat (limited to 'XMPCommon/Interfaces')
-rw-r--r-- | XMPCommon/Interfaces/BaseInterfaces/IConfigurable_I.h | 129 | ||||
-rw-r--r-- | XMPCommon/Interfaces/BaseInterfaces/ISharedObject_I.h | 50 | ||||
-rw-r--r-- | XMPCommon/Interfaces/BaseInterfaces/IThreadSafe_I.h | 52 | ||||
-rw-r--r-- | XMPCommon/Interfaces/IConfigurationManager_I.h | 65 | ||||
-rw-r--r-- | XMPCommon/Interfaces/IErrorNotifier_I.h | 53 | ||||
-rw-r--r-- | XMPCommon/Interfaces/IError_I.h | 282 | ||||
-rw-r--r-- | XMPCommon/Interfaces/IMemoryAllocator_I.h | 53 | ||||
-rw-r--r-- | XMPCommon/Interfaces/ISharedMutex.h | 88 | ||||
-rw-r--r-- | XMPCommon/Interfaces/IUTF8String_I.h | 115 |
9 files changed, 887 insertions, 0 deletions
diff --git a/XMPCommon/Interfaces/BaseInterfaces/IConfigurable_I.h b/XMPCommon/Interfaces/BaseInterfaces/IConfigurable_I.h new file mode 100644 index 0000000..ef52ec8 --- /dev/null +++ b/XMPCommon/Interfaces/BaseInterfaces/IConfigurable_I.h @@ -0,0 +1,129 @@ +#ifndef IConfigurable_I_h__ +#define IConfigurable_I_h__ 1 + +// ================================================================================================= +// ADOBE SYSTEMS INCORPORATED +// Copyright 2014 Adobe Systems Incorporated +// All Rights Reserved +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= + +#include "XMPCommon/XMPCommonFwdDeclarations_I.h" +#include "XMPCommon/Interfaces/BaseInterfaces/IConfigurable.h" +#include "XMPCommon/XMPCommonErrorCodes.h" +#include <map> + +namespace XMP_COMPONENT_INT_NAMESPACE { + + class IConfigurable_I + : public virtual IConfigurable + { + public: + + typedef struct std::pair< eDataType, CombinedDataValue > TypeValuePair; + typedef std::pair< uint64, TypeValuePair > KeyValuePair; + typedef std::pair< uint64, eDataType > KeyValueTypePair; + + //! + //! Function to validate a key. + //! \param[in] key an unsigned 64 bit number indicating the key of the parameter. + //! If an object only supports fixed number of keys, it can override this function and + //! return error for an unsupported key, otherwise return #kCECNone. + //! + virtual eConfigurableErrorCode APICALL ValidateKey( const uint64 & key ) const { return kCECNone; } + + + //! + //! Function to modify the key. + //! \param[in] key an unsigned 64 bit number indicating the key of the parameter. + //! If an object supports eight character case in-sensitive keys, it can override this function + //! and convert them to lower case. + //! \return the new key. + //! + virtual uint64 APICALL ModifyKey( const uint64 & key ) const { return key; } + + //! + //! Function to validate the value and its type for a particular key. + //! \param[in] key an unsigned 64 bit number indicating the key of the parameter. + //! \param[in] type an eDataType enum value indicating the type of data associated with the key. + //! \param[in] value indicates the value of the data. + //! If an object supports a key with only a fixed type or it wants to constrain the values a key + //! can hold, it can override this function for such operations. Returns an error code in case + //! of an error condition, otherwise return kCECNone. + //! + virtual eConfigurableErrorCode APICALL ValidateValue( const uint64 & key, eDataType type, const CombinedDataValue & value ) const = 0; + + //! + //! Allows keys to be treated as case insensitive. + //! \param[in] flag a boolean value if set to true makes key as case insensitive + //! + virtual void APICALL TreatKeyAsCaseInsensitive( bool flag = true ) = 0; + + //! + //! Allows type of value to be changed later on. + //! \param[in] flag a boolean value if set to true allows even the type of data associated with the key to be changed later on. + //! + virtual void APICALL AllowDifferentValueTypesForExistingEntries( bool flag = true ) = 0; + + //! + //! Restrict to have only specific keys. + //! \param[in] keysTable an array of uint64 values containing all the keys. + //! \param[in] sizeofTable number of entries in the array. + //! + virtual void APICALL SetAllowedKeys( uint64 * keysTable, sizet sizeOfTable ) = 0; + + //! + //! Restrict data type of particular keys. + //! \param[in] keyValueTypePairTable an array of KeyValueTypePair containing all the allowed dataTypes for the keys. + //! \param[in] sizeOfTable number of entries in the array. + //! + virtual void APICALL SetAllowedValueTypesForKeys( KeyValueTypePair * keyValueTypePairTable, sizet sizeOfTable ) = 0; + + //! + //! Function to get access to the mutex object. + //! + virtual spISharedMutex APICALL GetMutex() const = 0; + + virtual void APICALL SetParameter( const uint64 & key, bool value ); + virtual void APICALL SetParameter( const uint64 & key, uint64 value ); + virtual void APICALL SetParameter( const uint64 & key, int64 value ); + virtual void APICALL SetParameter( const uint64 & key, double value ); + virtual void APICALL SetParameter( const uint64 & key, char value ); + virtual void APICALL SetParameter( const uint64 & key, const char * value ); + virtual void APICALL SetParameter( const uint64 & key, const void * value ); + + virtual bool APICALL GetParameter( const uint64 & key, bool & value ) const; + virtual bool APICALL GetParameter( const uint64 & key, uint64 & value ) const; + virtual bool APICALL GetParameter( const uint64 & key, int64 & value ) const; + virtual bool APICALL GetParameter( const uint64 & key, double & value ) const; + virtual bool APICALL GetParameter( const uint64 & key, char & value ) const; + virtual bool APICALL GetParameter( const uint64 & key, const char * & value ) const; + virtual bool APICALL GetParameter( const uint64 & key, const void * & value ) const; + + protected: + + //! + //! protected Virtual Destructor + //! + virtual ~IConfigurable_I() __NOTHROW__ {}; + + virtual void APICALL setParameter( const uint64 & key, uint32 dataType, const CombinedDataValue & dataValue, pcIError_base & error ) __NOTHROW__; + virtual uint32 APICALL removeParameter( const uint64 & key, pcIError_base & error ) __NOTHROW__; + virtual uint32 APICALL getParameter( const uint64 & key, uint32 dataType, CombinedDataValue & value, pcIError_base & error ) const __NOTHROW__; + virtual void APICALL getAllParameters( uint64 * array, sizet count ) const __NOTHROW__; + virtual uint32 APICALL getDataType( const uint64 & key, pcIError_base & error ) const __NOTHROW__; + + virtual void APICALL SetParameter( const uint64 & key, eDataType type, const CombinedDataValue & value ) = 0; + virtual bool APICALL GetParameter( const uint64 & key, eDataType type, CombinedDataValue & value ) const = 0; + + #ifdef FRIEND_CLASS_DECLARATION + FRIEND_CLASS_DECLARATION(); + #endif + REQ_FRIEND_CLASS_DECLARATION(); + }; + +} + +#endif // IConfigurable_I_h__ diff --git a/XMPCommon/Interfaces/BaseInterfaces/ISharedObject_I.h b/XMPCommon/Interfaces/BaseInterfaces/ISharedObject_I.h new file mode 100644 index 0000000..e1ab42e --- /dev/null +++ b/XMPCommon/Interfaces/BaseInterfaces/ISharedObject_I.h @@ -0,0 +1,50 @@ +#ifndef __ISharedObject_I_h__ +#define __ISharedObject_I_h__ 1 + +// ================================================================================================= +// ADOBE SYSTEMS INCORPORATED +// Copyright 2014 Adobe Systems Incorporated +// All Rights Reserved +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= + +#include "XMPCommon/XMPCommonDefines_I.h" +#include "XMPCommon/XMPCommonFwdDeclarations_I.h" +#include "XMPCommon/Interfaces/BaseInterfaces/ISharedObject.h" + +namespace AdobeXMPCommon_Int { + + //! + //! Internal interface that serves as the base interface of all the internal interfaces inherited from + //! externally exposed interfaces. + //! This allows all interfaces to be returned as raw pointers through wrapper functions so that internal + //! object is not deleted as soon as the internal smart pointer goes out of scope. + //! \note Any class/interface which inherits from this class needs to provide implementation for + //! AcquireInternal pure virtual function. + //! + class ISharedObject_I + : public virtual ISharedObject + { + public: + + //! + //! It indicates that the pointer owned by the internal smart pointer is required to extend beyond the life span + //! of smart pointer. This is generally the case where we are returning raw pointer from an internal shared pointer. + //! Called internally by the library to pass raw pointers across shared libraries from shared pointers. + //! + virtual void APICALL AcquireInternal() const __NOTHROW__ = 0; + + virtual pISharedObject_I APICALL GetISharedObject_I() __NOTHROW__ { return this; } + + protected: + + #ifdef FRIEND_CLASS_DECLARATION + FRIEND_CLASS_DECLARATION(); + #endif + REQ_FRIEND_CLASS_DECLARATION(); + }; +} + +#endif // __ISharedObject_I_h__ diff --git a/XMPCommon/Interfaces/BaseInterfaces/IThreadSafe_I.h b/XMPCommon/Interfaces/BaseInterfaces/IThreadSafe_I.h new file mode 100644 index 0000000..8d039c8 --- /dev/null +++ b/XMPCommon/Interfaces/BaseInterfaces/IThreadSafe_I.h @@ -0,0 +1,52 @@ +#ifndef IThreadSafe_I_h__ +#define IThreadSafe_I_h__ 1 + +// ================================================================================================= +// ADOBE SYSTEMS INCORPORATED +// Copyright 2015 Adobe Systems Incorporated +// All Rights Reserved +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= + +#include "XMPCommon/XMPCommonFwdDeclarations_I.h" +#include "XMPCommon/Interfaces/BaseInterfaces/IThreadSafe.h" + +namespace AdobeXMPCommon_Int { + + //! + //! \brief Internal Interface that serves as the base interface for all the externally exposed + //! or internal interfaces which needs to provide client configurable thread safety. + //! \attention In case client has disabled thread safety at the module level these functions will + //! have no use. + //! \note By default all the objects created are not thread safe. + //! + + class IThreadSafe_I + : public virtual IThreadSafe + { + public: + + //! + //! Make two objects share the same mutex. + //! Generally required in case of a DOM or where parent child relationship needs to be maintained. + //! \param[in] mutex a shared pointer of ISharedMutex interface to be shared among the object. + //! + virtual void APICALL ShareMutex( const XMP_COMPONENT_INT_NAMESPACE::spISharedMutex & mutex ) = 0; + virtual void APICALL UnShareMutex() = 0; + + virtual pIThreadSafe_I APICALL GetIThreadSafe_I() __NOTHROW__ { return this; } + + virtual uint32 APICALL isThreadSafe() const __NOTHROW__ { + if ( IsThreadSafe() ) return 1; + return 0; + } + + #ifdef FRIEND_CLASS_DECLARATION + REQ_FRIEND_CLASS_DECLARATION(); + #endif + REQ_FRIEND_CLASS_DECLARATION(); + }; +} +#endif // IThreadSafe_I_h__ diff --git a/XMPCommon/Interfaces/IConfigurationManager_I.h b/XMPCommon/Interfaces/IConfigurationManager_I.h new file mode 100644 index 0000000..bd8d094 --- /dev/null +++ b/XMPCommon/Interfaces/IConfigurationManager_I.h @@ -0,0 +1,65 @@ +#ifndef IConfigurationManager_I_h__ +#define IConfigurationManager_I_h__ 1 + +// ================================================================================================= +// ADOBE SYSTEMS INCORPORATED +// Copyright 2014 Adobe Systems Incorporated +// All Rights Reserved +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= + +#include "XMPCommon/XMPCommonFwdDeclarations_I.h" +#include "XMPCommon/Interfaces/IConfigurationManager.h" +#include "XMPCommon/Interfaces/BaseInterfaces/ISharedObject_I.h" + +namespace XMP_COMPONENT_INT_NAMESPACE { + + //! + //! \brief Internal interface that represents configuration settings controllable by the client. + //! \details Provides functions through which client can plug in its own memory allocators, error notifiers. + //! \attention Not Thread Safe as this functionality is generally used at the initialization phase. + //! +#if XMP_WinBuild + #pragma warning( push ) + #pragma warning( disable : 4250 ) +#endif + + class IConfigurationManager_I + : public virtual IConfigurationManager + , public virtual ISharedObject_I + { + public: + + //! + //! return the version of the interface. + //! \return 32 bit unsigned integer representing the version of the interface. + //! + static uint32 GetInterfaceVersion() { return kInternalInterfaceVersionNumber; } + + virtual pIConfigurationManager APICALL GetActualIConfigurationManager() __NOTHROW__ { return this; } + virtual pvoid APICALL GetInterfacePointer( uint64 interfaceID, uint32 interfaceVersion ); + + virtual ~IConfigurationManager_I() __NOTHROW__{} + + protected: + virtual uint32 APICALL registerMemoryAllocator( pIMemoryAllocator_base memoryAllocator, pcIError_base & error ) __NOTHROW__; + virtual uint32 APICALL registerErrorNotifier( pIErrorNotifier_base clientErrorNotifier, pcIError_base & error ) __NOTHROW__; + virtual uint32 APICALL disableMultiThreading( pcIError_base & error ) __NOTHROW__; + virtual uint32 APICALL isMultiThreaded( pcIError_base & error ) const __NOTHROW__; + virtual pvoid APICALL getInterfacePointer( uint64 interfaceID, uint32 interfaceVersion, pcIError_base & error ) __NOTHROW__; + pvoid APICALL GetInterfacePointerInternal( uint64 interfaceID, uint32 interfaceVersion, bool isTopLevel ); + + #ifdef FRIEND_CLASS_DECLARATION + REQ_FRIEND_CLASS_DECLARATION(); + #endif + REQ_FRIEND_CLASS_DECLARATION(); + }; + + #if XMP_WinBuild + #pragma warning( pop ) + #endif +} + +#endif // IConfigurationManager_I_h__ diff --git a/XMPCommon/Interfaces/IErrorNotifier_I.h b/XMPCommon/Interfaces/IErrorNotifier_I.h new file mode 100644 index 0000000..d5ff642 --- /dev/null +++ b/XMPCommon/Interfaces/IErrorNotifier_I.h @@ -0,0 +1,53 @@ +#ifndef IErrorNotifier_I_h__ +#define IErrorNotifier_I_h__ 1 + +// ================================================================================================= +// ADOBE SYSTEMS INCORPORATED +// Copyright 2014 Adobe Systems Incorporated +// All Rights Reserved +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= + +#include "XMPCommon/XMPCommonFwdDeclarations_I.h" +#include "XMPCommon/Interfaces/IErrorNotifier.h" + +namespace XMP_COMPONENT_INT_NAMESPACE { + + //! + //! \brief Internal interface that represents an interface to be implemented by library + //! in case it is interested in getting notifications with respect to errors/warnings encountered + //! within the library. + //! \details In case library is interested in error notifications it can implement this interface + //! and register the same with the #IConfigurationManager. For every warning or error + //! encountered the NotifyError function will be called by the library. In case of warnings ( indicated + //! by the severity of the error ) the implementation has the option to continue ignoring the warning by + //! returning true else he can return false and the warning will be thrown aborting the current operation. + //! + class IErrorNotifier_I + : public virtual IErrorNotifier + { + public: + + //! + //! Get the current error notifier. + //! + static pIErrorNotifier GetErrorNotifier(); + + //! + //! Set the current error notifier. + //! + static pIErrorNotifier SetErrorNotifier( pIErrorNotifier errorNotifier ); + + protected: + ~IErrorNotifier_I() {} + + #ifdef FRIEND_CLASS_DECLARATION + REQ_FRIEND_CLASS_DECLARATION(); + #endif + REQ_FRIEND_CLASS_DECLARATION(); + }; +} + +#endif // IErrorNotifier_I_h__ diff --git a/XMPCommon/Interfaces/IError_I.h b/XMPCommon/Interfaces/IError_I.h new file mode 100644 index 0000000..203b8bf --- /dev/null +++ b/XMPCommon/Interfaces/IError_I.h @@ -0,0 +1,282 @@ +#ifndef IError_I_h__ +#define IError_I_h__ 1 + +// ================================================================================================= +// ADOBE SYSTEMS INCORPORATED +// Copyright 2014 Adobe Systems Incorporated +// All Rights Reserved +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= + + +#include "XMPCommon/Interfaces/IError.h" +#include "XMPCommon/Interfaces/BaseInterfaces/ISharedObject_I.h" +#include "XMPCommon/Interfaces/IErrorNotifier_I.h" + +//! \cond NEVER_IN_DOCUMNETATION +#define PARAMETER_1( error, condition1, parameter1 ) \ + if ( condition1 ) error->AppendParameter( parameter1 ); + +#define PARAMETER_2( error, condition1, parameter1, \ + condition2, parameter2 ) \ + PARAMETER_1( error, condition1, parameter1 ) \ + PARAMETER_1( error, condition2, parameter2 ) + +#define PARAMETER_3( error, condition1, parameter1, \ + condition2, parameter2, condition3, parameter3 ) \ + PARAMETER_2( error, condition1, parameter1, condition2, parameter2 ) \ + PARAMETER_1( error, condition3, parameter3 ) \ + +#define PARAMETER_4( error, condition1, parameter1, \ + condition2, parameter2, condition3, parameter3, \ + condition4, parameter4 ) \ + PARAMETER_3( error, condition1, parameter1, condition2, \ + parameter2, condition3, parameter3 ) \ + PARAMETER_1( error, condition4, parameter4 ) + +#define PARAMETER_5( error, condition1, parameter1, \ + condition2, parameter2, condition3, parameter3, \ + condition4, parameter4, condition5, parameter5 ) \ + PARAMETER_4( error, condition1, parameter1, condition2, \ + parameter2, condition3, parameter3, condition4, parameter4 ) \ + PARAMETER_1( error, condition5, parameter5 ) + +#define PARAMETER_6( error, condition1, parameter1, \ + condition2, parameter2, condition3, parameter3, \ + condition4, parameter4, condition5, parameter5, \ + condition6, parameter6 ) \ + PARAMETER_5( error, condition1, parameter1, condition2, \ + parameter2, condition3, parameter3, condition4, parameter4, \ + condition5, parameter5 ) \ + PARAMETER_1( error, condition6, parameter6 ) + +#define GET_MACRO( error, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, MACRO_NAME, ... ) MACRO_NAME +#define CALLAPPENDPARAMETER( ... ) _CALLAPPENDPARAMETER( GET_MACRO( __VA_ARGS__, \ + PARAMETER_6, PARAMETER_6, PARAMETER_5, PARAMETER_5, PARAMETER_4, PARAMETER_4, \ + PARAMETER_3, PARAMETER_3, PARAMETER_2, PARAMETER_2, PARAMETER_1, PARAMETER_1 ), \ + __VA_ARGS__ ) +#define _CALLAPPENDPARAMETER( MACRO_NAME, ... ) _CALLAPPENDPARAMETER_( MACRO_NAME( __VA_ARGS__ ) ) +#define _CALLAPPENDPARAMETER_( X ) X + +//! \endcond + +//! +//! \brief Helper macro to create and notify warning to the client. +//! \details Creates a shared pointer of type #AdobeXMPCommon::IError, sets all the appropriate fields and +//! then notifies the client about the warning. +//! \param[in] domain an object of type #AdobeXMPCommon::IError_v1::eErrorDomain indicating the +//! domain to which this warning belongs. +//! \param[in] errorCode an object of type #AdobeXMPCommon::IError_v1::eErrorCode indicating the +//! error code within a particular domain. +//! \param[in] message pointer to a constant null terminated char buffer containing message. NULL pointer +//! will be treated as empty message string. +//! \param[in] ... variable number of pointers to constant null terminated char buffers. Each +//! entry containing a parameter to be stored along with the warning. +//! +#define NOTIFY_WARNING( domain, errorCode, message, ... ) { \ + spIError_I warn = IError_I::CreateError( ( domain ) , ( errorCode ) , IError_base::kESWarning ); \ + warn->SetLocation( __FILE__, __LINE__ ); \ + warn->SetMessage( ( message ) ); \ + CALLAPPENDPARAMETER( warn, __VA_ARGS__ ); \ + spcIError warning = warn; \ + if ( !IErrorNotifier_I::GetErrorNotifier()->Notify( warning ) ) { \ + throw warning; \ + } \ +} + +//! +//! \brief Helper macro to create and notify warning to the client. +//! \details Creates a shared pointer of type #AdobeXMPCommon::IError, sets all the appropriate fields and +//! then notifies the client about the error. +//! \param[in] domain an object of type #AdobeXMPCommon::IError_v1::eErrorDomain indicating the +//! domain to which this error belongs. +//! \param[in] errorCode an object of type #AdobeXMPCommon::IError_v1::eErrorCode indicating the +//! error code within a particular domain. +//! \param[in] message pointer to a constant null terminated char buffer containing message. NULL +//! pointer will be treated as empty message string. +//! \param[in] severity a value of #AdobeXMPCommon::IError_v1::eErrorSeverity indicating the +//! severity of the error. +//! \param[in] ... variable number of pointers to constant null terminated char buffers. Each +//! entry containing a parameter to be stored along with the error. +//! +#define NOTIFY_ERROR( domain, errorCode, message, severity, ... ) { \ + spIError_I err = IError_I::CreateError( ( domain ) , ( errorCode ) , severity ); \ + err->SetLocation( __FILE__, __LINE__ ); \ + err->SetMessage( ( message ) ); \ + CALLAPPENDPARAMETER( err, __VA_ARGS__ ); \ + spcIError error = err; \ + if ( !IErrorNotifier_I::GetErrorNotifier()->Notify( error ) ) { \ + throw error; \ + } \ + if ( severity > IError_v1::kESWarning ) { \ + throw error; \ + } \ +} + +#define CATCH_ALL() catch( ... ) { \ + NOTIFY_ERROR( IError_v1::kEDGeneral, IError_v1::kGECUnknownExceptionCaught, \ + "Unknown exception caught", IError_v1::kESOperationFatal ); } +//! +//! \brief Helper macro to create and throw an error without notifying the client. +//! \details Creates a shared pointer of type #AdobeXMPCommon::IError, sets all the appropriate fields and +//! then raises an exception with this shared pointer after marking it as const. +//! \param[in] domain an object of type #AdobeXMPCommon::IError_v1::eErrorDomain indicating the +//! domain to which this error belongs. +//! \param[in] errorCode an object of type #AdobeXMPCommon::IError_v1::eErrorCode indicating the +//! error code within a particular domain. +//! \param[in] message pointer to a constant null terminated char buffer containing message. NULL +//! pointer will be treated as empty message string. +//! \param[in] severity a value of #AdobeXMPCommon::IError_v1::eErrorSeverity indicating the +//! severity of the error. +//! \param[in] ... variable number of pointers to constant null terminated char buffers. Each +//! entry containing a parameter to be stored along with the error. +//! +#define THROW_ERROR( domain, errorCode, message, severity, ... ) { \ + spIError_I error = IError_I::CreateError( ( domain ) , ( errorCode ) , severity ); \ + error->SetLocation( __FILE__, __LINE__ ); \ + error->SetMessage( ( message ) ); \ + CALLAPPENDPARAMETER( error, __VA_ARGS__ ); \ + spcIError cError = error; \ + throw cError; \ +} + + +namespace XMP_COMPONENT_INT_NAMESPACE { + + //! + //! \brief Internal interface that represents an error/warning encountered during processing. + //! \details Provides all the functions to get/set required information regarding error scenario as well as + //! creating errors. + //! \attention Do Not support Multi-threading at object level. + //! \attention Multi-threading not required since internally same object will not be used across multiple threads. + //! + +#if XMP_WinBuild + #pragma warning( push ) + #pragma warning( disable : 4250 ) +#endif + class IError_I + : public virtual IError + , public virtual ISharedObject_I + { + public: + + using IError_v1::AppendParameter; + using IError_v1::GetCode; + using IError_v1::GetDomain; + using IError_v1::GetSeverity; + //using IError_v1::GetMessage; + using IError_v1::GetLocation; + using IError_v1::GetParameter; + using IError_v1::GetNextError; + using IError_v1::SetNextError; + + //! + //! Appends a parameter to the list of parameters. + //! \param[in] parameter shared pointer to a constant an object of IUTF8String. + //! Invalid shared pointer will be treated as empty message string. + //! + void APICALL AppendParameter( const spcIUTF8String & string ) __NOTHROW__; + + virtual pIError APICALL GetActualIError() __NOTHROW__ { return this; } + virtual pISharedObject_I APICALL GetISharedObject_I() __NOTHROW__ { return this; } + + virtual pvoid APICALL GetInterfacePointer( uint64 interfaceID, uint32 interfaceVersion ); + + // static factory methods + + //! + //! Creates an error object. + //! \param[in] errDomain a value of #eErrorDomain indicating the error domain. + //! \param[in] errCode a value of #eErrorCode indicating the error code. + //! \param[in] errSeverity a value of #eErrorSeverity indicating the severity of the error. + //! + static spIError_I CreateError( eErrorDomain errDomain, eErrorCode errCode, eErrorSeverity errSeverity ); + + + //! + //! Creates an error for uncaught exception. + //! \param[in] severity a value of #IError_v1::eErrorSeverity type indicating the severity of an error. + //! \param[in] fileName pointer to a constant null terminated char buffer containing fileName in which error + //! originated. + //! \param[in] lineNumber a value of #AdobeXMPCommon::uint32 type respresenting the lineNumber at which error + //! originated. + //! creates and returns appropriate error. + //! + static spIError_I CreateUnknownExceptionCaughtError( IError_v1::eErrorSeverity severity, const char * fileName, uint32 lineNumber ); + + //! + //! Creates an error for unavailable version of an interface.. + //! \param[in] severity a value of #IError_v1::eErrorSeverity type indicating the severity of an error. + //! \param[in] interfaceID a value of uint64 type representing the interfaceID of the interface. + //! \param[in] requestedVersion a value of uint32 type representing the version of the requested interface. + //! \param[in] fileName pointer to a constant null terminated char buffer containing fileName in which error + //! originated. + //! \param[in] lineNumber a value of #AdobeXMPCommon::uint32 type respresenting the lineNumber at which error + //! originated. + //! creates and returns appropriate error. + //! + static spIError_I CreateInterfaceVersionNotAvailableError( IError_v1::eErrorSeverity severity, uint64 interfaceID, uint32 requestedVersion, const char * fileName, uint32 lineNumber ); + + //! + //! Creates an error for unavailable interface. + //! \param[in] severity a value of #IError_v1::eErrorSeverity type indicating the severity of an error. + //! \param[in] interfaceID a value of uint64 type representing the interfaceID of the interface. + //! \param[in] requestedInterfaceID a value of uint64 type representing the interfaceID of the requested interface. + //! \param[in] fileName pointer to a constant null terminated char buffer containing fileName in which error + //! originated. + //! \param[in] lineNumber a value of #AdobeXMPCommon::uint32 type respresenting the lineNumber at which error + //! originated. + //! creates and returns appropriate error. + //! + static spIError_I CreateInterfaceNotAvailableError( IError_v1::eErrorSeverity severity, uint64 interfaceID, uint64 requestedInterfaceID, const char * fileName, uint32 lineNumber ); + + //! + //! Creates an error for client function throwing exception. + //! \param[in] severity a value of #IError_v1::eErrorSeverity type indicating the severity of an error. + //! \param[in] fileName pointer to a constant null terminated char buffer containing fileName in which error + //! originated. + //! \param[in] lineNumber a value of #AdobeXMPCommon::uint32 type respresenting the lineNumber at which error + //! originated. + //! creates and returns appropriate error. + //! + static spIError_I CreateClientCodeExceptionError( IError_v1::eErrorSeverity severity, const char * fileName, uint32 lineNumber ); + + protected: + + //! + //! @{ + //! wrapper functions - DLL across boundary safe functions. + //! + virtual uint32 APICALL getCode( pcIError_base & error ) const __NOTHROW__; + virtual uint32 APICALL getDomain( pcIError_base & error ) const __NOTHROW__; + virtual uint32 APICALL getSeverity( pcIError_base & error ) const __NOTHROW__; + virtual pcIUTF8String_base APICALL getMessage( pcIError_base & error ) const __NOTHROW__; + virtual pcIUTF8String_base APICALL getLocation( pcIError_base & error ) const __NOTHROW__; + virtual pcIUTF8String_base APICALL getParameter( sizet index, pcIError_base & error ) const __NOTHROW__; + virtual pIError_base APICALL getNextError( pcIError_base & error ) __NOTHROW__; + virtual pIError_base APICALL setNextError( pIError_base nextError, pcIError_base & error ) __NOTHROW__; + virtual pvoid APICALL getInterfacePointer( uint64 interfaceID, uint32 interfaceVersion, pcIError_base & error ) __NOTHROW__; + //! @} + //! + + virtual pvoid APICALL GetInterfacePointerInternal( uint64 interfaceID, uint32 interfaceVersion, bool isTopLevel ); + + virtual ~IError_I() __NOTHROW__ {} + + #ifdef FRIEND_CLASS_DECLARATION + FRIEND_CLASS_DECLARATION(); + #endif + REQ_FRIEND_CLASS_DECLARATION(); + }; + +#if XMP_WinBuild + #pragma warning( pop ) +#endif + + uint32 ReportErrorAndContinueABISafe( uint32 errorDomain, uint32 errorCode, uint32 errorSeverity, const char * message, pcIError_base & error ) __NOTHROW__; +} + +#endif // IError_I_h__ diff --git a/XMPCommon/Interfaces/IMemoryAllocator_I.h b/XMPCommon/Interfaces/IMemoryAllocator_I.h new file mode 100644 index 0000000..77cdec0 --- /dev/null +++ b/XMPCommon/Interfaces/IMemoryAllocator_I.h @@ -0,0 +1,53 @@ +#ifndef IMemoryAllocator_I_h__ +#define IMemoryAllocator_I_h__ 1 + +// ================================================================================================= +// ADOBE SYSTEMS INCORPORATED +// Copyright 2014 Adobe Systems Incorporated +// All Rights Reserved +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= + +#include "XMPCommon/XMPCommonFwdDeclarations_I.h" +#include "XMPCommon/Interfaces/IMemoryAllocator.h" + +namespace XMP_COMPONENT_INT_NAMESPACE { + + //! + //! \brief Internal interface that represents an interface to be implemented by client in case + //! he is interested in controlling the memory allocation and deallocation on the heap. + //! \details In case client is interested in controlling the memory allocation and deallocation on + //! the heap he can implement this interface and register the same with the + //! #AdobeXMPCommon::IConfigurationManager. For every request of memory allocation or deallocation on + //! the heap corresponding function will be called by the library. + //! \attention Support for Multi threading is under clients hand. + //! + class IMemoryAllocator_I + : public virtual IMemoryAllocator + { + public: + + //! + //! Get the current error notifier. + //! + static pIMemoryAllocator GetMemoryAllocator() __NOTHROW__; + + //! + //! Set the current error notifier. + //! + static pIMemoryAllocator SetMemoryAllocator( pIMemoryAllocator_base memoryAllocator ) __NOTHROW__; + + + protected: + ~IMemoryAllocator_I() {} + + #ifdef FRIEND_CLASS_DECLARATION + REQ_FRIEND_CLASS_DECLARATION(); + #endif + REQ_FRIEND_CLASS_DECLARATION(); + }; +} + +#endif // IMemoryAllocator_I_h__ diff --git a/XMPCommon/Interfaces/ISharedMutex.h b/XMPCommon/Interfaces/ISharedMutex.h new file mode 100644 index 0000000..6543fba --- /dev/null +++ b/XMPCommon/Interfaces/ISharedMutex.h @@ -0,0 +1,88 @@ +#ifndef ISharedMutex_h__ +#define ISharedMutex_h__ 1 + +// ================================================================================================= +// ADOBE SYSTEMS INCORPORATED +// Copyright 2015 Adobe Systems Incorporated +// All Rights Reserved +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= + +#include "XMPCommon/XMPCommonFwdDeclarations_I.h" +#include "XMPCommon/Interfaces/BaseInterfaces/ISharedObject_I.h" +#include "XMPCommon/XMPCommonErrorCodes_I.h" + +namespace XMP_COMPONENT_INT_NAMESPACE { + + //! + //! Internal interface that represents a mutex object. + //! \details Provides all the functions to lock/unlock the mutex. + //! + class XMP_PUBLIC ISharedMutex + : public virtual ISharedObject + { + public: + //! + //! Locks the mutex in exclusive mode. + //! \return a value of type eMutexErrorCode indicating the status of operation. + //! + virtual eMultiThreadingErrorCode APICALL Lock() __NOTHROW__ = 0; + + //! + //! Tries to lock the mutex in exclusive mode. + //! \return a value of type eMutexErrorCode indicating the status of operation. + //! + virtual eMultiThreadingErrorCode APICALL TryLock() __NOTHROW__ = 0; + + //! + //! Unlocks the mutex in exclusive mode. + //! \return a value of type eMutexErrorCode indicating the status of operation. + //! + virtual eMultiThreadingErrorCode APICALL Unlock() __NOTHROW__ = 0; + + //! + //! Locks the mutex in non exclusive mode. + //! \return a value of type eMutexErrorCode indicating the status of operation. + //! + virtual eMultiThreadingErrorCode APICALL LockShared() __NOTHROW__ = 0; + + //! + //! Tries to lock the mutex in non exclusive mode. + //! \return a value of type eMutexErrorCode indicating the status of operation. + //! + virtual eMultiThreadingErrorCode APICALL TryLockShared() __NOTHROW__ = 0; + + //! + //! Unlocks the mutex in non exclusive mode. + //! \return a value of type eMutexErrorCode indicating the status of operation. + //! + virtual eMultiThreadingErrorCode APICALL UnlockShared() __NOTHROW__ = 0; + + // factory methods + //! + //! Creates a mutex. + //! \return a shared pointer to #ISharedMutex. + //! + static spISharedMutex CreateSharedMutex(); + + protected: + //! + //! Destructor + //! + virtual ~ISharedMutex() __NOTHROW__ {} + + //! \cond XMP_INTERNAL_DOCUMENTATION + + #ifdef FRIEND_CLASS_DECLARATION + FRIEND_CLASS_DECLARATION(); + #endif + REQ_FRIEND_CLASS_DECLARATION(); + //! \endcond + + }; +} + +#endif // ISharedMutex_h__ + diff --git a/XMPCommon/Interfaces/IUTF8String_I.h b/XMPCommon/Interfaces/IUTF8String_I.h new file mode 100644 index 0000000..ac5d456 --- /dev/null +++ b/XMPCommon/Interfaces/IUTF8String_I.h @@ -0,0 +1,115 @@ +#ifndef __IUTF8String_I_h__ +#define __IUTF8String_I_h__ 1 + +// ================================================================================================= +// ADOBE SYSTEMS INCORPORATED +// Copyright 2014 Adobe Systems Incorporated +// All Rights Reserved +// +// NOTICE: Adobe permits you to use, modify, and distribute this file in accordance with the terms +// of the Adobe license agreement accompanying it. +// ================================================================================================= + +#include "XMPCommon/XMPCommonFwdDeclarations_I.h" +#include "XMPCommon/Interfaces/IUTF8String.h" +#include "XMPCommon/Interfaces/BaseInterfaces/ISharedObject_I.h" + +namespace XMP_COMPONENT_INT_NAMESPACE { + +#if XMP_WinBuild + #pragma warning( push ) + #pragma warning( disable : 4250 ) +#endif + + //! + //! \brief Internal interface that represents an UTF8String. + //! \details Provides all the functions to access properties of the string object, append or assign content + //! to the existing string objects and create empty string object or clone existing string objects. + //! + class IUTF8String_I + : public virtual IUTF8String + , public virtual ISharedObject_I + { + public: + + //! + //! return the version of the interface. + //! \return 32 bit unsigned integer representing the version of the interface. + //! + static uint32 GetInterfaceVersion() { return kInternalInterfaceVersionNumber; } + + using IUTF8String_v1::assign; + using IUTF8String_v1::append; + using IUTF8String_v1::insert; + using IUTF8String_v1::erase; + using IUTF8String_v1::resize; + using IUTF8String_v1::replace; + using IUTF8String_v1::copy; + using IUTF8String_v1::find; + using IUTF8String_v1::rfind; + using IUTF8String_v1::compare; + using IUTF8String_v1::substr; + using IUTF8String_v1::empty; + + virtual pIUTF8String APICALL GetActualIUTF8String() __NOTHROW__ { return this; } + + virtual pIUTF8String_base APICALL assign( const char * buffer, sizet count, pcIError_base & error ) __NOTHROW__; + virtual pIUTF8String_base APICALL assign( pcIUTF8String_base str, sizet srcPos, sizet count, pcIError_base & error ) __NOTHROW__; + virtual pIUTF8String_base APICALL append( const char * buffer, sizet count, pcIError_base & error ) __NOTHROW__; + virtual pIUTF8String_base APICALL append( pcIUTF8String_base str, sizet srcPos, sizet count, pcIError_base & error ) __NOTHROW__; + virtual pIUTF8String_base APICALL insert( sizet pos, const char * buf, sizet count, pcIError_base & error ) __NOTHROW__; + virtual pIUTF8String_base APICALL insert( sizet pos, pcIUTF8String_base src, sizet srcPos, sizet count, pcIError_base & error ) __NOTHROW__; + virtual pIUTF8String_base APICALL erase( sizet pos, sizet count, pcIError_base & error ) __NOTHROW__; + virtual void APICALL resize( sizet n, pcIError_base & error ) __NOTHROW__; + virtual pIUTF8String_base APICALL replace( sizet pos, sizet count, const char * buf, sizet srcCount, pcIError_base & error ) __NOTHROW__; + virtual pIUTF8String_base APICALL replace( sizet pos, sizet count, pcIUTF8String_base src, sizet srcPos, sizet srcCount, pcIError_base & error ) __NOTHROW__; + virtual sizet APICALL copy( char * buf, sizet len, sizet pos, pcIError_base & error ) const __NOTHROW__; + virtual sizet APICALL find( const char * buf, sizet pos, sizet count, pcIError_base & error ) const __NOTHROW__; + virtual sizet APICALL find( pcIUTF8String_base src, sizet pos, sizet count, pcIError_base & error ) const __NOTHROW__; + virtual sizet APICALL rfind( const char * buf, sizet pos, sizet count, pcIError_base & error ) const __NOTHROW__; + virtual sizet APICALL rfind( pcIUTF8String_base src, sizet pos, sizet count, pcIError_base & error ) const __NOTHROW__; + virtual int32 APICALL compare( sizet pos, sizet len, const char * buf, sizet count, pcIError_base & error ) const __NOTHROW__; + virtual int32 APICALL compare( sizet pos, sizet len, pcIUTF8String_base str, sizet strPos, sizet strLen, pcIError_base & error ) const __NOTHROW__; + virtual pIUTF8String_base APICALL substr( sizet pos, sizet count, pcIError_base & error ) const __NOTHROW__; + virtual uint32 APICALL empty( pcIError_base & error ) const __NOTHROW__; + + virtual pvoid APICALL GetInterfacePointer( uint64 interfaceID, uint32 interfaceVersion ); + + // static factory functions + + //! + //! Creates an IUTF8String object whose initial contents are copied from a char buffer. + //! \param[in] buf pointer to a constant char buffer containing content. It can be null + //! terminated or not. NULL pointer will be treated as empty string. + //! \param[in] count a value of #AdobeXMPCommon::sizet indicating the length in case buf is not null + //! terminated. In case buf is null terminated it can be set to npos. + //! \return a shared pointer to a newly created #AdobeXMPCommon::IUTF8String object + //! + XMP_PRIVATE static spIUTF8String CreateUTF8String( const char * buf = NULL, sizet count = AdobeXMPCommon::npos ); + + protected: + virtual pvoid APICALL getInterfacePointer( uint64 interfaceID, uint32 interfaceVersion, pcIError_base & error ) __NOTHROW__; + pvoid APICALL GetInterfacePointerInternal( uint64 interfaceID, uint32 interfaceVersion, bool isTopLevel ); + + virtual ~IUTF8String_I() __NOTHROW__ {} + + #ifdef FRIEND_CLASS_DECLARATION + FRIEND_CLASS_DECLARATION(); + #endif + REQ_FRIEND_CLASS_DECLARATION(); + }; + +#if XMP_WinBuild + #pragma warning( pop ) +#endif + +} + +#include "XMPCommon/Utilities/TAllocator.h" +namespace XMP_COMPONENT_INT_NAMESPACE { + // typedefs for vectors and their corresponding shared pointers. + typedef std::vector< spIUTF8String, TAllocator< spIUTF8String > > mmIUTF8StringList; + typedef std::vector< spcIUTF8String, TAllocator< spcIUTF8String > > mmcIUTF8StringList; +} + +#endif // __IUTF8String_I_h__ |