1 #ifndef DALI_INTERNAL_TYPE_ABSTRACTION_H
2 #define DALI_INTERNAL_TYPE_ABSTRACTION_H
5 * Copyright (c) 2021 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
25 #include <dali/internal/common/owner-pointer.h>
26 #include <dali/public-api/object/ref-object.h>
33 * Template helpers to strip of const reference and reference to prevent anyone
34 * from passing references as message parameters
37 // For basic types, they are always pass by copy
38 template<typename Type>
41 using HolderType = Type;
42 using PassingType = Type;
45 // For complex types that are copied into the message,
46 // they are passed as const reference when they don't need to be copied
47 template<typename Type>
50 using HolderType = Type;
51 using PassingType = const Type&;
54 // For complex types that are owned by the message,
55 // They are passed and hold in an OwnerPointer
56 template<typename Type>
59 using HolderType = OwnerPointer<Type>;
60 using PassingType = OwnerPointer<Type>&;
63 // Default for Vector3 and other structures
65 struct ParameterType : public ComplexType<T>
69 // For message owned parameters
71 struct ParameterType<OwnerPointer<T> > : public OwnedType<T>
77 struct ParameterType<T*> : public BasicType<T*>
81 struct ParameterType<const T*> : public BasicType<const T*>
85 struct ParameterType<int> : public BasicType<int>
89 struct ParameterType<unsigned int> : public BasicType<unsigned int>
93 struct ParameterType<float> : public BasicType<float>
97 struct ParameterType<bool> : public BasicType<bool>
101 struct ParameterType<short int> : public BasicType<short int>
105 #if INT_MAX != LONG_MAX
107 struct ParameterType<long> : public BasicType<long>
111 struct ParameterType<unsigned long> : public BasicType<unsigned long>
116 //TODO: Passing intrusive pointers through messages is potentially dangerous,
117 // this should be checked
119 struct ParameterType<IntrusivePtr<T> >
120 : public BasicType<IntrusivePtr<T> >
124 // poorly constructed types, types should not be defined as references
125 // this will trigger a compilation error.
127 struct ParameterType<U&>
131 struct ParameterType<const U&>
135 } //namespace Internal
139 #endif // DALI_INTERNAL_TYPE_ABSTRACTION_H