29 #ifndef VALUE_ARRAY_ADAPTER_H
30 #define VALUE_ARRAY_ADAPTER_H
47 #define SW16(s) _byteswap_ushort(s)
48 #define SW32(s) _byteswap_ulong(s)
49 #define SW64(s) _byteswap_uint64(s)
51 #include <libkern/OSByteOrder.h>
52 #define SW16(s) __builtin_bswap16( (s) )
53 #define SW32(s) __builtin_bswap32( (s) )
54 #define SW64(s) __builtin_bswap64( (s) )
57 #define SW16(s) bswap_16(s)
58 #define SW32(s) bswap_32(s)
59 #define SW64(s) bswap_64(s)
70 template<
typename TTargetType>
74 template<
typename TSourceType>
75 static TTargetType
Convert (TSourceType src)
77 return static_cast<TTargetType
>(src);
85 template<
typename TSourceType>
96 template<
size_t TValueSize>
100 static void Extract (
const void *src,
void *dst)
102 std::reverse_copy(
reinterpret_cast<const uint8_t*
>(src),
103 reinterpret_cast<const uint8_t*
>(src) + TValueSize,
104 reinterpret_cast<uint8_t*
>(dst));
111 static void Extract (
const void *src,
void *dst)
113 *
reinterpret_cast<uint64_t*
>(dst) =
SW64(*
reinterpret_cast<const uint64_t*
>(src));
120 static void Extract (
const void *src,
void *dst)
122 *
reinterpret_cast<uint32_t*
>(dst) =
SW32(*
reinterpret_cast<const uint32_t*
>(src));
129 static void Extract (
const void *src,
void *dst)
131 *
reinterpret_cast<uint16_t*
>(dst) =
SW16(*
reinterpret_cast<const uint16_t*
>(src));
138 static void Extract (
const void *src,
void *dst)
140 *
reinterpret_cast<uint8_t*
>(dst) = *
reinterpret_cast<const uint8_t*
>(src);
169 void ReadFromPort ();
198 struct ValueArrayInternals;
216 template<
typename TValueNodeType,
typename TOutputValueType,
typename TEffectiveValueType = TOutputValueType>
337 if (!base_value || !selector)
343 INodeMap *node_map = base_value->GetNode()->GetNodeMap();
344 if (node_map != selector->GetNode()->GetNodeMap())
351 CStringPtr candidates_node = node_map->GetNode(
"ValueArrayCandidates");
365 GENICAM_NAMESPACE::gcstring_vector tokens;
366 Tokenize(candidates_str, tokens,
",");
370 +
"[" + selector->GetNode()->GetName() +
"]";
371 return tokens.contains (wanted);
383 template<
typename TFieldType>
408 template<
typename TFieldType>
439 template<
typename TFieldType>
441 const uint8_t *src, TOutputValueType *dst)
443 for (
size_t i = 0; i < num_values; ++i)
445 const uint8_t *field_ptr = src + i * address_step;
447 TFieldType field_value = *
reinterpret_cast<const TFieldType*
>(field_ptr);
448 dst[i] =
static_cast<TOutputValueType
>(
EffectiveValue (field_value));
451 template<
typename TFieldType>
453 const uint8_t *src, TOutputValueType *dst)
455 for (
size_t i = 0; i < num_values; ++i)
457 const uint8_t *field_ptr = src + i * address_step;
459 TFieldType field_value = ReadSwapped<TFieldType> (field_ptr);
460 dst[i] =
static_cast<TOutputValueType
>(
EffectiveValue (field_value));
463 template<
typename TFieldType>
465 uint64_t mask,
size_t shift,
466 const uint8_t *src, TOutputValueType *dst)
468 for (
size_t i = 0; i < num_values; ++i)
470 const uint8_t *field_ptr = src + i * address_step;
472 TFieldType field_value = *
reinterpret_cast<const TFieldType*
>(field_ptr);
473 uint64_t field_bits = mask & (field_value >> shift);
474 dst[i] =
static_cast<TOutputValueType
>(
EffectiveValue (field_bits));
477 template<
typename TFieldType>
479 uint64_t mask,
size_t shift,
480 const uint8_t *src, TOutputValueType *dst)
482 for (
size_t i = 0; i < num_values; ++i)
484 const uint8_t *field_ptr = src + i * address_step;
486 TFieldType field_value = ReadSwapped<TFieldType> (field_ptr);
487 uint64_t field_bits = mask & (field_value >> shift);
488 dst[i] =
static_cast<TOutputValueType
>(
EffectiveValue (field_bits));
515 assert (
false &&
"Signed MaskeIntReg should be refused in constructor");
616 template<
typename TRawType>
622 template<
typename TFieldType>
681 #endif // VALUE_ARRAY_ADAPTER_H