This file is indexed.

/usr/include/tango/devapi_attr.tpp is in libtango-dev 9.2.5a+dfsg1-2build1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
//+===================================================================================================================
//
// file :               devapi_att.tpp
//
// description :        C++ source code for the Attribute class template methods when they are not specialized and
//						related to attribute value setting
//
// project :            TANGO
//
// author(s) :          E.Taurel
//
// Copyright (C) :      2014,2015
//						European Synchrotron Radiation Facility
//                      BP 220, Grenoble 38043
//                      FRANCE
//
// This file is part of Tango.
//
// Tango 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 3 of the License, or
// (at your option) any later version.
//
// Tango 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 Tango.
// If not, see <http://www.gnu.org/licenses/>.
//
// $Revision: 17240 $
//
//-===================================================================================================================

#ifndef _DEVAPI_ATTR_TPP
#define _DEVAPI_ATTR_TPP

#ifdef HAS_TYPE_TRAITS
	#include <type_traits>
#endif

namespace Tango
{

//+-------------------------------------------------------------------------------------------------------------------
//
// method :
//		DeviceAttribute::DeviceAttribute
//
// description :
//		The DeviceAttribute class constructors used for enumeration. They are implemented as template methods
//
//-------------------------------------------------------------------------------------------------------------------

template <typename T>
DeviceAttribute::DeviceAttribute(string &_name,T _val):ext(new DeviceAttributeExt)
{
	name = _name;
	base_val(_val);
}

template <typename T>
DeviceAttribute::DeviceAttribute(const char *_name,T _val):ext(new DeviceAttributeExt)
{
	name = _name;
	base_val(_val);
}

template <typename T>
void DeviceAttribute::base_val(T _val)
{
	dim_x = 1;
	dim_y = 0;
	w_dim_x = 0;
	w_dim_y = 0;
	quality = Tango::ATTR_VALID;
	data_format = Tango::FMT_UNKNOWN;
	d_state_filled = false;
	exceptions_flags.set(failed_flag);
	exceptions_flags.set(isempty_flag);
	ShortSeq = new(DevVarShortArray);
	ShortSeq->length(1);
	ShortSeq[0] = static_cast<short>(_val);
}

//-----------------------------------------------------------------------------------------------------------------

template <typename T>
DeviceAttribute::DeviceAttribute(string &_name,vector<T> &_val):ext(new DeviceAttributeExt)
{
	name = _name;
	dim_x = _val.size();
	base_vect(_val);
}

template <typename T>
DeviceAttribute::DeviceAttribute(const char *_name,vector<T> &_val):ext(new DeviceAttributeExt)
{
	name = _name;
	dim_x = _val.size();
	base_vect(_val);
}

template <typename T>
void DeviceAttribute::base_vect(vector<T> &_val)
{
	dim_y = 0;
	w_dim_x = 0;
	w_dim_y = 0;
	quality = Tango::ATTR_VALID;
	data_format = Tango::FMT_UNKNOWN;
	d_state_filled = false;
	exceptions_flags.set(failed_flag);
	exceptions_flags.set(isempty_flag);
	ShortSeq = new(DevVarShortArray);
	ShortSeq->length(_val.size());
	for (size_t loop = 0;loop < _val.size();loop++)
		ShortSeq[loop] = static_cast<short>(_val[loop]);
}

//-----------------------------------------------------------------------------------------------------------------

template <typename T>
DeviceAttribute::DeviceAttribute(string &_name,vector<T> &_val,int _x,int _y):ext(new DeviceAttributeExt)
{
	name = _name;
	dim_x = _x;
	dim_y = _y;
	base_vect_size(_val);
}

template <typename T>
DeviceAttribute::DeviceAttribute(const char *_name,vector<T> &_val,int _x,int _y):ext(new DeviceAttributeExt)
{
	name = _name;
	dim_x = _x;
	dim_y = _y;
	base_vect_size(_val);
}

template <typename T>
void DeviceAttribute::base_vect_size(vector<T> &_val)
{
	w_dim_x = 0;
	w_dim_y = 0;
	quality = Tango::ATTR_VALID;
	data_format = Tango::FMT_UNKNOWN;
	d_state_filled = false;
	exceptions_flags.set(failed_flag);
	exceptions_flags.set(isempty_flag);
	ShortSeq = new(DevVarShortArray);
	ShortSeq->length(_val.size());
	for (size_t loop = 0;loop < _val.size();loop++)
		ShortSeq[loop] = static_cast<short>(_val[loop]);
}

//+-------------------------------------------------------------------------------------------------------------------
//
// method :
//		DeviceAttribute::operator >>
//
// description :
//		Extractor method used for enumeration. It is implemented as a template method
//
// argument :
// 		out :
//			- datum : The enumeration to be filled in
//
//-------------------------------------------------------------------------------------------------------------------


template <typename T>
bool DeviceAttribute::operator >> (T &datum)
{
	bool ret = true;

//
// Some check on provided type (for modern compiler...)
//

	ret = template_type_check(datum);

//
// check for available data
//

	if (ret == true)
	{
		ret = check_for_data();
		if (ret == false)
			return false;

		if (ShortSeq.operator->() != NULL)
		{
			if (ShortSeq->length() != 0)
				datum = static_cast<T>(ShortSeq[0]);
			else
				ret = false;
		}
		else
		{
			// check the wrongtype_flag
			ret = check_wrong_type_exception();
		}
	}

	return ret;
}

template <typename T>
bool DeviceAttribute::operator >> (vector<T> &datum)
{
	bool ret = true;

//
// Some check on provided type (for modern compiler...)
//

	T dummy;
	ret = template_type_check(dummy);

//
// check for available data
//

	ret = check_for_data();
	if ( ret == false)
		return false;

	if (ShortSeq.operator->() != NULL)
	{
		if (ShortSeq->length() != 0)
		{
			datum.resize(ShortSeq->length());
			for (size_t i=0; i<ShortSeq->length(); i++)
				datum[i] = static_cast<T>(ShortSeq[i]);
		}
		else
			ret = false;
	}
	else
	{
		// check the wrongtype_flag
		ret = check_wrong_type_exception();
	}
	return ret;
}

template <typename T>
bool DeviceAttribute::extract_read (vector<T> &_data)
{
	bool ret = true;

//
// Some check on provided type (for modern compiler...)
//

	T dummy;
	ret = template_type_check(dummy);

//
// check for available data
//

	ret = check_for_data();
	if ( ret == false)
		return false;

	if (ShortSeq.operator->() != NULL)
	{
		if (ShortSeq->length() != 0)
		{
			size_t length = get_nb_read();
			_data.resize(length);
         	for (size_t i=0; i<length; i++)
         		_data[i] = static_cast<T>(ShortSeq[i]);
		}
		else
			ret = false;
	}
	else
	{
		// check the wrongtype_flag
		ret = check_wrong_type_exception();
	}
	return ret;
}

template <typename T>
bool DeviceAttribute::extract_set(vector<T> &_data)
{
	bool ret = true;

//
// Some check on provided type (for modern compiler...)
//

	T dummy;
	ret = template_type_check(dummy);

//
// check for available data
//

	ret = check_for_data();
	if ( ret == false)
		return false;

	if (ShortSeq.operator->() != NULL)
	{
		if (ShortSeq->length() != 0)
		{
			// check the size of the setpoint values
			long read_length = check_set_value_size (ShortSeq->length());

			// copy the set point values to the vector
			_data.resize(ShortSeq->length() - read_length);
			unsigned int k = 0;
         	for (unsigned int i=read_length; i<ShortSeq->length(); i++, k++)
         		_data[k] = static_cast<T>(ShortSeq[i]);
		}
		else
			ret = false;
	}
	else
	{
		// check the wrongtype_flag
		ret = check_wrong_type_exception();
	}
	return ret;
}

//+-------------------------------------------------------------------------------------------------------------------
//
// method :
//		DeviceAttribute::operator <<
//
// description :
//		Insertor method used for enumeration. It is implemented as a template method
//
// argument :
// 		out :
//			- datum : The enumeration to be filled in
//
//-------------------------------------------------------------------------------------------------------------------

template <typename T>
void DeviceAttribute::operator << (T datum)
{
	template_type_check(datum);

	dim_x = 1;
	dim_y = 0;
	w_dim_x = 0;
	w_dim_y = 0;
	quality = Tango::ATTR_VALID;
	data_format = Tango::FMT_UNKNOWN;

    DevVarShortArray *short_vararr = new(DevVarShortArray);
    short_vararr->length(1);
    (*short_vararr)[0] = static_cast<short>(datum);
    ShortSeq = short_vararr;

	del_mem(Tango::DEV_SHORT);
}

template <typename T>
void DeviceAttribute::operator << (vector<T> &_datum)
{
	T dummy;
	template_type_check(dummy);

	dim_x = _datum.size();
	dim_y = 0;
	w_dim_x = 0;
	w_dim_y = 0;
	quality = Tango::ATTR_VALID;
	data_format = Tango::FMT_UNKNOWN;

	if (ShortSeq.operator->() == NULL)
	{
		DevVarShortArray *short_vararr = new(DevVarShortArray);
		ShortSeq = short_vararr;
	}
	ShortSeq->length(_datum.size());
	for (size_t loop = 0;loop < _datum.size();loop++)
		ShortSeq[loop] = static_cast<short>(_datum[loop]);

	del_mem(Tango::DEV_SHORT);
}

template <typename T>
void DeviceAttribute::insert(vector<T> &_datum,int _x,int _y)
{
	*this << _datum;
	dim_x = _x;
	dim_y = _y;
}

template <typename T>
bool DeviceAttribute::template_type_check(T &_datum)
{
#ifdef HAS_UNDERLYING
	bool short_enum = is_same<short,typename underlying_type<T>::type>::value;
	bool uns_int_enum = is_same<unsigned int,typename underlying_type<T>::type>::value;

	if (short_enum == false && uns_int_enum == false)
	{
		if (exceptions_flags.test(wrongtype_flag))
		{
			ApiDataExcept::throw_exception("API_IncompatibleAttrArgumentType",
			"Type provided for insertion is not a valid enum. Only C enum or C++11 enum with underlying short data type are supported",
			"DeviceAttribute::operator<<");
		}

		return false;
	}
#endif // HAS_UNDERLYING

#ifdef HAS_TYPE_TRAITS
	if (is_enum<T>::value == false)
	{
		if (exceptions_flags.test(wrongtype_flag))
		{
			ApiDataExcept::throw_exception("API_IncompatibleAttrArgumentType",
			"Type provided for insertion is not an enumeration",
			"DeviceAttribute::operator<<");
		}

		return false;
	}
#endif // HAS_TYPE_TRAITS

	return true;
}

} // End of Tango namespace
#endif // _DEVAPI_ATTR_TPP