Tf module
Summary: The Tf (Tools Foundations) module.
Tf – Tools Foundation
Exceptions:
|
Classes:
|
A named temporary file which keeps the internal file handle closed. |
A TfNotice that is sent when a script module is loaded. |
|
Provides tracking of |
|
This class is used to provide high-level descriptions about scopes of execution that could possibly block, or to provide relevant information about high-level action that would be useful in a crash report. |
|
Provides low-level facilities for shared modules with script bindings to register themselves with their dependences, and provides a mechanism whereby those script modules will be loaded when necessary. |
|
TfType represents a dynamic runtime type. |
|
Functions:
|
Raise a fatal error to the Tf Diagnostic system. |
|
Returns a tuple (moduleName, functionName, fileName, lineNo). |
|
PrepareModule(module, result) -- Prepare an extension module at import time. |
|
Prepare an extension module at import time. |
|
Raise a coding error to the Tf Diagnostic system. |
|
Raise a runtime error to the Tf Diagnostic system. |
|
Issues a status update to the Tf diagnostic system. |
|
Issue a warning via the TfDiagnostic system. |
- exception pxr.Tf.CppException
- exception pxr.Tf.ErrorException(*args)
- class pxr.Tf.CallContext
Attributes:
char
char
int
char
- property file
char
- Type
type
- property function
char
- Type
type
- property line
int
- Type
type
- property prettyFunction
char
- Type
type
- class pxr.Tf.Debug
Methods:
classmethod GetDebugSymbolDescription(name) -> str
classmethod GetDebugSymbolDescriptions() -> str
classmethod GetDebugSymbolNames() -> list[str]
classmethod IsDebugSymbolNameEnabled(name) -> bool
classmethod SetDebugSymbolsByName(pattern, value) -> list[str]
classmethod SetOutputFile(file) -> None
- static GetDebugSymbolDescription()
classmethod GetDebugSymbolDescription(name) -> str
Get a description for the specified debug symbol.
A short description of the debug symbol is returned. This is the same description string that is embedded in the return value of GetDebugSymbolDescriptions.
- Parameters
name (str) –
- static GetDebugSymbolDescriptions()
classmethod GetDebugSymbolDescriptions() -> str
Get a description of all debug symbols and their purpose.
A single string describing all registered debug symbols along with short descriptions is returned.
- static GetDebugSymbolNames()
classmethod GetDebugSymbolNames() -> list[str]
Get a listing of all debug symbols.
- static IsDebugSymbolNameEnabled()
classmethod IsDebugSymbolNameEnabled(name) -> bool
True if the specified debug symbol is set.
- Parameters
name (str) –
- static SetDebugSymbolsByName()
classmethod SetDebugSymbolsByName(pattern, value) -> list[str]
Set registered debug symbols matching
pattern
tovalue
.All registered debug symbols matching
pattern
are set tovalue
. The only matching is an exact match withpattern
, or ifpattern
ends with an’*’as is otherwise a prefix of a debug symbols. The names of all debug symbols set by this call are returned as a vector.- Parameters
pattern (str) –
value (bool) –
- static SetOutputFile()
classmethod SetOutputFile(file) -> None
Direct debug output to either stdout or stderr.
Note that file MUST be either stdout or stderr. If not, issue an error and do nothing. Debug output is issued to stdout by default. If the environment variable TF_DEBUG_OUTPUT_FILE is set to’stderr’, then output is issued to stderr by default.
- Parameters
file (FILE) –
- class pxr.Tf.DiagnosticType
Methods:
Attributes:
- static GetValueFromName()
- allValues = (Tf.TF_DIAGNOSTIC_CODING_ERROR_TYPE, Tf.TF_DIAGNOSTIC_FATAL_CODING_ERROR_TYPE, Tf.TF_DIAGNOSTIC_RUNTIME_ERROR_TYPE, Tf.TF_DIAGNOSTIC_FATAL_ERROR_TYPE, Tf.TF_DIAGNOSTIC_NONFATAL_ERROR_TYPE, Tf.TF_DIAGNOSTIC_WARNING_TYPE, Tf.TF_DIAGNOSTIC_STATUS_TYPE, Tf.TF_APPLICATION_EXIT_TYPE)
- class pxr.Tf.Enum
Methods:
classmethod GetValueFromFullName(fullname, foundIt) -> Enum
- static GetValueFromFullName()
classmethod GetValueFromFullName(fullname, foundIt) -> Enum
Returns the enumerated value for a fully-qualified name.
This takes a fully-qualified enumerated value name (e.g.,
"Season::WINTER"
) and returns the associated value. If there is no such name, this returns -1. Since -1 can sometimes be a valid value, thefoundIt
flag pointer, if notNone
, is set totrue
if the name was found andfalse
otherwise. Also, since this is not a templated function, it has to return a generic value type, so we useTfEnum
.- Parameters
fullname (str) –
foundIt (bool) –
- class pxr.Tf.Error
Classes:
Attributes:
The error code posted for this error.
The error code posted for this error, as a string.
- class Mark
Methods:
A list of the errors held by this mark.
- Clear()
- GetErrors()
A list of the errors held by this mark.
- IsClean()
- SetMark()
- property errorCode
The error code posted for this error.
- property errorCodeString
The error code posted for this error, as a string.
- class pxr.Tf.MallocTag
Classes:
Methods:
classmethod GetCallTree(tree, skipRepeated) -> bool
classmethod GetMaxTotalBytes() -> int
classmethod GetTotalBytes() -> int
classmethod Initialize(errMsg) -> bool
classmethod IsInitialized() -> bool
classmethod SetCapturedMallocStacksMatchList(matchList) -> None
classmethod SetDebugMatchList(matchList) -> None
- class CallTree
Classes:
Methods:
- class PathNode
Methods:
Attributes:
- GetChildren()
- property nAllocations
- property nBytes
- property nBytesDirect
- property siteName
- GetCallSites()
- GetPrettyPrintString()
- GetRoot()
- LogReport()
- Report()
- static GetCallStacks()
- static GetCallTree()
classmethod GetCallTree(tree, skipRepeated) -> bool
Return a snapshot of memory usage.
Returns a snapshot by writing into
\*tree
. See theC
*tree structure for documentation. IfInitialize()
has not been called, *tree is set to a rather blank structure (empty vectors, empty strings, zero in all integral fields) andfalse
is returned; otherwise,\*tree
is set with the contents of the current memory snapshot andtrue
is returned. It is fine to call this function on the same\*tree
instance; each call simply overwrites the data from the last call. If /p skipRepeated istrue
, then any repeated callsite is skipped. See theCallTree
documentation for more details.- Parameters
tree (CallTree) –
skipRepeated (bool) –
- static GetMaxTotalBytes()
classmethod GetMaxTotalBytes() -> int
Return the maximum total number of bytes that have ever been allocated at one time.
This is simply the maximum value of GetTotalBytes() since Initialize() was called.
- static GetTotalBytes()
classmethod GetTotalBytes() -> int
Return total number of allocated bytes.
The current total memory that has been allocated and not freed is returned. Memory allocated before calling
Initialize()
is not accounted for.
- static Initialize()
classmethod Initialize(errMsg) -> bool
Initialize the memory tagging system.
This function returns
true
if the memory tagging system can be successfully initialized or it has already been initialized. Otherwise,\*errMsg
is set with an explanation for the failure.Until the system is initialized, the various memory reporting calls will indicate that no memory has been allocated. Note also that memory allocated prior to calling
Initialize()
is not tracked i.e. all data refers to allocations that happen subsequent to callingInitialize()
.- Parameters
errMsg (str) –
- static IsInitialized()
classmethod IsInitialized() -> bool
Return true if the tagging system is active.
If
Initialize()
has been successfully called, this function returnstrue
.
- static SetCapturedMallocStacksMatchList()
classmethod SetCapturedMallocStacksMatchList(matchList) -> None
Sets the tags to trace.
When memory is allocated for any tag that matches
matchList
a stack trace is recorded. When that memory is released the stack trace is discarded. Clients can callGetCapturedMallocStacks()
to get a list of all recorded stack traces. This is useful for finding leaks.Traces recorded for any tag that will no longer be matched are discarded by this call. Traces recorded for tags that continue to be matched are retained.
matchList
is a comma, tab or newline separated list of malloc tag names. The names can have internal spaces but leading and trailing spaces are stripped. If a name ends in’*’then the suffix is wildcarded. A name can have a leading’-‘or’+’to prevent or allow a match. Each name is considered in order and later matches override earlier matches. For example,’Csd*, -CsdScene::_Populate*, +CsdScene::_PopulatePrimCacheLocal’matches any malloc tag starting with’Csd’but nothing starting with’CsdScene::_Populate’except’CsdScene::_PopulatePrimCacheLocal’. Use the empty string to disable stack capturing.- Parameters
matchList (str) –
- static SetDebugMatchList()
classmethod SetDebugMatchList(matchList) -> None
Sets the tags to trap in the debugger.
When memory is allocated or freed for any tag that matches
matchList
the debugger trap is invoked. If a debugger is attached the program will stop in the debugger, otherwise the program will continue to run. SeeArchDebuggerTrap()
andArchDebuggerWait()
.matchList
is a comma, tab or newline separated list of malloc tag names. The names can have internal spaces but leading and trailing spaces are stripped. If a name ends in’*’then the suffix is wildcarded. A name can have a leading’-‘or’+’to prevent or allow a match. Each name is considered in order and later matches override earlier matches. For example,’Csd*, -CsdScene::_Populate*, +CsdScene::_PopulatePrimCacheLocal’matches any malloc tag starting with’Csd’but nothing starting with’CsdScene::_Populate’except’CsdScene::_PopulatePrimCacheLocal’. Use the empty string to disable debugging traps.- Parameters
matchList (str) –
- class pxr.Tf.NamedTemporaryFile(suffix='', prefix='', dir=None, text=False)
A named temporary file which keeps the internal file handle closed. A class which constructs a temporary file(that isn’t open) on __enter__, provides its name as an attribute, and deletes it on __exit__.
Note: The constructor args for this object match those of python’s tempfile.mkstemp() function, and will have the same effect on the underlying file created.
Attributes:
The path for the temporary file created.
- property name
The path for the temporary file created.
- class pxr.Tf.Notice
Classes:
Represents the Notice connection between senders and receivers of notices.
Methods:
Register
(noticeType, callback, sender)noticeType : Tf.Notice callback : function sender : object
RegisterGlobally
(noticeType, callback)noticeType : Tf.Notice callback : function
Send(sender)
SendGlobally()
- class Listener
Represents the Notice connection between senders and receivers of notices. When a Listener object expires the connection is broken. You can also use the Revoke() function to break the connection. A Listener object is returned from the Register() and RegisterGlobally() functions.
Methods:
Revoke()
- Revoke()
Revoke()
Revoke interest by a notice listener. This function revokes interest in the particular notice type and call-back method that its Listener object was registered for.
- static Register(noticeType, callback, sender) Listener
noticeType : Tf.Notice callback : function sender : object
Register a listener as being interested in a TfNotice type from a specific sender. Notice listener will get sender as an argument. Registration of interest in a notice class N automatically registers interest in all classes derived from N. When a notice of appropriate type is received, the listening object’s member-function method is called with the notice. To reverse the registration, call Revoke() on the Listener object returned by this call.
Register( noticeType, callback, sender ) -> Listener
noticeType : Tf.Notice callback : function sender : object
Register a listener as being interested in a TfNotice type from a specific sender. Notice listener will get sender as an argument. Registration of interest in a notice class N automatically registers interest in all classes derived from N. When a notice of appropriate type is received, the listening object’s member-function method is called with the notice. To reverse the registration, call Revoke() on the Listener object returned by this call.
- static RegisterGlobally(noticeType, callback) Listener
noticeType : Tf.Notice callback : function
Register a listener as being interested in a TfNotice type from any sender. The notice listener does not get sender as an argument.
- Send()
Send(sender)
sender : object
Deliver the notice to interested listeners, returning the number of interested listeners. This is the recommended form of Send. It takes the sender as an argument. Listeners that registered for the given sender AND listeners that registered globally will get the notice.
Send(sender)
sender : object
Deliver the notice to interested listeners, returning the number of interested listeners. This is the recommended form of Send. It takes the sender as an argument. Listeners that registered for the given sender AND listeners that registered globally will get the notice.
- SendGlobally()
SendGlobally()
Deliver the notice to interested listeners. For most clients it is recommended to use the Send(sender) version of Send() rather than this one. Clients that use this form of Send will prevent listeners from being able to register to receive notices based on the sender of the notice. ONLY listeners that registered globally will get the notice.
- class pxr.Tf.PyModuleWasLoaded
A TfNotice that is sent when a script module is loaded. Since many modules may be loaded at once, listeners are encouraged to defer work triggered by this notice to the end of an application iteration. This, of course, is good practice in general.
Methods:
name
()Return the name of the module that was loaded.
- name() str
Return the name of the module that was loaded.
- class pxr.Tf.RefPtrTracker
Provides tracking of
TfRefPtr
objects to particular objects.Clients can enable, at compile time, tracking of
TfRefPtr
objects that point to particular instances of classes derived fromTfRefBase
. This is useful if you have a ref counted object with a ref count that should’ve gone to zero but didn’t. This tracker can tell you everyTfRefPtr
that’s holding theTfRefBase
and a stack trace where it was created or last assigned to.Clients can get a report of all watched instances and how many
TfRefPtr
objects are holding them usingReportAllWatchedCounts()
(in python useTf.RefPtrTracker()
.GetAllWatchedCountsReport()). You can see all of the stack traces usingReportAllTraces()
(in python useTf.RefPtrTracker()
.GetAllTracesReport()).Clients will typically enable tracking using code like this:
#include "pxr/base/tf/refPtrTracker.h" class MyRefBaseType; typedef TfRefPtr<MyRefBaseType> MyRefBaseTypeRefPtr; TF_DECLARE_REFPTR_TRACK(MyRefBaseType); class MyRefBaseType { \.\.\. public: static bool _ShouldWatch(const MyRefBaseType\*); \.\.\. }; TF_DEFINE_REFPTR_TRACK(MyRefBaseType, MyRefBaseType::_ShouldWatch);
Note that the
TF_DECLARE_REFPTR_TRACK()
macro must be invoked before any use of theMyRefBaseTypeRefPtr
type.The
MyRefBaseType::_ShouldWatch()
function returnstrue
if the given instance ofMyRefBaseType
should be tracked. You can also useTfRefPtrTracker::WatchAll()
to watch every instance (but that might use a lot of memory and time).If you have a base type,
B
, and a derived type,D
, and you hold instances ofD
in aTfRefPtr < ``B>``
(i.e. a pointer to the base) then you must track both typeB
and typeD
. But you can useTfRefPtrTracker::WatchNone()
when trackingB
if you’re not interested in instances ofB
.Methods:
Attributes:
True if this object has expired, False otherwise.
- GetAllTracesReport()
- GetAllWatchedCountsReport()
- GetTracesReportForWatched()
- property expired
True if this object has expired, False otherwise.
- class pxr.Tf.ScopeDescription
This class is used to provide high-level descriptions about scopes of execution that could possibly block, or to provide relevant information about high-level action that would be useful in a crash report.
This class is reasonably fast to use, especially if the message strings are not dynamically created, however it should not be used in very highly performance sensitive contexts. The cost to push & pop is essentially a TLS lookup plus a couple of atomic operations.
Methods:
SetDescription
(description)Replace the description stack entry for this scope description.
- SetDescription(description) None
Replace the description stack entry for this scope description.
Caller guarantees that the string
description
lives at least as long as this TfScopeDescription object.- Parameters
description (str) –
SetDescription(description) -> None
Replace the description stack entry for this scope description.
This object adopts ownership of the rvalue
description
.- Parameters
description (str) –
SetDescription(description) -> None
Replace the description stack entry for this scope description.
Caller guarantees that the string
description
lives at least as long as this TfScopeDescription object.- Parameters
description (char) –
- class pxr.Tf.ScriptModuleLoader
Provides low-level facilities for shared modules with script bindings to register themselves with their dependences, and provides a mechanism whereby those script modules will be loaded when necessary. Currently, this is when one of our script modules is loaded, when TfPyInitialize is called, and when Plug opens shared modules.
Generally, user code will not make use of this.
Methods:
Return a list of all currently known modules in a valid dependency order.
Return a python dict containing all currently known modules under their canonical names.
WriteDotFile
(file)Write a graphviz dot-file for the dependency graph of all.
Attributes:
True if this object has expired, False otherwise.
- GetModuleNames() list[str]
Return a list of all currently known modules in a valid dependency order.
- GetModulesDict() python.dict
Return a python dict containing all currently known modules under their canonical names.
- WriteDotFile(file) None
Write a graphviz dot-file for the dependency graph of all.
currently known modules/modules to file.
- Parameters
file (str) –
- property expired
True if this object has expired, False otherwise.
- class pxr.Tf.Singleton
- class pxr.Tf.StatusObject
- class pxr.Tf.Stopwatch
Methods:
AddFrom
(t)Adds the accumulated time and sample count from
t
into theTfStopwatch
.Reset
()Resets the accumulated time and the sample count to zero.
Start
()Record the current time for use by the next
Stop()
call.Stop
()Increases the accumulated time stored in the
TfStopwatch
.Attributes:
int
int
int
int
float
- AddFrom(t) None
Adds the accumulated time and sample count from
t
into theTfStopwatch
.If you have several timers taking measurements, and you wish to combine them together, you can add one timer’s results into another; for example,
t2.AddFrom(t1)
will addt1
‘s time and sample count intot2
.- Parameters
t (Stopwatch) –
- Start() None
Record the current time for use by the next
Stop()
call.The
Start()
function records the current time. A subsequent call toStart()
before a call toStop()
simply records a later current time, but does not change the accumulated time of theTfStopwatch
.
- Stop() None
Increases the accumulated time stored in the
TfStopwatch
.The
Stop()
function increases the accumulated time by the duration between the current time and the last time recorded by aStart()
call. A subsequent call toStop()
before another call toStart()
will therefore double-count time and throw off the results.A
TfStopwatch
also counts the number of samples it has taken. The”sample count”is simply the number of times thatStop()
has been called.
- property microseconds
int
Return the accumulated time in microseconds.
Note that 45 minutes will overflow a 32-bit counter, so take care to save the result in an
int64_t
, and not a regularint
orlong
.- Type
type
- property milliseconds
int
Return the accumulated time in milliseconds.
- Type
type
- property nanoseconds
int
Return the accumulated time in nanoseconds.
Note that this number can easily overflow a 32-bit counter, so take care to save the result in an
int64_t
, and not a regularint
orlong
.- Type
type
- property sampleCount
int
Return the current sample count.
The sample count, which is simply the number of calls to
Stop()
since creation or a call toReset()
, is useful for computing average running times of a repeated task.- Type
type
- property seconds
float
Return the accumulated time in seconds as a
double
.- Type
type
- class pxr.Tf.TemplateString
Methods:
Returns an empty mapping for the current template.
Returns any error messages generated during template parsing.
SafeSubstitute
(arg1)Like Substitute() , except that if placeholders are missing from the mapping, instead of raising a coding error, the original placeholder will appear in the resulting string intact.
Substitute
(arg1)Performs the template substitution, returning a new string.
Attributes:
str
bool
- GetEmptyMapping() Mapping
Returns an empty mapping for the current template.
This method first calls IsValid to ensure that the template is valid.
- GetParseErrors() list[str]
Returns any error messages generated during template parsing.
- SafeSubstitute(arg1) str
Like Substitute() , except that if placeholders are missing from the mapping, instead of raising a coding error, the original placeholder will appear in the resulting string intact.
- Parameters
arg1 (Mapping) –
- Substitute(arg1) str
Performs the template substitution, returning a new string.
The mapping contains keys which match the placeholders in the template. If a placeholder is found for which no mapping is present, a coding error is raised.
- Parameters
arg1 (Mapping) –
- property template
str
Returns the template source string supplied to the constructor.
- Type
type
- property valid
bool
Returns true if the current template is well formed.
Empty templates are valid.
- Type
type
- class pxr.Tf.Tf_PyEnumWrapper
Attributes:
- property displayName
- property fullName
- property name
- property value
- class pxr.Tf.Tf_TestPyContainerConversions
Methods:
- static GetPairTimesTwo()
- static GetTokens()
- static GetVectorTimesTwo()
- class pxr.Tf.Tf_TestPyOptional
Methods:
- static TakesOptional()
- static TestOptionalChar()
- static TestOptionalDouble()
- static TestOptionalFloat()
- static TestOptionalInt()
- static TestOptionalLong()
- static TestOptionalShort()
- static TestOptionalString()
- static TestOptionalStringVector()
- static TestOptionalUChar()
- static TestOptionalUInt()
- static TestOptionalULong()
- static TestOptionalUShort()
- class pxr.Tf.Type
TfType represents a dynamic runtime type.
TfTypes are created and discovered at runtime, rather than compile time.
Features:
unique typename
safe across DSO boundaries
can represent C++ types, pure Python types, or Python subclasses of wrapped C++ types
lightweight value semantics you can copy and default construct TfType, unlike
std::type_info
.totally ordered can use as a
std::map
key
Methods:
classmethod AddAlias(base, name) -> None
classmethod Define() -> Type
classmethod Find() -> Type
classmethod FindByName(name) -> Type
classmethod FindDerivedByName(name) -> Type
GetAliases
(derivedType)Returns a vector of the aliases registered for the derivedType under this, the base type.
GetAllAncestorTypes
(result)Build a vector of all ancestor types inherited by this type.
GetAllDerivedTypes
(result)Return the set of all types derived (directly or indirectly) from this type.
classmethod GetRoot() -> Type
IsA
(queryType)Return true if this type is the same as or derived from
queryType
Attributes:
list[Type]
bool
bool
bool
TfPyObjWrapper
int
str
- AddAlias()
classmethod AddAlias(base, name) -> None
Add an alias name for this type under the given base type.
Aliases are similar to typedefs in C++: they provide an alternate name for a type. The alias is defined with respect to the given
base
type. Aliases must be unique with respect to both other aliases beneath that base type and names of derived types of that base.- Parameters
base (Type) –
name (str) –
AddAlias(name) -> None
Add an alias for DERIVED beneath BASE.
This is a convenience method, that declares both DERIVED and BASE as TfTypes before adding the alias.
- Parameters
name (str) –
- static Define()
classmethod Define() -> Type
Define a TfType with the given C++ type T and C++ base types B.
Each of the base types will be declared (but not defined) as TfTypes if they have not already been.
The typeName of the created TfType will be the canonical demangled RTTI type name, as defined by GetCanonicalTypeName() .
It is an error to attempt to define a type that has already been defined.
Define() -> Type
Define a TfType with the given C++ type T and no bases.
See the other Define() template for more details.
C++ does not allow default template arguments for function templates, so we provide this separate definition for the case of no bases.
- static Find()
classmethod Find() -> Type
Retrieve the
TfType
corresponding to typeT
.The type
T
must have been declared or defined in the type system or theTfType
corresponding to an unknown type is returned.IsUnknown()
Find(obj) -> Type
Retrieve the
TfType
corresponding toobj
.The
TfType
corresponding to the actual object represented byobj
is returned; this may not be the object returned byTfType::Find<T>()
ifT
is a polymorphic type.This works for Python subclasses of the C++ type
T
as well, as long asT
has been wrapped using TfPyPolymorphic.Of course, the object’s type must have been declared or defined in the type system or the
TfType
corresponding to an unknown type is returned.IsUnknown()
- Parameters
obj (T) –
Find(t) -> Type
Retrieve the
TfType
corresponding to an obj with the giventype_info
.- Parameters
t (type_info) –
- static FindByName()
classmethod FindByName(name) -> Type
Retrieve the
TfType
corresponding to the givenname
.Every type defined in the TfType system has a unique, implementation independent name. In addition, aliases can be added to identify a type underneath a specific base type; see TfType::AddAlias() . The given name will first be tried as an alias under the root type, and subsequently as a typename.
This method is equivalent to:
TfType::GetRoot().FindDerivedByName(name)
For any object
obj
,Find(obj) == FindByName( Find(obj).GetTypeName() )
- Parameters
name (str) –
- FindDerivedByName()
classmethod FindDerivedByName(name) -> Type
Retrieve the
TfType
that derives from this type and has the given alias or typename.AddAlias
- Parameters
name (str) –
FindDerivedByName(name) -> Type
Retrieve the
TfType
that derives from BASE and has the given alias or typename.This is a convenience method, and is equivalent to:
TfType::Find<BASE>().FindDerivedByName(name)
- Parameters
name (str) –
- GetAliases(derivedType) list[str]
Returns a vector of the aliases registered for the derivedType under this, the base type.
AddAlias()
- Parameters
derivedType (Type) –
- GetAllAncestorTypes(result) None
Build a vector of all ancestor types inherited by this type.
The starting type is itself included, as the first element of the results vector.
Types are given in”C3”resolution order, as used for new-style classes starting in Python 2.3. This algorithm is more complicated than a simple depth-first traversal of base classes, in order to prevent some subtle errors with multiple-inheritance. See the references below for more background.
This can be expensive; consider caching the results. TfType does not cache this itself since it is not needed internally.
Guido van Rossum.”Unifying types and classes in Python 2.2: Method resolution order.” http://www.python.org/download/releases/2.2.2/descrintro/#mro
Barrett, Cassels, Haahr, Moon, Playford, Withington.”A Monotonic Superclass Linearization for Dylan.”OOPSLA 96. http://www.webcom.com/haahr/dylan/linearization-oopsla96.html
- Parameters
result (list[Type]) –
- GetAllDerivedTypes(result) None
Return the set of all types derived (directly or indirectly) from this type.
- Parameters
result (set[Type]) –
- static GetRoot()
classmethod GetRoot() -> Type
Return the root type of the type hierarchy.
All known types derive (directly or indirectly) from the root. If a type is specified with no bases, it is implicitly considered to derive from the root type.
- IsA(queryType) bool
Return true if this type is the same as or derived from
queryType
.If
queryType
is unknown, this always returnsfalse
.- Parameters
queryType (Type) –
IsA() -> bool
Return true if this type is the same as or derived from T.
This is equivalent to:
IsA(Find<T>())
- Unknown = Tf.Type.Unknown
- property baseTypes
list[Type]
Return a vector of types from which this type was derived.
- Type
type
- property derivedTypes
- property isEnumType
bool
Return true if this is an enum type.
- Type
type
- property isPlainOldDataType
bool
Return true if this is a plain old data type, as defined by C++.
- Type
type
- property isUnknown
bool
Return true if this is the unknown type, representing a type unknown to the TfType system.
The unknown type does not derive from the root type, or any other type.
- Type
type
- property pythonClass
TfPyObjWrapper
Return the Python class object for this type.
If this type is unknown or has not yet had a Python class defined, this will return
None
, as an emptyTfPyObjWrapper
DefinePythonClass()
- Type
type
- property sizeof
int
Return the size required to hold an instance of this type on the stack (does not include any heap allocated memory the instance uses).
This is what the C++ sizeof operator returns for the type, so this value is not very useful for Python types (it will always be sizeof(boost::python::object)).
- Type
type
- property typeName
str
Return the machine-independent name for this type.
This name is specified when the TfType is declared.
Declare()
- Type
type
- class pxr.Tf.Warning
- pxr.Tf.Fatal(msg)
Raise a fatal error to the Tf Diagnostic system.
- pxr.Tf.GetCodeLocation(framesUp)
Returns a tuple (moduleName, functionName, fileName, lineNo).
To trace the current location of python execution, use GetCodeLocation(). By default, the information is returned at the current stack-frame; thus:
info = GetCodeLocation()
will return information about the line that GetCodeLocation() was called from. One can write:
def genericDebugFacility(): info = GetCodeLocation(1) # print out data def someCode(): ... if bad: genericDebugFacility()
and genericDebugFacility() will get information associated with its caller, i.e. the function someCode().
- pxr.Tf.PrepareModule(module, result)
PrepareModule(module, result) – Prepare an extension module at import time. Generally, this should only be called by the __init__.py script for a module upon loading a boost python module (generally ‘_libName.so’).
- pxr.Tf.PreparePythonModule(moduleName=None)
Prepare an extension module at import time. This will import the Python module associated with the caller’s module (e.g. ‘_tf’ for ‘pxr.Tf’) or the module with the specified moduleName and copy its contents into the caller’s local namespace.
Generally, this should only be called by the __init__.py script for a module upon loading a boost python module (generally ‘_libName.so’).
- pxr.Tf.RaiseCodingError(msg)
Raise a coding error to the Tf Diagnostic system.
- pxr.Tf.RaiseRuntimeError(msg)
Raise a runtime error to the Tf Diagnostic system.
- pxr.Tf.Status(msg, verbose=True)
Issues a status update to the Tf diagnostic system.
If verbose is True (the default) then information about where in the code the status update was issued from is included.
- pxr.Tf.Warn(msg, template='')
Issue a warning via the TfDiagnostic system.
At this time, template is ignored.
- pxr.Tf.WindowsImportWrapper()