This file is indexed.

/usr/include/synfig-1.0/synfig/value.h is in libsynfig-dev 1.0.2-1.

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
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
/* === S Y N F I G ========================================================= */
/*!	\file value.h
**	\brief Template Header
**
**	$Id$
**
**	\legal
**	Copyright (c) 2002-2005 Robert B. Quattlebaum Jr., Adrian Bentley
**	Copyright (c) 2007, 2008 Chris Moore
**  Copyright (c) 2011 Carlos López
**
**	This package is free software; you can redistribute it and/or
**	modify it under the terms of the GNU General Public License as
**	published by the Free Software Foundation; either version 2 of
**	the License, or (at your option) any later version.
**
**	This package 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
**	General Public License for more details.
**	\endlegal
*/
/* ========================================================================= */

/* === S T A R T =========================================================== */

#ifndef __SYNFIG_VALUE_H
#define __SYNFIG_VALUE_H

/* === H E A D E R S ======================================================= */

#include "base_types.h"

// TODO: remove following includes
#include "angle.h"
#include "segment.h"
#include "string.h"
#include <list>
#include <vector>
#include <ETL/trivial>
#include <ETL/handle>
#include "general.h"
#include "blinepoint.h"
#include "bone.h"
#include "widthpoint.h"
#include "dashitem.h"
#include "exception.h"
#include "interpolation.h"
#include "transformation.h"

#ifdef USE_HALF_TYPE
#include <OpenEXR/half.h>
#endif

#include <ETL/ref_count>

/* === M A C R O S ========================================================= */

/* === T Y P E D E F S ===================================================== */

/* === C L A S S E S & S T R U C T S ======================================= */

namespace synfig {

// TODO: remove following predeclarations
class Canvas;
class Vector;
class Time;
struct Segment;
class Gradient;
class BLinePoint;
class WidthPoint;
class DashItem;
class Color;
class Bone;
class ValueNode_Bone;
class Matrix;
class BoneWeightPair;

/*!	\class ValueBase
**	\brief Base class for the Values of Synfig
*/
class ValueBase
{
	/*
 --	** -- T Y P E S -----------------------------------------------------------
	*/

public:
	typedef std::vector<ValueBase> List;

	/*
 --	** -- D A T A -------------------------------------------------------------
	*/

protected:
	//! The type of value
	Type *type;
	//! Pointer to hold the data of the value
	void *data;
	//! Counter of Value Nodes that refers to this Value Base
	//! Value base can only be destructed if the ref_count is not greater than 0
	//!\see etl::reference_counter
	etl::reference_counter ref_count;
	//! For Values with loop option like TYPE_LIST
	bool loop_;
	//! For Values of Constant Value Nodes
	bool static_;
	//! Parameter interpolation
	Interpolation interpolation_;

	/*
 --	** -- C O N S T R U C T O R S -----------------------------------
	*/

public:

	//! Default constructor
	ValueBase();

	//! Template constructor for any type
	template <typename T>
	ValueBase(const T &x, bool loop_=false, bool static_=false):
		type(&type_nil),data(0),ref_count(0),loop_(loop_), static_(static_),
		interpolation_(INTERPOLATION_UNDEFINED)
	{
#ifdef INITIALIZE_TYPE_BEFORE_USE
		type->initialize();
#endif
		set(x);
	}

	template <typename T>
	ValueBase(const std::vector<T> &x, bool loop_=false, bool static_=false):
		type(&type_nil),data(0),ref_count(0),loop_(loop_), static_(static_),
		interpolation_(INTERPOLATION_UNDEFINED)
	{
#ifdef INITIALIZE_TYPE_BEFORE_USE
		type->initialize();
#endif
		set_list_of(x);
	}

	//! Copy constructor. The data is not copied, just the type.
	ValueBase(Type &x);

	//! Default destructor
	~ValueBase();

	/*
 --	** -- O P E R A T O R S ---------------------------------------------------
	*/

public:

	//! Template for the operator assignation operator for non ValueBase classes
	//! \see set()
	template <class T> ValueBase& operator=(const T& x)
		{ set(x); return *this; }

	//!Operator asignation for ValueBase classes. Does a exact copy of \x
	ValueBase& operator=(const ValueBase& x);

	//! Eqaul than operator. Segment, Gradient and Bline Points cannot be compared.
	bool operator==(const ValueBase& rhs)const;

	//! Not equal than operator.
	bool operator!=(const ValueBase& rhs)const { return !operator==(rhs); }

	//!	Constant index operator for when value is of type TYPE_LIST
	const ValueBase &operator[](int index)const
		{ assert(type==&type_list); assert(index>0); return get_list()[index]; }

	/*
 --	** -- M E M B E R   F U N C T I O N S -------------------------------------
	*/

public:

	//! Deletes the data only if the ref count is zero
	void clear();

	//! Gets the loop option.
	bool get_loop()const { return loop_; }

