aboutsummaryrefslogtreecommitdiff
path: root/sp/src/public/datamodel/dmelementhandle.h
blob: 319f308c08acb3b75fbb7e65e4275d3b71b07043 (plain) (blame)
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
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose: 
//
//=============================================================================

#ifndef DMELEMENTHANDLE_H
#define DMELEMENTHANDLE_H

#ifdef _WIN32
#pragma once
#endif


//-----------------------------------------------------------------------------
// handle to an CDmElement
//-----------------------------------------------------------------------------
#define PERFORM_HANDLE_TYPECHECKING 0
#if PERFORM_HANDLE_TYPECHECKING

// this is here to make sure we're being type-safe about element handles
// otherwise, the compiler lets us cast to bool incorrectly
// the other solution would be to redefine DmElementHandle_t s.t. DMELEMENT_HANDLE_INVALID==0
struct DmElementHandle_t
{
	DmElementHandle_t() : handle( 0xffffffff ) {}
	explicit DmElementHandle_t( int h ) : handle( h ) {}
	inline bool operator==( const DmElementHandle_t &h ) const { return handle == h.handle; }
	inline bool operator!=( const DmElementHandle_t &h ) const { return handle != h.handle; }
	inline bool operator<( const DmElementHandle_t &h ) const { return handle < h.handle; }
//	inline operator int() const { return handle; } // if we're okay with implicit int casts, uncomment this method
	int handle;
};
const DmElementHandle_t DMELEMENT_HANDLE_INVALID;

#else // PERFORM_HANDLE_TYPECHECKING

enum DmElementHandle_t
{
	DMELEMENT_HANDLE_INVALID = 0xffffffff
};

#endif // PERFORM_HANDLE_TYPECHECKING



#endif // DMELEMENTHANDLE_H