Subversion Repositories gelsvn

Rev

Rev 595 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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

Generated by GNU Enscript 1.6.6.
59

Generated by GNU Enscript 1.6.6.
60
 
60
 
61
 
61
 
62
 
62