Caffa  1.1.0
C++ Application Framework for Embedded Systems with introspection
cafTypedField.h
1 // ##################################################################################################
2 //
3 // Custom Visualization Core library
4 // Copyright (C) 2011-2013 Ceetron AS
5 //
6 // This library may be used under the terms of either the GNU General Public License or
7 // the GNU Lesser General Public License as follows:
8 //
9 // GNU General Public License Usage
10 // This library is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // This library is distributed in the hope that it will be useful, but WITHOUT ANY
16 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 // FITNESS FOR A PARTICULAR PURPOSE.
18 //
19 // See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
20 // for more details.
21 //
22 // GNU Lesser General Public License Usage
23 // This library is free software; you can redistribute it and/or modify
24 // it under the terms of the GNU Lesser General Public License as published by
25 // the Free Software Foundation; either version 2.1 of the License, or
26 // (at your option) any later version.
27 //
28 // This library is distributed in the hope that it will be useful, but WITHOUT ANY
29 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
30 // FITNESS FOR A PARTICULAR PURPOSE.
31 //
32 // See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
33 // for more details.
34 //
35 // ##################################################################################################
36 #pragma once
37 
38 #include "cafDataFieldAccessor.h"
39 #include "cafFieldHandle.h"
40 #include "cafPortableDataType.h"
41 
42 #include <typeinfo>
43 
44 namespace caffa
45 {
46 // Type traits magic to check if a template argument is a vector
47 template <typename T>
48 struct is_vector : public std::false_type
49 {
50 };
51 template <typename T, typename A>
52 struct is_vector<std::vector<T, A>> : public std::true_type
53 {
54 };
55 
56 template <typename T>
57 concept IsVector = is_vector<T>::value;
58 
59 class DataField : public FieldHandle
60 {
61 public:
62  virtual void setUntypedAccessor( std::unique_ptr<DataFieldAccessorInterface> accessor ) = 0;
63 };
64 
65 template <typename DataType>
66 class TypedField : public DataField
67 {
68 public:
69  using FieldDataType = DataType;
70 
71 public:
72  virtual DataType value() const = 0;
73  virtual void setValue( const DataType& fieldValue ) = 0;
74 
75  std::string dataType() const override { return PortableDataType<DataType>::name(); }
76 };
77 
78 } // End of namespace caffa
Definition: cafTypedField.h:60
Base class for all fields, making it possible to handle them generically.
Definition: cafFieldHandle.h:23
Definition: cafTypedField.h:67
Main Caffa namespace.
Definition: __init__.py:1
Definition: cafPortableDataType.h:35
Definition: cafTypedField.h:49