27 #ifndef __SYNFIG_VALUE_H
28 #define __SYNFIG_VALUE_H
40 #include <ETL/trivial>
52 #include <OpenEXR/half.h>
55 #include <ETL/ref_count>
90 typedef std::vector<ValueBase>
List;
122 template <
typename T>
127 #ifdef INITIALIZE_TYPE_BEFORE_USE
133 template <
typename T>
138 #ifdef INITIALIZE_TYPE_BEFORE_USE
159 {
set(x);
return *
this; }
253 template <
typename T>
263 std::vector<T> out_list;
264 out_list.reserve(list.size());
265 for(List::const_iterator i = list.begin(); i != list.end(); ++i)
267 out_list.push_back(i->get(x));
274 *
this =
List(list.begin(), list.end());
278 String get_string()
const;
283 template <
typename T>
287 template <
typename T>
288 inline void set(
const T& x) { _set(x); }
308 {
return Type::get_type<List>(); }
310 {
return Type::get_type<Canvas*>(); }
312 {
return Type::get_type<ValueNode_Bone*>(); }
314 {
int i[(int)1 - (
int)
sizeof(T)];
return type_nil; }
316 {
int i[(int)1 - (
int)
sizeof(T)];
return type_nil; }
318 {
int i[(int)1 - (
int)
sizeof(T)];
return type_nil; }
347 inline void create() { create(*
type); }
349 template <
typename T>
350 inline static bool _can_get(
const TypeId type,
const T &)
352 typedef typename T::AliasedType TT;
354 Type::get_operation<typename Operation::GenericFuncs<TT>::GetFunc>(
358 template <
typename T>
359 inline static bool _can_put(
const TypeId type,
const T &)
361 typedef typename T::AliasedType TT;
363 Type::get_operation<typename Operation::GenericFuncs<TT>::PutFunc>(
367 template <
typename T>
368 inline static bool _can_set(
const TypeId type,
const T &)
370 typedef typename T::AliasedType TT;
372 Type::get_operation<typename Operation::GenericFuncs<TT>::SetFunc>(
376 template <
typename T>
377 const typename T::AliasedType& _get(
const T &)
const
379 typedef typename T::AliasedType TT;
382 printf(
"%s:%d !is_valid()\n", __FILE__, __LINE__);
385 typename Operation::GenericFuncs<TT>::GetFunc func =
386 Type::get_operation<typename Operation::GenericFuncs<TT>::GetFunc>(
392 assert(func != NULL);
396 template <
typename T>
397 void _put(
const T &,
typename T::AliasedType *x)
const
400 typedef typename T::AliasedType TT;
401 typename Operation::GenericFuncs<TT>::PutFunc func =
402 Type::get_operation<typename Operation::GenericFuncs<TT>::PutFunc>(
404 assert(func != NULL);
409 void __set(
const T &alias,
const typename T::AliasedType &x)
411 typedef typename T::AliasedType TT;
412 #ifdef INITIALIZE_TYPE_BEFORE_USE
413 alias.type.initialize();
416 Type ¤t_type = *
type;
419 typename Operation::GenericFuncs<TT>::SetFunc func =
420 Type::get_operation<typename Operation::GenericFuncs<TT>::SetFunc>(
424 if (!
ref_count.unique()) create(current_type);
430 Type &new_type = alias.type;
431 assert(new_type != current_type);
434 typename Operation::GenericFuncs<TT>::SetFunc func =
435 Type::get_operation<typename Operation::GenericFuncs<TT>::SetFunc>(
437 assert(func != NULL);
445 template <
typename T>