	//! Sets the loop option.
	void set_loop(bool x) { loop_=x; }

	//! Gets the static option.
	bool get_static()const { return static_; }

	//! Sets the static option.
	void set_static(bool x) { static_=x; }

	//! Gets the interpolation.
	Interpolation get_interpolation()const { return interpolation_; }

	//! Sets the interpolation.
	void set_interpolation(Interpolation x) { interpolation_=x; }
	
	//! Create independent copy from existing ValueBase object
	void copy(const ValueBase& x);

	//! Copies properties (static, interpolation, etc) from other ValueBase object.
	void copy_properties_of(const ValueBase& x);

	//! True if the Value is not valid or is type LIST and is empty
	bool empty()const;

	//! Gets the contained type in the Value Base
	Type& get_contained_type()const;

	//! Returns true if the contained value is defined and valid.
	bool is_valid()const;

	//!	Returns a string containing the name of the type. Used for sif files
	String type_name()const { return type->description.name; }

	//! Returns the type of the contained value
	Type& get_type()const { return *type; }

	template<typename T>
	inline static bool can_get(const TypeId type, const T &x)
		{ return _can_get(type, types_namespace::get_type_alias(x)); }
	template<typename T>
	inline static bool can_get(const Type& type, const T &x) { return can_get(type.identifier, x); }
	template<typename T>
	inline static bool can_set(const TypeId type, const T &x)
		{ return _can_set(type, types_namespace::get_type_alias(x)); }
	template<typename T>
	inline static bool can_set(const Type& type, const T &x) { return can_set(type.identifier, x); }
	template<typename T>
	inline static bool can_put(const TypeId type, const T &x)
		{ return _can_put(type, types_namespace::get_type_alias(x)); }
	template<typename T>
	inline static bool can_put(const Type& type, const T &x) { return can_put(type.identifier, x); }
	inline static bool can_copy(const TypeId dest, const TypeId src)
		{ return NULL != Type::get_operation<Operation::CopyFunc>(Operation::Description::get_copy(dest, src)); }
	inline static bool can_copy(const Type& dest, const Type& src) { return can_copy(dest.identifier, src.identifier); }

	template<typename T> inline bool can_get(const T &x) const { return is_valid() && can_get(*type, x); }
	template<typename T> inline bool can_set(const T &x) const { return can_set(*type, x); }
	template<typename T> inline bool can_put(const T &x) const { return is_valid() && can_put(*type, x); }
	bool can_copy_from(const TypeId type) const { return can_copy(this->type->identifier, type); }
	bool can_copy_from(const Type& type) const { return can_copy(*this->type, type); }
	bool can_copy_to(const TypeId type) const { return can_copy(type, this->type->identifier); }
	bool can_copy_to(const Type& type) const { return can_copy(type, *this->type); }

	template<typename T> bool same_type_as(const T&x) const { return can_get(x) && can_set(x) && can_put(x); }

	// === GET MEMBERS ========================================================
	//! Template to get the ValueBase class data by casting the type
	template <typename T>
	inline const T &get(const T &x)const { return (const T&)_get(types_namespace::get_type_alias(x)); }

	//! Gets the data as List Type
	const List& get_list()const { return get(List()); }

	template<typename T>
	std::vector<T> get_list_of(const T &x)const
	{
		const List &list = get_list();
		std::vector<T> out_list;
		out_list.reserve(list.size());
		for(List::const_iterator i = list.begin(); i != list.end(); ++i)
			if (i->can_get(x))
				out_list.push_back(i->get(x));
		return out_list;
	}

	template<typename T>
	void set_list_of(const std::vector<T> &list)
	{
		*this = List(list.begin(), list.end());
	}

#ifdef _DEBUG
	String get_string() const;
#endif	// _DEBUG
	// ========================================================================

	//! Put template for any class
	template <typename T>
	inline void put(T* x)const { _put(types_namespace::get_type_alias(*x), x); }

	//! Set template for any class
	template <typename T>
	inline void set(const T& x) { _set(x); }


	/*
 --	** -- S T A T I C   F U N C T I O N S -------------------------------------
	*/

public:
	//!	Returns a the corresponding Type of the described type.
	//! Notice that this is used in the loadcanvas. It should keep all
	//! all type names used in previous sif files
	static Type& ident_type(const String &str);


	// === GET TYPE MEMBERS ===================================================
	template<typename T>
	static Type& get_type(const T&) { return Type::get_type<T>(); }

	// TODO: remove this, when removed all references in code
	static Type& get_type(const List &)
		{ return Type::get_type<List>(); }
	static Type& get_type(Canvas* const &)
		{ return Type::get_type<Canvas*>(); }
	static Type& get_type(ValueNode_Bone* const &)
		{ return Type::get_type<ValueNode_Bone*>(); }
	template <typename T> static Type& get_type(const T* &)
		{ int i[(int)1 - (int)sizeof(T)]; return type_nil; }
	template <typename T> static Type& get_type(const std::vector<T> &)
		{ int i[(int)1 - (int)sizeof(T)]; return type_nil; }
	template <typename T> static Type& get_type(const std::list<T> &)
		{ int i[(int)1 - (int)sizeof(T)]; return type_nil; }
	// ========================================================================


