Loading...
Searching...
No Matches
typeFunctions.h
Go to the documentation of this file.
1//
2// Copyright 2016 Pixar
3//
4// Licensed under the Apache License, Version 2.0 (the "Apache License")
5// with the following modification; you may not use this file except in
6// compliance with the Apache License and the following modification to it:
7// Section 6. Trademarks. is deleted and replaced with:
8//
9// 6. Trademarks. This License does not grant permission to use the trade
10// names, trademarks, service marks, or product names of the Licensor
11// and its affiliates, except as required to comply with Section 4(c) of
12// the License and to reproduce the content of the NOTICE file.
13//
14// You may obtain a copy of the Apache License at
15//
16// http://www.apache.org/licenses/LICENSE-2.0
17//
18// Unless required by applicable law or agreed to in writing, software
19// distributed under the Apache License with the above modification is
20// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21// KIND, either express or implied. See the Apache License for the specific
22// language governing permissions and limitations under the Apache License.
23//
24#ifndef PXR_BASE_TF_TYPE_FUNCTIONS_H
25#define PXR_BASE_TF_TYPE_FUNCTIONS_H
26
29
30#include "pxr/pxr.h"
31
32#include <memory>
33
34PXR_NAMESPACE_OPEN_SCOPE
35
53template <class T, class ENABLE = void>
55#if 0
56 static T* GetRawPtr(T& t) {
57 return &t;
58 }
59#endif
60
61 static const T* GetRawPtr(const T& t) {
62 return &t;
63 }
64
65 static T& ConstructFromRawPtr(T* ptr) { return *ptr; }
66
67 static bool IsNull(const T&) {
68 return false;
69 }
70
71 static void Class_Object_MUST_Not_Be_Const() { }
72 static void Object_CANNOT_Be_a_Pointer() { }
73};
74
75template <class T>
76struct TfTypeFunctions<T*> {
77 static T* GetRawPtr(T* t) {
78 return t;
79 }
80
81 static T* ConstructFromRawPtr(T* ptr) { return ptr; }
82
83 static bool IsNull(T* ptr) {
84 return !ptr;
85 }
86
87 static void Class_Object_MUST_Be_Passed_By_Address() { }
88 static void Class_Object_MUST_Not_Be_Const() { }
89};
90
91template <class T>
92struct TfTypeFunctions<const T*> {
93 static const T* GetRawPtr(const T* t) {
94 return t;
95 }
96
97 static bool IsNull(const T* ptr) {
98 return !ptr;
99 }
100
101 static const T* ConstructFromRawPtr(T* ptr) { return ptr; }
102 static void Class_Object_MUST_Be_Passed_By_Address() { }
103};
104
105PXR_NAMESPACE_CLOSE_SCOPE
106
107#endif // PXR_BASE_TF_TYPE_FUNCTIONS_H
Implements assorted functions based on compile-time type information.
Definition: typeFunctions.h:54