def getMethod(self, method_name): ''' Overriden from baseclass. ''' #sanity check self._BaseRepresentation__checkCompRef() if BaseRepresentation.getMethod(self, method_name) != None: return BaseRepresentation.getMethod(self, method_name) #list of return values return_list = [] #create the temporary dictionary that will be returned later ret_val = {'Value': ["None"], 'Timeout': getStandardTimeout()} #Check the method's name to see if it's really a RW attribute #This will be true if the method name starts with "_set_". If this #happens to be the case, just return if method_name.rfind("_set_") == 0: self.__logger.logDebug("Write attribute:" + method_name) return ret_val #Check to see if the method's name begins with "_get_". If this is #true, this is a special case because we do not have to worry #about inout and out parameters. elif method_name.rfind("_get_") == 0: self.__handleReadAttribute(method_name, return_list) #Since we've gotten this far, we must now examine the IFR to determine #which return values (if any) and exceptions this method can #return/throw. else: self.__handleNormalMethod(method_name, return_list) #convert the list of typecodes to a list of real implementations of #those types #if the methodname was not found... if len(return_list) == 0: self.__logger.logWarning("Failed to dynamically generate '" + method_name + "' because the IFR" + " was missing information on the method!") raise CORBA.NO_RESOURCES() ret_val['Value'] = self.__typecodesToObjects(return_list) self.__logger.logDebug("retVal looks like:" + method_name + " " + str(ret_val)) return ret_val
def getCompIfrID(comp_name): ''' Given a component's name, returns said component's interface repository ID or throws an exception if the ID cannot be determined. Raises: CORBA.NO_RESOURCES ''' #get a list of component info's comp_list = getManager().get_component_info(getClient().token.h, [], "*", "*", 0) for comp in comp_list: if comp.name == comp_name: return comp.type #sanity check raise CORBA.NO_RESOURCES()
def __init__(self, compname, comptype): ''' Constructor ''' #superclass constructor BaseRepresentation.__init__(self, compname) self.__logger = getLogger(str(Dynamic) + "(" + compname + ")") #--------------------------------------------------------------------- def __initialize(args): ''' Fake lifecycle method. ''' self.__logger.logDebug("Simulated lifecyle method") return def __cleanUp(args): ''' Fake lifecycle method. ''' self.__logger.logDebug("Simulated lifecyle method") return self.setMethod('initialize', {'Timeout': 0.0, 'Value': __initialize}) self.setMethod('cleanUp', {'Timeout': 0.0, 'Value': __cleanUp}) #save the IDL type self.comp_type = comptype self.__interf = IR.lookup_id(comptype) try: self.__interf = self.__interf._narrow(CORBA.InterfaceDef) self.__interf = self.__interf.describe_interface() except Exception, ex: self.__logger.logCritical("Cannot find a definition for '" + self.comp_type + "' components!") raise CORBA.NO_RESOURCES()