Subversion Repositories gelsvn

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
667 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:
677 janba 26
        typedef size_t IndexType;
27
 
667 khor 28
        ItemID(): index(INVALID_INDEX){}
29
 
30
        bool operator ==(const ItemID& other) const { return index == other.index; }
31
        bool operator !=(const ItemID& other) const { return index != other.index; }
32
        bool operator <(const ItemID& other) const { return index < other.index; }
677 janba 33
 
34
        IndexType get_index() const { return index;}
667 khor 35
 
36
    private:
677 janba 37
        IndexType index;
667 khor 38
        static const IndexType INVALID_INDEX =  -1;
39
 
40
        explicit ItemID(IndexType _index): index(_index){}
41
 
42
        friend class ConnectivityKernel;
43
 
44
        template<typename ITEM> friend class ItemVector;
45
        template<typename ITEM, typename ITEMID> friend class AttributeVector;
46
        template<typename X>
47
        friend std::ostream& operator<<(std::ostream& os, const ItemID<X>&);
48
 
49
    };
50
 
51
	template<typename T>
52
	inline std::ostream& operator<<(std::ostream& os, const ItemID<T>& iid)
53
	{
54
		return (os << iid.index);
55
	}
56
 
57
}
58
 
59
#endif