660 |
khor |
1 |
/* ----------------------------------------------------------------------- *
|
|
|
2 |
* This file is part of GEL, http://www.imm.dtu.dk/GEL
|
|
|
3 |
* Copyright (C) the authors and DTU Informatics
|
|
|
4 |
* For license and list of authors, see ../../doc/intro.pdf
|
|
|
5 |
* ----------------------------------------------------------------------- */
|
|
|
6 |
|
|
|
7 |
/**
|
|
|
8 |
* @file ItemID.h
|
|
|
9 |
* @brief Base class for the integer IDs used to refer to mesh entities.
|
|
|
10 |
*/
|
|
|
11 |
|
|
|
12 |
|
|
|
13 |
#ifndef __HMESH_ITEMID_H__
|
|
|
14 |
#define __HMESH_ITEMID_H__
|
|
|
15 |
|
|
|
16 |
#include <iostream>
|
|
|
17 |
|
|
|
18 |
namespace HMesh
|
|
|
19 |
{
|
|
|
20 |
/** The ItemID class is simply a wrapper around an index. This class associates a type
|
|
|
21 |
with the index. */
|
|
|
22 |
template<typename T>
|
|
|
23 |
class ItemID
|
|
|
24 |
{
|
|
|
25 |
public:
|
|
|
26 |
ItemID(): index(INVALID_INDEX){}
|
|
|
27 |
|
|
|
28 |
bool operator ==(const ItemID& other) const { return index == other.index; }
|
|
|
29 |
bool operator !=(const ItemID& other) const { return index != other.index; }
|
|
|
30 |
bool operator <(const ItemID& other) const { return index < other.index; }
|
|
|
31 |
|
|
|
32 |
private:
|
|
|
33 |
typedef size_t IndexType;
|
|
|
34 |
static const IndexType INVALID_INDEX = -1;
|
|
|
35 |
|
|
|
36 |
IndexType index;
|
|
|
37 |
|
|
|
38 |
explicit ItemID(IndexType _index): index(_index){}
|
|
|
39 |
|
|
|
40 |
friend class ConnectivityKernel;
|
|
|
41 |
|
|
|
42 |
template<typename ITEM> friend class ItemVector;
|
|
|
43 |
template<typename ITEM, typename ITEMID> friend class AttributeVector;
|
|
|
44 |
template<typename X>
|
|
|
45 |
friend std::ostream& operator<<(std::ostream& os, const ItemID<X>&);
|
|
|
46 |
|
|
|
47 |
};
|
|
|
48 |
|
|
|
49 |
template<typename T>
|
|
|
50 |
inline std::ostream& operator<<(std::ostream& os, const ItemID<T>& iid)
|
|
|
51 |
{
|
|
|
52 |
return (os << iid.index);
|
|
|
53 |
}
|
|
|
54 |
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
#endif
|