Cortex
10.0.0-a4
|
This class defines methods for creating instances of classes defined in python modules on disk. More...
Public Member Functions | |
def | __init__ (self, searchPaths) |
Creates a ClassLoader which will load classes found on the SearchPath object passed in. More... | |
def | searchPath (self) |
Returns a copy of the searchpath used to find classes. More... | |
def | classNames |
Returns an alphabetically sorted list of all the classes found on the searchpaths. More... | |
def | versions (self, name) |
Returns the available versions of the specified class as a list of ints, with the latest version last. More... | |
def | setDefaultVersion (self, name, version) |
Sets the default version for the named class. More... | |
def | getDefaultVersion (self, name) |
Returns the default version for the named class. More... | |
def | load |
Loads the specified version of the named class. More... | |
def | refresh (self) |
The ClassLoader uses a caching mechanism to speed up frequent reloads of the same class. More... | |
def | defaultLoader (cls, envVar) |
Returns a ClassLoader configured to load from the paths defined by the specified environment variable. More... | |
def | defaultOpLoader (cls) |
Returns a ClassLoader configured to load from the paths defined by the IECORE_OP_PATHS environment variable. More... | |
def | defaultProceduralLoader (cls) |
Returns a ClassLoader configured to load from the paths defined by the IECORE_PROCEDURAL_PATHS environment variable. More... | |
This class defines methods for creating instances of classes defined in python modules on disk.
We could just use the standard import mechanism for this but this gives us queries over what is available and versioning and suchlike, and uses a different set of searchpaths to the standard python paths. It's intended for loading classes derived from Op, ParameterisedProcedural and similar extension classes, and allows us to create small versioned units of functionality for use all over the place - the ieCore "do" script uses the ClassLoader to find operations it can perform for instance. This class will find files with the following template path: <any path>="">/<className>/<className>-<version>.py Where [] represents optional field. And for performance sake, it will not explore directories which contain files that match this: <any path>="">/<className>/<className>*.*
def IECore.ClassLoader.__init__ | ( | self, | |
searchPaths | |||
) |
Creates a ClassLoader which will load classes found on the SearchPath object passed in.
References IECore.ClassLoader.__defaultVersions, IECore.ClassLoader.__loadMutex, IECore.ClassLoader.__searchPaths, and IECore.ClassLoader.refresh().
Referenced by IECore.ClassLoader.defaultProceduralLoader().
def IECore.ClassLoader.classNames | ( | self, | |
matchString = "*" |
|||
) |
Returns an alphabetically sorted list of all the classes found on the searchpaths.
The optional matchString performs glob style matching to narrow down the set of names returned.
References IECore.ClassLoader.__findAllClasses().
def IECore.ClassLoader.defaultLoader | ( | cls, | |
envVar | |||
) |
Returns a ClassLoader configured to load from the paths defined by the specified environment variable.
The same object is returned each time, allowing one loader to be shared by many callers.
References IECore.msg().
Referenced by IECoreMaya.FnDagNode.defaultShapeName(), IECoreMaya.ClassVectorParameterUI.registerToolsMenuCallback(), IECore.ClassParameter.setClass(), IECore.ClassVectorParameter.setClass(), IECoreMaya.ClassVectorParameterUI.setCollapsed(), and IECoreMaya.FnParameterisedHolder.setParameterised().
def IECore.ClassLoader.defaultOpLoader | ( | cls | ) |
Returns a ClassLoader configured to load from the paths defined by the IECORE_OP_PATHS environment variable.
The same object is returned each time, allowing one loader to be shared by many callers.
def IECore.ClassLoader.defaultProceduralLoader | ( | cls | ) |
Returns a ClassLoader configured to load from the paths defined by the IECORE_PROCEDURAL_PATHS environment variable.
The same object is returned each time, allowing one loader to be shared by many callers.
References IECore.ClassLoader.__classes, IECore.ClassLoader.__foundAllClasses, IECore.ClassLoader.__init__(), IECore.ClassLoader.__updateClassFromSearchPath(), IECore.cat(), IECore.cp(), IECore.frameListFromList(), IECore.ls(), IECore.mv(), IECoreHoudini::SOP_CortexConverter.parameters, IECore::ParameterisedInterface.parameters(), IECoreHoudini::ParameterisedHolder< SOP_Node >.parameters, IECoreHoudini::ParameterisedHolder< BaseType >.parameters, IECore::Shader.parameters(), IECore::Light.parameters(), IECore::ExternalProcedural.parameters(), IECore::Camera.parameters(), IECore::Display.parameters(), IECore::Parameterised.parameters(), IECore::ParameterisedProcedural.parameters(), IECore::CompoundParameter.parameters(), IECore::Renderer::ExternalProcedural.parameters(), IECoreMaya.ParameterPanel.ParameterUIContainer.parameters, IECore.registerRunTimeTyped(), IECore.rm(), IECore::Parameterised.userData(), and IECore::Parameter.userData().
Referenced by IECoreRI.executeProcedural().
def IECore.ClassLoader.getDefaultVersion | ( | self, | |
name | |||
) |
Returns the default version for the named class.
This is the version that is loaded if no version is specified in the load() method. If it has not been set explicitly with setDefaultVersion() then it defaults to the highest available version.
References IECore.ClassLoader.__defaultVersions, IECore.ClassLoader.__findClass(), and IECore.msg().
Referenced by IECore.ClassLoader.load().
def IECore.ClassLoader.load | ( | self, | |
name, | |||
version = None |
|||
) |
Loads the specified version of the named class.
Version defaults to getDefaultVersion( name ) if not specified. Note that this returns the actual class object itself rather than an instance of that class. It also adds two class attributes named "path" and "version" with the info necessary to reload the Op from ClassLoader.
References IECore.ClassLoader.__findClass(), IECore.ClassLoader.__loadMutex, IECore.ClassLoader.getDefaultVersion(), and IECore.ClassLoader.versions().
def IECore.ClassLoader.refresh | ( | self | ) |
The ClassLoader uses a caching mechanism to speed up frequent reloads of the same class.
This method can be used to force an update of the cache to reflect changes on the filesystem.
References IECore.ClassLoader.__classes, and IECore.ClassLoader.__foundAllClasses.
Referenced by IECore.ClassLoader.__init__().
def IECore.ClassLoader.searchPath | ( | self | ) |
Returns a copy of the searchpath used to find classes.
References IECore.ClassLoader.__searchPaths.
def IECore.ClassLoader.setDefaultVersion | ( | self, | |
name, | |||
version | |||
) |
Sets the default version for the named class.
This is the version that is loaded if no version is specified in the load() method.
References IECore.ClassLoader.__defaultVersions, IECore.ClassLoader.__findClass(), and IECore.ClassLoader.__validateVersion().
def IECore.ClassLoader.versions | ( | self, | |
name | |||
) |
Returns the available versions of the specified class as a list of ints, with the latest version last.
If the class doesn't exist returns an empty list.
References IECore.ClassLoader.__findClass().
Referenced by IECore.ClassLoader.load().