File size: 34,953 Bytes
d8ab1df |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 |
Tf module — pxr-usd-api 105.1 documentation
pxr-usd-api
»
Modules »
Tf module
# Tf module
Summary: The Tf (Tools Foundations) module.
Tf – Tools Foundation
Exceptions:
CppException
ErrorException(*args)
Classes:
CallContext
Debug
DiagnosticType
Enum
Error
MallocTag
NamedTemporaryFile([suffix, prefix, dir, text])
A named temporary file which keeps the internal file handle closed.
Notice
PyModuleWasLoaded
A TfNotice that is sent when a script module is loaded.
RefPtrTracker
Provides tracking of TfRefPtr objects to particular objects.
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.
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.
Singleton
StatusObject
Stopwatch
TemplateString
Tf_PyEnumWrapper
Tf_TestAnnotatedBoolResult
Tf_TestPyContainerConversions
Tf_TestPyOptional
Type
TfType represents a dynamic runtime type.
Warning
Functions:
Fatal(msg)
Raise a fatal error to the Tf Diagnostic system.
GetCodeLocation(framesUp)
Returns a tuple (moduleName, functionName, fileName, lineNo).
PrepareModule(module, result)
PrepareModule(module, result) -- Prepare an extension module at import time.
PreparePythonModule([moduleName])
Prepare an extension module at import time.
RaiseCodingError(msg)
Raise a coding error to the Tf Diagnostic system.
RaiseRuntimeError(msg)
Raise a runtime error to the Tf Diagnostic system.
Status(msg[, verbose])
Issues a status update to the Tf diagnostic system.
Warn(msg[, template])
Issue a warning via the TfDiagnostic system.
WindowsImportWrapper()
exception pxr.Tf.CppException
exception pxr.Tf.ErrorException(*args)
class pxr.Tf.CallContext
Attributes:
file
char
function
char
line
int
prettyFunction
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:
GetDebugSymbolDescription
classmethod GetDebugSymbolDescription(name) -> str
GetDebugSymbolDescriptions
classmethod GetDebugSymbolDescriptions() -> str
GetDebugSymbolNames
classmethod GetDebugSymbolNames() -> list[str]
IsDebugSymbolNameEnabled
classmethod IsDebugSymbolNameEnabled(name) -> bool
SetDebugSymbolsByName
classmethod SetDebugSymbolsByName(pattern, value) -> list[str]
SetOutputFile
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 to value .
All registered debug symbols matching pattern are set to value
. The only matching is an exact match with pattern , or if
pattern 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:
GetValueFromName
Attributes:
allValues
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:
GetValueFromFullName
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, the foundIt flag pointer, if not None , is set to
true if the name was found and false otherwise. Also, since
this is not a templated function, it has to return a generic value
type, so we use TfEnum .
Parameters
fullname (str) –
foundIt (bool) –
class pxr.Tf.Error
Classes:
Mark
Attributes:
errorCode
The error code posted for this error.
errorCodeString
The error code posted for this error, as a string.
class Mark
Methods:
Clear
GetErrors
A list of the errors held by this mark.
IsClean
SetMark
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:
CallTree
Methods:
GetCallStacks
GetCallTree
classmethod GetCallTree(tree, skipRepeated) -> bool
GetMaxTotalBytes
classmethod GetMaxTotalBytes() -> int
GetTotalBytes
classmethod GetTotalBytes() -> int
Initialize
classmethod Initialize(errMsg) -> bool
IsInitialized
classmethod IsInitialized() -> bool
SetCapturedMallocStacksMatchList
classmethod SetCapturedMallocStacksMatchList(matchList) -> None
SetDebugMatchList
classmethod SetDebugMatchList(matchList) -> None
class CallTree
Classes:
CallSite
PathNode
Methods:
GetCallSites
GetPrettyPrintString
GetRoot
LogReport
Report
class CallSite
Attributes:
nBytes
name
property nBytes
property name
class PathNode
Methods:
GetChildren
Attributes:
nAllocations
nBytes
nBytesDirect
siteName
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 the C *tree
structure for documentation. If Initialize() has not been called,
*tree is set to a rather blank structure (empty vectors, empty
strings, zero in all integral fields) and false is returned;
otherwise, \*tree is set with the contents of the current memory
snapshot and true 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 is true , then any repeated
callsite is skipped. See the CallTree 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 calling
Initialize() .
Parameters
errMsg (str) –
static IsInitialized()
classmethod IsInitialized() -> bool
Return true if the tagging system is active.
If Initialize() has been successfully called, this function
returns true .
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 call GetCapturedMallocStacks() 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. See ArchDebuggerTrap() and ArchDebuggerWait()
.
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:
name
The path for the temporary file created.
property name
The path for the temporary file created.
class pxr.Tf.Notice
Classes:
Listener
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
Send(sender)
SendGlobally
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()
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 from
TfRefBase . 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 every TfRefPtr that’s holding the TfRefBase 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 using
ReportAllWatchedCounts() (in python use Tf.RefPtrTracker()
.GetAllWatchedCountsReport()). You can see all of the stack traces
using ReportAllTraces() (in python use Tf.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 the MyRefBaseTypeRefPtr type.
The MyRefBaseType::_ShouldWatch() function returns true if the
given instance of MyRefBaseType should be tracked. You can also
use TfRefPtrTracker::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 of D in a TfRefPtr < ``B>`` (i.e. a pointer to
the base) then you must track both type B and type D . But you
can use TfRefPtrTracker::WatchNone() when tracking B if you’re
not interested in instances of B .
Methods:
GetAllTracesReport
GetAllWatchedCountsReport
GetTracesReportForWatched
Attributes:
expired
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:
GetModuleNames()
Return a list of all currently known modules in a valid dependency order.
GetModulesDict()
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:
expired
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 the TfStopwatch .
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:
microseconds
int
milliseconds
int
nanoseconds
int
sampleCount
int
seconds
float
AddFrom(t) → None
Adds the accumulated time and sample count from t into the
TfStopwatch .
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 add t1 ‘s time and sample
count into t2 .
Parameters
t (Stopwatch) –
Reset() → None
Resets the accumulated time and the sample count to zero.
Start() → None
Record the current time for use by the next Stop() call.
The Start() function records the current time. A subsequent call
to Start() before a call to Stop() simply records a later
current time, but does not change the accumulated time of the
TfStopwatch .
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 a Start()
call. A subsequent call to Stop() before another call to
Start() 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 that Stop() 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 regular int or
long .
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 regular int
or long .
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 to Reset() , 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:
GetEmptyMapping()
Returns an empty mapping for the current template.
GetParseErrors()
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:
template
str
valid
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:
displayName
fullName
name
value
property displayName
property fullName
property name
property value
class pxr.Tf.Tf_TestAnnotatedBoolResult
Attributes:
annotation
property annotation
class pxr.Tf.Tf_TestPyContainerConversions
Methods:
GetPairTimesTwo
GetTokens
GetVectorTimesTwo
static GetPairTimesTwo()
static GetTokens()
static GetVectorTimesTwo()
class pxr.Tf.Tf_TestPyOptional
Methods:
TakesOptional
TestOptionalChar
TestOptionalDouble
TestOptionalFloat
TestOptionalInt
TestOptionalLong
TestOptionalShort
TestOptionalString
TestOptionalStringVector
TestOptionalUChar
TestOptionalUInt
TestOptionalULong
TestOptionalUShort
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:
AddAlias
classmethod AddAlias(base, name) -> None
Define
classmethod Define() -> Type
Find
classmethod Find() -> Type
FindByName
classmethod FindByName(name) -> Type
FindDerivedByName
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.
GetRoot
classmethod GetRoot() -> Type
IsA(queryType)
Return true if this type is the same as or derived from queryType
Attributes:
Unknown
baseTypes
list[Type]
derivedTypes
isEnumType
bool
isPlainOldDataType
bool
isUnknown
bool
pythonClass
TfPyObjWrapper
sizeof
int
typeName
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 type T .
The type T must have been declared or defined in the type system
or the TfType corresponding to an unknown type is returned.
IsUnknown()
Find(obj) -> Type
Retrieve the TfType corresponding to obj .
The TfType corresponding to the actual object represented by
obj is returned; this may not be the object returned by
TfType::Find<T>() if T is a polymorphic type.
This works for Python subclasses of the C++ type T as well, as
long as T 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 given
type_info .
Parameters
t (type_info) –
static FindByName()
classmethod FindByName(name) -> Type
Retrieve the TfType corresponding to the given name .
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 returns false .
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 empty TfPyObjWrapper
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()
© Copyright 2019-2023, NVIDIA.
Last updated on Nov 14, 2023.
|