I have a beginner Python question: let's say I'm traversing the hierarchy, I've got a node object and I want to figure out its type:
typeInt = WireTapInt()
node.getNodeType( typeInt )
if typeInt == IFFFS_WT_TYPE_CLIP:
But IFFFS_WT_TYPE_CLIP is an anonymous enum from ifffsWTTypes.h, how to I access that in Python code? I'd rather avoid hardcoding "6" instead of IFFFS_WT_TYPE_CLIP, and calling:
name = wireTapStr()
parent.getNode( name )
if name == "CLIP":
doesn't seem much better. It looks like you are using boost.python to export the C++ API to Python, and from the brief Googling I've done, it is possible to export C++ enums that way, but I can't find any info on how to access these enum values?
We are deprecating the use of integer/enum node types (for this very reason), in favour of string representations. We want to avoid having to include a header for a given server, as well as make the code a bit easier to read.
The API calls you are using will remain for a few versions, and will then be removed.
It would be great if the Python DSO would export string variables containing those strings, so that I can reference a variable name instead of hard-coding a string in my Python code. That gives me a bit of "compile-time" checking, as opposed to failing at runtime because I made a typo in a string being passed to the API.
Part of the reason we don;t have these is because the API you have is essentially generic (i.e. no IFFFS-isms). IFFFS is not the only product to be exposed by WT. To do what you are asking, we would need a companion DSO from each of the WT-capable products.
That sounds like a reasonable approach: just provide a helper DSO for different applications which you can link again/dlopen() if you want the additional convenience/safety of not hard-coding these strings in your app.