summaryrefslogtreecommitdiff
path: root/public/include/XMPCommon/Interfaces/BaseInterfaces/IThreadSafe.h
blob: b0ed4b545824b7e345b30d271c6f43fd87813124 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//! @file IThreadSafe.h
#ifndef IThreadSafe_h__
#define IThreadSafe_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.h"

namespace AdobeXMPCommon {
	
	//!
	//! \brief Interface that serves as the base interface for all the externally exposed 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 XMP_PUBLIC IThreadSafe
	{
	public:

		//!
		//! @brief Enables the thread safety on an object.
		//! @details After calling this function the object can be used across multiple threads.
		//!
		virtual void APICALL EnableThreadSafety() const __NOTHROW__ = 0;

		//!
		//! @brief Disables the thread safety on an object.
		//! @details After calling this function the object should not be used across multiple threads.
		//!
		virtual void APICALL DisableThreadSafety() const __NOTHROW__ = 0;

		//!
		//! @brief Informs whether object can be used across multiple threads or not.
		//! \returns bool value; true in case object can be used across multiple threads, false
		//!  otherwise.
		//!
		virtual bool APICALL IsThreadSafe() const = 0;

		//! @{
		//! \cond XMP_INTERNAL_DOCUMENTATION
		//!  @brief Return the pointer to the internal Thread Safe interface
		//! \return either a const or non const pointer to internal IThreadSafe_I interface.
		virtual AdobeXMPCommon_Int::pIThreadSafe_I APICALL GetIThreadSafe_I() __NOTHROW__ = 0;

		XMP_PRIVATE AdobeXMPCommon_Int::pcIThreadSafe_I GetIThreadSafe_I() const __NOTHROW__ {
			return const_cast< IThreadSafe * >( this )->GetIThreadSafe_I();
		}
		//! \endcond
		//! @}

	protected:
		//! \cond XMP_INTERNAL_DOCUMENTATION
		//! @brief all safe functions
		virtual uint32 APICALL isThreadSafe() const __NOTHROW__ = 0;
		//! \endcond

	#ifdef FRIEND_CLASS_DECLARATION
		FRIEND_CLASS_DECLARATION();
	#endif
		REQ_FRIEND_CLASS_DECLARATION();
	};

}
#endif  // IThreadSafe_h__