All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
purpose.h
1 //
2 // Copyright 2017 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 __GUSD_PURPOSE_H__
25 #define __GUSD_PURPOSE_H__
26 
27 #include <UT/UT_StringArray.h>
28 #include <UT/UT_StringHolder.h>
29 
30 #include "pxr/pxr.h"
31 #include "pxr/usd/usdGeom/tokens.h"
32 
33 #include "gusd/api.h"
34 
35 
36 PXR_NAMESPACE_OPEN_SCOPE
37 
38 
39 enum GusdPurposeSet {
40  GUSD_PURPOSE_NONE = 0x00,
41  GUSD_PURPOSE_DEFAULT = 0x01,
42  GUSD_PURPOSE_PROXY = 0x02,
43  GUSD_PURPOSE_RENDER = 0x04,
44  GUSD_PURPOSE_GUIDE = 0x08,
45 };
46 
47 
48 GUSD_API
49 inline GusdPurposeSet
50 GusdPurposeSetFromName(const UT_StringRef& name)
51 {
52  if(name == UsdGeomTokens->default_)
53  return GUSD_PURPOSE_DEFAULT;
54  else if(name == UsdGeomTokens->proxy)
55  return GUSD_PURPOSE_PROXY;
56  else if(name == UsdGeomTokens->render)
57  return GUSD_PURPOSE_RENDER;
58  else if(name == UsdGeomTokens->guide)
59  return GUSD_PURPOSE_GUIDE;
60  return GUSD_PURPOSE_NONE;
61 }
62 
63 
64 GUSD_API
65 inline GusdPurposeSet
66 GusdPurposeSetFromName(const TfToken& name)
67 {
68  if(name == UsdGeomTokens->default_)
69  return GUSD_PURPOSE_DEFAULT;
70  else if(name == UsdGeomTokens->proxy)
71  return GUSD_PURPOSE_PROXY;
72  else if(name == UsdGeomTokens->render)
73  return GUSD_PURPOSE_RENDER;
74  else if(name == UsdGeomTokens->guide)
75  return GUSD_PURPOSE_GUIDE;
76  return GUSD_PURPOSE_NONE;
77 }
78 
79 
80 GUSD_API
81 inline bool
82 GusdPurposeInSet( const TfToken& name, GusdPurposeSet set )
83 {
84  return set&GusdPurposeSetFromName(name);
85 }
86 
87 
90 GUSD_API
91 GusdPurposeSet GusdPurposeSetFromArray(const UT_StringArray& purposes);
92 
93 GUSD_API
94 GusdPurposeSet GusdPurposeSetFromArray(const TfTokenVector& purposes);
96 
97 
99 GUSD_API
100 TfTokenVector GusdPurposeSetToTokens(GusdPurposeSet purposes);
101 
102 
104 GUSD_API
105 UT_StringArray GusdPurposeSetToStrings(GusdPurposeSet purposes);
106 
107 
109 GUSD_API
110 GusdPurposeSet GusdPurposeSetFromMask(const char* mask);
111 
112 
113 PXR_NAMESPACE_CLOSE_SCOPE
114 
115 #endif // __GUSD_PURPOSE_H__
Token for efficient comparison, assignment, and hashing of known strings.
Definition: token.h:89
USDGEOM_API TfStaticData< UsdGeomTokensType > UsdGeomTokens
A global variable with static, efficient TfTokens for use in all public USD API.
std::vector< TfToken > TfTokenVector
Convenience types.
Definition: token.h:438