#include #include "../shared/SimpleLogFile.h" #include "../shared/ThreadMonitor.h" #include "../shared/GlobalConfigFile.h" #include "ReportAlertsTcl.h" #include "TclDatabaseWrapper.h" #include "TclDatabaseObjectWrapper.h" #include "../shared/TclUtil.h" #include "TclReplyToClient.h" #include "TclGridObjectWrapper.h" #include "TclDataDebug.h" #include "TclLogWrapper.h" #include "TclLimitAlertWrapper.h" #include "TclAlertConnectionWrapper.h" #include "TclTopListRequestWrapper.h" #include "TclNamedReference.h" #include "ExecutionContext.h" __thread ExecutionContext *ExecutionContext::_instance = NULL; ExecutionContext::ExecutionContext(Tcl_Interp *interp, GridFiller *gridFiller) : _interp(interp), _gridFiller(gridFiller) { assert(!_instance); _instance = this; } ExecutionContext::~ExecutionContext() { sendToLogFile(TclList()<fullName; if (nameSpace == "::") // The root namespace already ends in ::. That is different from all // other namespaces. return nameSpace + name; else return nameSpace + "::" + name; } std::string ExecutionContext::getAbsoluteName(std::string const &name) { return getAbsoluteName(_interp, name); } static const char *const S_GRID_ERRORS = "grid_errors"; void ExecutionContext::initInterp(std::string const &interpType) { installNamedReferenceDebugCommands(_interp); installGridObjectWrapper(_interp, _gridFiller); installLimitAlertCommands(_interp); installAlertConnectionCommands(_interp); installTopListRequestCommands(_interp); installLogCommands(_interp); TclDatabaseObjectWrapper::addStandardCommands(_interp); TclDatabaseObjectWrapper::addStandardDatabases(_interp); installReportAlerts(_interp); // TODO TclDatabaseWrapper is deprecated, replaced by // TclDatabaseObjectWrapper. The following line should be removed soon. TclDatabaseWrapper::createDatabaseCmd(_interp, "ti::rw_database", "@RW"); TclReplyToClient::instance().addOtherCommands(_interp); installDataDebug(_interp); if (!interpType.empty()) { Tcl_CreateNamespace(_interp, "ti", NULL, NULL); /* Tcl_Obj *result = Tcl_SetVar2Ex(_interp, "ti::interp_type", NULL, makeTclString(interpType), TCL_LEAVE_ERR_MSG); if (!result) { std::string errorMessage = Tcl_GetStringResult(_interp); TclList msg; msg<