Subversion Repositories gelsvn

Rev

Rev 589 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
512 s042372 1
/* ----------------------------------------------------------------------- *
572 jab 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
512 s042372 5
 * ----------------------------------------------------------------------- */
511 s042372 6
 
578 jab 7
/**
8
 * @file ItemID.h
9
 * @brief Base class for the integer IDs used to refer to mesh entities.
10
 */
572 jab 11
 
12
 
511 s042372 13
#ifndef __HMESH_ITEMID_H__
14
#define __HMESH_ITEMID_H__
15
 
546 jab 16
#include <iostream>
17
 
511 s042372 18
namespace HMesh
19
{
586 jab 20
    /** The ItemID class is simply a wrapper around an index. This class associates a type
21
     with the index. */
515 s042372 22
    template<typename T>
512 s042372 23
    class ItemID
24
    {
25
    public:
586 jab 26
        ItemID(): index(INVALID_INDEX){}
511 s042372 27
 
586 jab 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; }
546 jab 31
 
515 s042372 32
    private:
585 jab 33
        typedef size_t IndexType;
34
        static const IndexType INVALID_INDEX =  -1;
518 s042372 35
 
589 jab 36
        IndexType index;
37
 
586 jab 38
        explicit ItemID(IndexType _index): index(_index){}
511 s042372 39
 
515 s042372 40
        friend class ConnectivityKernel;
586 jab 41
 
42
        template<typename ITEM> friend class ItemVector;
43
        template<typename ITEM, typename ITEMID> friend class AttributeVector;
589 jab 44
        template<typename X>
45
        friend std::ostream& operator<<(std::ostream& os, const ItemID<X>&);
511 s042372 46
 
512 s042372 47
    };
511 s042372 48
 
547 jab 49
	template<typename T>
50
	inline std::ostream& operator<<(std::ostream& os, const ItemID<T>& iid)
546 jab 51
	{
52
		return (os << iid.index);
53
	}
54
 
511 s042372 55
}
56
 
57
#endif