	/*
 --	** -- C A S T   O P E R A T O R S -----------------------------------------
	*/

public:
	//! I wonder why are those casting operators disabled...
	/*
	template<typename T>
	operator const T&() const
	{
		Type &t = Type::get_type<T>();
		Operation::GenericFuncs<T>::GetFunc func =
			Type::get_operation<Operation::GenericFuncs<T>::GetFunc>(
				Operation::Description::get_get(t.identifier) );
		assert(func != NULL);
		return func(data);
	}
	*/

	/*
 --	** -- O T H E R -----------------------------------------------------------
	*/

private:
	void create(Type &type);
	inline void create() { create(*type); }

	template <typename T>
	inline static bool _can_get(const TypeId type, const T &)
	{
		typedef typename T::AliasedType TT;
		return NULL !=
			Type::get_operation<typename Operation::GenericFuncs<TT>::GetFunc>(
				Operation::Description::get_get(type) );
	}

	template <typename T>
	inline static bool _can_put(const TypeId type, const T &)
	{
		typedef typename T::AliasedType TT;
		return NULL !=
			Type::get_operation<typename Operation::GenericFuncs<TT>::PutFunc>(
				Operation::Description::get_put(type) );
	}

	template <typename T>
	inline static bool _can_set(const TypeId type, const T &)
	{
		typedef typename T::AliasedType TT;
		return NULL !=
			Type::get_operation<typename Operation::GenericFuncs<TT>::SetFunc>(
				Operation::Description::get_set(type) );
	}

	template <typename T>
	const typename T::AliasedType& _get(const T &)const
	{
		typedef typename T::AliasedType TT;
#ifdef _DEBUG
		if (!is_valid())
			printf("%s:%d !is_valid()\n", __FILE__, __LINE__);
#endif
		assert(is_valid());
		typename Operation::GenericFuncs<TT>::GetFunc func =
			Type::get_operation<typename Operation::GenericFuncs<TT>::GetFunc>(
				Operation::Description::get_get(type->identifier) );
#ifdef _DEBUG
		if (func == NULL)
			printf("%s:%d %s get_func == NULL\n", __FILE__, __LINE__, type->description.name.c_str());
#endif
		assert(func !=  NULL);
		return func(data);
	}

	template <typename T>
	void _put(const T &, typename T::AliasedType *x)const
	{
		assert(is_valid());
		typedef typename T::AliasedType TT;
		typename Operation::GenericFuncs<TT>::PutFunc func =
			Type::get_operation<typename Operation::GenericFuncs<TT>::PutFunc>(
				Operation::Description::get_put(type->identifier) );
		assert(func !=  NULL);
		func(*x, data);
	}

	template<typename T>
	void __set(const T &alias, const typename T::AliasedType &x)
	{
		typedef typename T::AliasedType TT;
#ifdef INITIALIZE_TYPE_BEFORE_USE
		alias.type.initialize();
#endif

		Type &current_type = *type;
		if (current_type != type_nil)
		{
			typename Operation::GenericFuncs<TT>::SetFunc func =
				Type::get_operation<typename Operation::GenericFuncs<TT>::SetFunc>(
					Operation::Description::get_set(current_type.identifier) );
			if (func != NULL)
			{
				if (!ref_count.unique()) create(current_type);
				func(data, x);
				return;
			}
		}

		Type &new_type = alias.type;
		assert(new_type != current_type);
		assert(new_type != type_nil);

		typename Operation::GenericFuncs<TT>::SetFunc func =
			Type::get_operation<typename Operation::GenericFuncs<TT>::SetFunc>(
				Operation::Description::get_set(new_type.identifier) );
		assert(func != NULL);

		create(new_type);
		assert(*type != type_nil);
		func(data, x);
	}

	//! Internal set template. Takes in consideration the reference counter
	template <typename T>
	inline void _set(const T& x) { __set(types_namespace::get_type_alias(x), x); }

}; // END of class ValueBase


/*!	\class Value
**	\brief Template for all the valid Value Types
*/
template <class T>
class Value : public ValueBase
{
public:
	Value(const T &x):ValueBase(x) { }
	Value(const ValueBase &x):ValueBase(x) { }
	T get()const { return ValueBase::get(T()); }
	void put(T* x)const	{ ValueBase::put(x); }
	void set(const T& x) { ValueBase::operator=(x); }
	Value<T>& operator=(const T& x) { set(x); return *this; }
	Value<T>& operator=(const Value<T>& x) { return ValueBase::operator=(x); }
	Value<T>& operator=(const ValueBase& x) { return ValueBase::operator=(x); }

}; // END of class Value

}; // END of namespace synfig

/* === E N D =============================================================== */

#endif