Création d'un compte pour un collaborateur extérieur au laboratoire depuis l'intranet ICube : https://intranet.icube.unistra.fr/fr/labs/member/profile

attributeHandler.h 4.91 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1
2
3
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
* version 0.1                                                                  *
4
* Copyright (C) 2009-2011, IGG Team, LSIIT, University of Strasbourg           *
Pierre Kraemer's avatar
Pierre Kraemer committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
*                                                                              *
* This library is free software; you can redistribute it and/or modify it      *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your     *
* option) any later version.                                                   *
*                                                                              *
* This library is distributed in the hope that it will be useful, but WITHOUT  *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or        *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License  *
* for more details.                                                            *
*                                                                              *
* You should have received a copy of the GNU Lesser General Public License     *
* along with this library; if not, write to the Free Software Foundation,      *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.           *
*                                                                              *
20
* Web site: http://cgogn.u-strasbg.fr/                                         *
Pierre Kraemer's avatar
Pierre Kraemer committed
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

#ifndef __ATTRIBUTE_HANDLER_H__
#define __ATTRIBUTE_HANDLER_H__

#include <vector>
#include <map>

#include "Topology/generic/genericmap.h"

namespace CGoGN
{

36
37
38
class AttributeHandlerGen
{
protected:
39
40
41
	friend class GenericMap ;
	friend class AttribMap ;

42
	// the map that contains the linked attribute
43
44
45
	GenericMap* m_map ;
	// boolean that states the validity of the handler
	bool valid ;
46
47

public:
48
	AttributeHandlerGen(GenericMap* m, bool v) : m_map(m), valid(v)
49
50
51
52
53
54
	{}

	GenericMap* map() const
	{
		return m_map ;
	}
55

56
57
58
59
60
61
	bool isValid() const
	{
		return valid ;
	}

protected:
62
63
	void setInvalid()
	{
64
		valid = false ;
65
	}
66
} ;
67

Pierre Kraemer's avatar
Pierre Kraemer committed
68
69
/**
 * Class that create an access-table to an existing attribute
Pierre Kraemer's avatar
Pierre Kraemer committed
70
 * Main available operations are:
Pierre Kraemer's avatar
Pierre Kraemer committed
71
72
73
74
75
 * - [ index ]
 * - [ dart ]
 * - begin / end / next to manage indexing
 */
template <typename T>
76
class AttributeHandler : public AttributeHandlerGen
Pierre Kraemer's avatar
Pierre Kraemer committed
77
78
{
protected:
79
	// the multi-vector that contains attribute data
80
	AttributeMultiVector<T>* m_attrib;
Pierre Kraemer's avatar
Pierre Kraemer committed
81

82
83
84
	void registerInMap() ;
	void unregisterFromMap() ;

85
86
87
public:
	typedef T DATA_TYPE ;

88
89
90
91
92
93
	/**
	 * Default constructor
	 * Constructs a non-valid AttributeHandler (i.e. not linked to any attribute)
	 */
	AttributeHandler() ;

Pierre Kraemer's avatar
Pierre Kraemer committed
94
95
96
	/**
	 * Constructor
	 * @param m the map which belong attribute
97
	 * @param amv a pointer to the AttributeMultiVector
Pierre Kraemer's avatar
Pierre Kraemer committed
98
	 */
99
	AttributeHandler(GenericMap* m, AttributeMultiVector<T>* amv) ;
Pierre Kraemer's avatar
Pierre Kraemer committed
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120

	/**
	 * Copy constructor
	 * @param ta the table attribute
	 */
	AttributeHandler(const AttributeHandler<T>& ta) ;

	/**
	 * affectation operator
	 * @param ta the table attribute to affect to this
	 */
	void operator=(const AttributeHandler<T>& ta) ;

	/**
	 * Destructor (empty & virtual)
	 */
	virtual ~AttributeHandler() ;

	/**
	 * get attribute data vector
	 */
121
	AttributeMultiVector<T>* getDataVector() const ;
Pierre Kraemer's avatar
Pierre Kraemer committed
122
123

	/**
124
	 * get attribute orbit
Pierre Kraemer's avatar
Pierre Kraemer committed
125
	 */
126
127
128
129
130
131
	unsigned int getOrbit() const ;

	/**
	 * get attribute index
	 */
	unsigned int getIndex() const ;
Pierre Kraemer's avatar
Pierre Kraemer committed
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163

	/**
	 * get attribute name
	 */
	const std::string& name() const ;

	/**
	 * [] operator with dart parameter
	 */
	T& operator[](Dart d) ;

	/**
	 * const [] operator with dart parameter
	 */
	const T& operator[](Dart d) const ;

	/**
	 * at operator (same as [] but with index parameter)
	 */
	T& operator[](unsigned int a) ;

	/**
	 * const at operator (same as [] but with index parameter)
	 */
	const T& operator[](unsigned int a) const ;

	/**
	 * insert an element (warning we add here a complete line in container)
	 */
	unsigned int insert(const T& elt) ;

	/**
untereiner's avatar
ihm3    
untereiner committed
164
	 * insert an element with default value (warning we add here a complete line in container)
Pierre Kraemer's avatar
Pierre Kraemer committed
165
166
167
	 */
	unsigned int newElt() ;

168
	/**
169
	 * initialize all the lines of the attribute with the given value
170
	 */
171
	void setAllValues(const T& v) ;
172

Pierre Kraemer's avatar
Pierre Kraemer committed
173
174
175
176
177
178
179
	/**
	 * begin of table
	 * @return the iterator of the begin of container
	 */
	unsigned int begin() const;

	/**
180
	 * end of table
Pierre Kraemer's avatar
Pierre Kraemer committed
181
182
183
184
185
	 * @return the iterator of the end of container
	 */
	unsigned int end() const;

	/**
186
	 * Next on iterator (equivalent to stl ++)
Pierre Kraemer's avatar
Pierre Kraemer committed
187
188
189
190
191
192
193
194
195
196
	 * @param iter iterator to
	 */
	void next(unsigned int& iter) const;
} ;

} // namespace CGoGN

#include "Topology/generic/attributeHandler.hpp"

#endif