Subversion Repositories gelsvn

Rev

Go to most recent revision | Details | 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
{
526 jab 20
	template<typename ITEM, typename ITEMID>
21
	class AttributeVector;
22
 
586 jab 23
    /** The ItemID class is simply a wrapper around an index. This class associates a type
24
     with the index. */
515 s042372 25
    template<typename T>
512 s042372 26
    class ItemID
27
    {
28
    public:
586 jab 29
        ItemID(): index(INVALID_INDEX){}
511 s042372 30
 
586 jab 31
        bool operator ==(const ItemID& other) const { return index == other.index; }
32
        bool operator !=(const ItemID& other) const { return index != other.index; }
33
        bool operator <(const ItemID& other) const { return index < other.index; }
547 jab 34
 
35
		template<typename X>
36
		friend std::ostream& operator<<(std::ostream& os, const ItemID<X>&);
546 jab 37
 
515 s042372 38
    private:
585 jab 39
        typedef size_t IndexType;
40
        static const IndexType INVALID_INDEX =  -1;
518 s042372 41
 
586 jab 42
        explicit ItemID(IndexType _index): index(_index){}
511 s042372 43
 
515 s042372 44
        friend class ConnectivityKernel;
586 jab 45
 
46
        template<typename ITEM> friend class ItemVector;
47
        template<typename ITEM, typename ITEMID> friend class AttributeVector;
511 s042372 48
 
512 s042372 49
        IndexType index;
50
    };
511 s042372 51
 
547 jab 52
	template<typename T>
53
	inline std::ostream& operator<<(std::ostream& os, const ItemID<T>& iid)
546 jab 54
	{
55
		return (os << iid.index);
56
	}
57
 
511 s042372 58
}
59
 
60
#endif