<commit_before>//////////////////////////////////////////////////////////////////////////
//
//  Copyright (c) 2007-2009, Image Engine Design Inc. All rights reserved.
//
//  Redistribution and use in source and binary forms, with or without
//  modification, are permitted provided that the following conditions are
//  met:
//
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//
//     * Redistributions in binary form must reproduce the above copyright
//       notice, this list of conditions and the following disclaimer in the
//       documentation and/or other materials provided with the distribution.
//
//     * Neither the name of Image Engine Design nor the names of any
//       other contributors to this software may be used to endorse or
//       promote products derived from this software without specific prior
//       written permission.
//
//  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
//  IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
//  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
//  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
//  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
//  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
//  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
//  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
//  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
//  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
//  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////

#ifndef IE_CORE_RUNTIMETYPED_H
#define IE_CORE_RUNTIMETYPED_H

#include "IECore/RefCounted.h"
#include "IECore/TypeIds.h"

#include <string>
#include <map>
#include <vector>
#include <set>

namespace IECore
{

#define IE_CORE_DECLARETYPEFNS( TYPENAME, BASETYPENAME )\
	virtual IECore::TypeId typeId() const { return TYPENAME ## TypeId; };\
	virtual std::string typeName() const { return #TYPENAME; };\
	static IECore::TypeId staticTypeId() { return TYPENAME ## TypeId; };\
	static std::string staticTypeName() { return #TYPENAME; };\
	static IECore::TypeId baseTypeId() { return BASETYPENAME ## TypeId; };\
	static std::string baseTypeName() { return #BASETYPENAME; };	

#define IE_CORE_DECLAREEXTENSIONTYPEFNS( TYPENAME, TYPEID, BASETYPENAME )\
	virtual IECore::TypeId typeId() const { return IECore::TypeId(TYPEID); };\
	virtual std::string typeName() const { return #TYPENAME; };\
	static IECore::TypeId staticTypeId() { return IECore::TypeId(TYPEID); };\
	static std::string staticTypeName() { return #TYPENAME; };\
	static IECore::TypeId baseTypeId() { return BASETYPENAME ## TypeId; };\
	static std::string baseTypeName() { return #BASETYPENAME; };	
		
#define IE_CORE_DECLARETYPEISINSTANCEFUNCTIONS( BASETYPE )																										\
	virtual bool isInstanceOf( IECore::TypeId typeId ) const { return typeId==staticTypeId() ? true : BASETYPE::isInstanceOf( typeId ); };						\
	virtual bool isInstanceOf( const std::string &typeName ) const { return typeName==staticTypeName() ? true : BASETYPE::isInstanceOf( typeName ); };			\
	
#define IE_CORE_DECLAREINHERITSFROMFUNCTIONS( BASETYPE )																										\
	static bool inheritsFrom( IECore::TypeId typeId ) { return BASETYPE::staticTypeId()==typeId ? true : BASETYPE::inheritsFrom( typeId ); };					\
	static bool inheritsFrom( const std::string &typeName ) { return BASETYPE::staticTypeName()==typeName ? true : BASETYPE::inheritsFrom( typeName ); }		\

#define IE_CORE_DECLARERUNTIMETYPEDDESCRIPTION( TYPE )		\
	private: \
	static const IECore::RunTimeTyped::TypeDescription<TYPE> g_typeDescription;\
	public:
	
#define IE_CORE_DEFINERUNTIMETYPEDDESCRIPTION( TYPE )																	\
	const IECore::RunTimeTyped::TypeDescription<TYPE> TYPE::g_typeDescription;		
	
#define IE_CORE_DEFINERUNTIMETYPED( TYPE )																	\
	IE_CORE_DEFINERUNTIMETYPEDDESCRIPTION( TYPE )
		
/// Use this macro within the public section of an IECore class declaration to
/// implement all necessary RunTimeTyped functions. TYPE is the name of
/// the class and BASETYPE is the name of the base class. The TypeId
/// enum must contain an entry TYPETypeId.
#define IE_CORE_DECLARERUNTIMETYPED( TYPE, BASETYPE )\
	IE_CORE_DECLAREMEMBERPTR( TYPE )  \
	IE_CORE_DECLARETYPEFNS( TYPE, BASETYPE )\
	IE_CORE_DECLARETYPEISINSTANCEFUNCTIONS( BASETYPE )\
	IE_CORE_DECLAREINHERITSFROMFUNCTIONS( BASETYPE )\
	IE_CORE_DECLARERUNTIMETYPEDDESCRIPTION( TYPE ) \
	typedef BASETYPE BaseType;
	
	
/// Use this macro within the public section of an extension library class declaration to
/// implement all necessary RunTimeTyped functions. TYPE is the name of
/// the class and BASETYPE is the name of the base class. TYPEID is a unique numeric type
/// identifier that must not clash with any other.
#define IE_CORE_DECLARERUNTIMETYPEDEXTENSION( TYPE, TYPEID, BASETYPE )\
	IE_CORE_DECLAREMEMBERPTR( TYPE )  \
	IE_CORE_DECLAREEXTENSIONTYPEFNS( TYPE, TYPEID, BASETYPE )\
	IE_CORE_DECLARETYPEISINSTANCEFUNCTIONS( BASETYPE )\
	IE_CORE_DECLAREINHERITSFROMFUNCTIONS( BASETYPE )\
	IE_CORE_DECLARERUNTIMETYPEDDESCRIPTION( TYPE ) \
	typedef BASETYPE BaseType;

/// An abstract base class for objects whose type we wish to determine at runtime.
/// The rationale for using such a type system rather than the std c++
/// typeid() stuff is as follows :
///
///	1) The GCC implentation of the C++ system breaks down with
///	templated types across module boundaries.
///
/// 2) We wish to use the type system to identify the type
/// of serialised objects in files (see the serialisation
/// interface defined in Object), but the C++ type_info object<commit_msg>Changed BaseType to BaseClass to due clash with existing definition in TypedData<commit_after>//////////////////////////////////////////////////////////////////////////
//
//  Copyright (c) 2007-2009, Image Engine Design Inc. All rights reserved.
//
//  Redistribution and use in source and binary forms, with or without
//  modification, are permitted provided that the following conditions are
//  met:
//
//     * Redistributions of source code must retain the above copyright
//       notice, this list of conditions and the following disclaimer.
//
//     * Redistributions in binary form must reproduce the above copyright
//       notice, this list of conditions and the following disclaimer in the
//       documentation and/or other materials provided with the distribution.
//
//     * Neither the name of Image Engine Design nor the names of any
//       other contributors to this software may be used to endorse or
//       promote products derived from this software without specific prior
//       written permission.
//
//  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
//  IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
//  THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
//  PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
//  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
//  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
//  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
//  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
//  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
//  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
//  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//////////////////////////////////////////////////////////////////////////

#ifndef IE_CORE_RUNTIMETYPED_H
#define IE_CORE_RUNTIMETYPED_H

#include "IECore/RefCounted.h"
#include "IECore/TypeIds.h"

#include <string>
#include <map>
#include <vector>
#include <set>

namespace IECore
{

#define IE_CORE_DECLARETYPEFNS( TYPENAME, BASETYPENAME )\
	virtual IECore::TypeId typeId() const { return TYPENAME ## TypeId; };\
	virtual std::string typeName() const { return #TYPENAME; };\
	static IECore::TypeId staticTypeId() { return TYPENAME ## TypeId; };\
	static std::string staticTypeName() { return #TYPENAME; };\
	static IECore::TypeId baseTypeId() { return BASETYPENAME ## TypeId; };\
	static std::string baseTypeName() { return #BASETYPENAME; };	

#define IE_CORE_DECLAREEXTENSIONTYPEFNS( TYPENAME, TYPEID, BASETYPENAME )\
	virtual IECore::TypeId typeId() const { return IECore::TypeId(TYPEID); };\
	virtual std::string typeName() const { return #TYPENAME; };\
	static IECore::TypeId staticTypeId() { return IECore::TypeId(TYPEID); };\
	static std::string staticTypeName() { return #TYPENAME; };\
	static IECore::TypeId baseTypeId() { return BASETYPENAME ## TypeId; };\
	static std::string baseTypeName() { return #BASETYPENAME; };	
		
#define IE_CORE_DECLARETYPEISINSTANCEFUNCTIONS( BASETYPE )																										\
	virtual bool isInstanceOf( IECore::TypeId typeId ) const { return typeId==staticTypeId() ? true : BASETYPE::isInstanceOf( typeId ); };						\
	virtual bool isInstanceOf( const std::string &typeName ) const { return typeName==staticTypeName() ? true : BASETYPE::isInstanceOf( typeName ); };			\
	
#define IE_CORE_DECLAREINHERITSFROMFUNCTIONS( BASETYPE )																										\
	static bool inheritsFrom( IECore::TypeId typeId ) { return BASETYPE::staticTypeId()==typeId ? true : BASETYPE::inheritsFrom( typeId ); };					\
	static bool inheritsFrom( const std::string &typeName ) { return BASETYPE::staticTypeName()==typeName ? true : BASETYPE::inheritsFrom( typeName ); }		\

#define IE_CORE_DECLARERUNTIMETYPEDDESCRIPTION( TYPE )		\
	private: \
	static const IECore::RunTimeTyped::TypeDescription<TYPE> g_typeDescription;\
	public:
	
#define IE_CORE_DEFINERUNTIMETYPEDDESCRIPTION( TYPE )																	\
	const IECore::RunTimeTyped::TypeDescription<TYPE> TYPE::g_typeDescription;		
	
#define IE_CORE_DEFINERUNTIMETYPED( TYPE )																	\
	IE_CORE_DEFINERUNTIMETYPEDDESCRIPTION( TYPE )
		
/// Use this macro within the public section of an IECore class declaration to
/// implement all necessary RunTimeTyped functions. TYPE is the name of
/// the class and BASETYPE is the name of the base class. The TypeId
/// enum must contain an entry TYPETypeId.
#define IE_CORE_DECLARERUNTIMETYPED( TYPE, BASETYPE )\
	IE_CORE_DECLAREMEMBERPTR( TYPE )  \
	IE_CORE_DECLARETYPEFNS( TYPE, BASETYPE )\
	IE_CORE_DECLARETYPEISINSTANCEFUNCTIONS( BASETYPE )\
	IE_CORE_DECLAREINHERITSFROMFUNCTIONS( BASETYPE )\
	IE_CORE_DECLARERUNTIMETYPEDDESCRIPTION( TYPE ) \
	typedef BASETYPE BaseClass;
	
	
/// Use this macro within the public section of an extension library class declaration to
/// implement all necessary RunTimeTyped functions. TYPE is the name of
/// the class and BASETYPE is the name of the base class. TYPEID is a unique numeric type
/// identifier that must not clash with any other.
#define IE_CORE_DECLARERUNTIMETYPEDEXTENSION( TYPE, TYPEID, BASETYPE )\
	IE_CORE_DECLAREMEMBERPTR( TYPE )  \
	IE_CORE_DECLAREEXTENSIONTYPEFNS( TYPE, TYPEID, BASETYPE )\
	IE_CORE_DECLARETYPEISINSTANCEFUNCTIONS( BASETYPE )\
	IE_CORE_DECLAREINHERITSFROMFUNCTIONS( BASETYPE )\
	IE_CORE_DECLARERUNTIMETYPEDDESCRIPTION( TYPE ) \
	typedef BASETYPE BaseClass;

/// An abstract base class for objects whose type we wish to determine at runtime.
/// The rationale for using such a type system rather than the std c++
/// typeid() stuff is as follows :
///
///	1) The GCC implentation of the C++ system breaks down with
///	templated types across module boundaries.
///
/// 2) We wish to use the type system to identify the type
/// of serialised objects in files (see the serialisation
/// interface defined in Object), but the C++ type_info object
{'fraction_non_alphanumeric': 0.1118857622847543, 'fraction_numerical': 0.0016799664006719867, 'mean_word_length': 3.6290824261275274, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3840775', 'n_tokens_mistral': 3591, 'n_tokens_neox': 3387, 'n_words': 1208}