00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef __HOM_HDAModule_h__
00017 #define __HOM_HDAModule_h__
00018
00019 #include "HOM_API.h"
00020 #include "HOM_Defines.h"
00021 #include "HOM_Errors.h"
00022 #include "HOM_Module.h"
00023
00024 class PY_EvaluationContext;
00025
00026 SWIGOUT(%rename(HDAModule) HOM_HDAModule;)
00027
00028 class HOM_API HOM_HDAModule
00029 {
00030 public:
00031 HOM_HDAModule()
00032 { HOM_CONSTRUCT_OBJECT(this) }
00033 HOM_HDAModule(const HOM_HDAModule &module)
00034 { HOM_CONSTRUCT_OBJECT(this) }
00035 virtual ~HOM_HDAModule()
00036 { HOM_DESTRUCT_OBJECT(this) }
00037
00038 virtual std::string __repr__() throw(HOM_ObjectWasDeleted, HOM_Error) = 0;
00039
00040 #if defined(SWIG) && defined(SWIGPYTHON)
00041 %extend
00042 {
00043
00044
00045
00046
00047 %feature("autodoc", "__getattr__(self, name) -> object") __getattr__;
00048 InterpreterObject __getattr__(const char *name)
00049 throw(HOM_ObjectWasDeleted, HOM_Error)
00050 {
00051 HOM_AutoLock hom_lock;
00052
00053
00054
00055 PY_EvaluationContext *context = self->getEvaluationContext();
00056 PyObject *dict = context
00057 ? (PyObject *)context->getGlobalsDict() : NULL;
00058 PyObject *attribute = (dict && name)
00059 ? PyDict_GetItemString(dict, name) : NULL;
00060
00061
00062 if (!attribute && dict)
00063 {
00064 dict = (PyObject *)context->getGlobalsDict();
00065 attribute = name ? PyDict_GetItemString(dict, name) : NULL;
00066 }
00067
00068
00069
00070 if (attribute)
00071 {
00072 Py_INCREF(attribute);
00073 return attribute;
00074 }
00075
00076
00077 if (!name)
00078 name = "";
00079 UT_WorkBuffer error_message;
00080 error_message.sprintf("'module' object has no attribute '%s'", name);
00081 PyErr_SetString(PyExc_AttributeError, error_message.buffer());
00082 return NULL;
00083 }
00084 }
00085
00086 #endif
00087
00088
00089
00090
00091 SWIGOUT(%ignore getEvaluationContext;)
00092 virtual PY_EvaluationContext *getEvaluationContext()
00093 throw(HOM_ObjectWasDeleted) = 0;
00094 };
00095
00096 #endif