Ejemplo n.º 1
0
    def updateGraph(self):

        # Component-specific code:
        #  Check existence of interface nodes in project graph and add edges
        symdict={}
        for p in self.newProvides: symdict[p.getType()] = p.getLocation()
        fqsymboldict, vertices = self._validateProjectSymbols(self.graph, symbols=symdict, 
                                                           kinds=['interface','port']) # should it be just 'port'?
        for ifaceNode in vertices:
            edge = BEdge(ifaceNode, self, graph=self.graph, action = 'provides')  # Connect with implemented interface
        # Add the new ports 
        for p in self.newProvides: 
            p.setLocation(fqsymboldict[p.getType()])
        self._b_provides.extend(self.newProvides)
            
        print >>DEBUGSTREAM,'Provides ports: ', self._b_provides
        
        # Check for existence of class/component nodes in project graph and add edges
        symdict={}
        for p in self.newUses: symdict[p.getType()] = p.getLocation()
        fqsymboldict, vertices = self._validateProjectSymbols(self.graph, symbols=symdict, 
                                                              kinds = ['interface', 'port']) # should it be just 'port'?
        for ifaceNode in vertices:
            edge = BEdge(ifaceNode, self, graph=self.graph, action = 'uses')  # Connect with implemented interface
        # Add the new interfaces 
        for p in self.newUses:
            p.setLocation(fqsymboldict[p.getType()])
        self._b_uses.extend(self.newUses)
                
        #print 'DEBUG: newUses=', str(self.newUses), ', b_uses=', str(self._b_uses)
    
        Sidlclass.updateGraph(self)
        pass
Ejemplo n.º 2
0
 def initCopy(self, copiedComponent):
     # Hack to make copy work with updateGraph, which generates _b_provides/_b_uses
     self.newProvides = copiedComponent._b_provides
     self.newUses = copiedComponent._b_uses
     
     Sidlclass.initCopy(self, copiedComponent)
     pass
Ejemplo n.º 3
0
 def change(self):
     """change component SIDL_SYMBOL options
     """
     project,graph = Globals().getProjectAndGraph(self.projectName)
     
     # delete uses or provides port
     if self.options.deletePortName:
         allmyports = [x.getName() for x in self._b_provides + self._b_uses]
         for p in self.options.deletePortName:
             if p not in allmyports:
                 err('There is not port named ' + p + ' in this component.')
     
         for pname in self.options.deletePortName:
             for theport in self._b_uses + self._b_provides:
                 if pname == theport.getName():
                     # TODO: Make sure this port is not in the implements or provides list under more than one name 
                     # before deleting the type
                     ptype = theport.getType()
                     if [x.getType()==ptype for x in self._b_uses + self._b_provides].count(True) + self._b_implements.keys().count(ptype) <= 0:
                         # remove edge
                         self.removeInEdge(ptype, kind = 'port', graph=graph)
                         if location == '%external%':
                             # Remove external file name in project defaults file
                             if not self._findExternal(ptype): project.removeDefaultValue(ptype,'External')
                             print >>DEBUGSTREAM, 'Removed external port or interface: ' + ptype
                             if ptype in self._b_externalSidlFiles.keys(): del self._b_externalSidlFiles[ptype]   
                     try: 
                         if theport in self._b_uses: self._b_uses.remove(theport)
                         elif theport in self._b_provides: self._b_provides.remove(theport)
                     except: err('Could not remove port %s, port not used or provided in component %s' % (pname, self.symbol))     
         
     # Let class handle everything it can (it also calls the builder update method)
     Sidlclass.change(self)
     return 0
Ejemplo n.º 4
0
 def defineArgsCreate(self):
     '''Defines command line options and defaults for the create action. 
     '''
     self.defineCommonArgsCreateAndChange1()
     Sidlclass.defineArgsCreate(self)
     self.defineCommonArgsCreateAndChange2()
     
     return
Ejemplo n.º 5
0
    def renameInternalSymbol(self, oldSymbol, newSymbol):
        Sidlclass.renameInternalSymbol(self, oldSymbol, newSymbol)
        
        for p in self._b_provides + self._b_uses:
            if oldSymbol == p.getType():
                self._replaceSymbolInFiles(oldSymbol, newSymbol)
                p.setType(newSymbol)
                
# FIXME: We're doing this to check that the sed approach actually works. 
        self.genClassImpl()
        return 0
Ejemplo n.º 6
0
 def defineArgsChange(self):
     '''Defines command line options and defaults for the change action.
     '''
     # Support all the creation options:
     self.defineCommonArgsCreateAndChange1()
     Sidlclass.defineArgsChange(self)
     self.defineCommonArgsCreateAndChange2()
     # Additional arguments specific to change
     
     # remove a port from this component
     self.parser.add_option("-d", "--delete", dest="deletePortName", action="append",
                       help="remove ports used or provided by the component given the port name (not SIDL symbol)."
                       + "Multiple ports can be specified using multiple --delete options.")
     return
Ejemplo n.º 7
0
    def removeInternalSymbol(self, oldSymbol):
        ''' Removes any internal references to symbol.'''
        Sidlclass.removeInternalSymbol(self,oldSymbol)
        
        for p in self._b_provides:
            if oldSymbol == p.getType():
                self._removeSymbolInFiles(oldSymbol)
                self._b_provides.remove(p)

                
        for p in self._b_uses:
            if oldSymbol == p.getType():
                self._removeSymbolInFiles(oldSymbol)
                self._b_uses.remove(p)
               
        self.genClassImpl()
        return 0
Ejemplo n.º 8
0
    def __init__(self, action = '__init__', args = None, project = None, modulePath = None,
                 symbol=None, version='0.0', graph=None):
        '''bocca <verb> component [options] SIDL_SYMBOL
        
        <verb> is one of create, change, remove, rename, display. For documentation on
        specific verbs, use 'bocca help <verb> component'
        '''

        self.implImports = {}
        self.graph = graph
        self.displayAll = False          # Used in display
        self.newProvides = []            # List of PortInstance objects
        self.newUses = []                # List of PortInstance objects
        self.new_extends = {}            # Used in create and change
        self.new_implements = {}         # Used in create and change
        self.newComponentProperties = TypedMap() # Used in create and change
        self.newPortsProperties = dict() # Used in create and change
        self.newBasicParamPort = None    # Used in create and change
        self.newParameterPorts = dict()  # Used in create and change
        self._b_provides = []          # List of port instance objects
        self._b_uses = []       
        if (symbol == 'temp'): 
            Sidlclass.__init__(self, action = action, 
                               args = args, modulePath = modulePath, 
                               project = project, kind = 'component', 
                               symbol = symbol, version = version, graph = graph)
            return
        self._b_componentProperties = TypedMap()
        self._b_portsProperties = dict(); # key{portname}: value{TypedMap}
        # simple param port:
        self._b_basicParamPort = None; # if not none, provides typemap and port of user-specified name which is stored here
        # full parameter ports delegated from factory.
        self._b_parameterPorts = dict(); # key{portname}: value{paramportdesc}
       # List of port instance objects
        self.allPortsTypes=[]
        Sidlclass.__init__(self, action = action, 
                         args = args, modulePath = modulePath, 
                         project = project, kind = 'component', 
                         symbol = symbol, version = version, graph=graph)
        pass
Ejemplo n.º 9
0
    def processCommonCreateAndChangeArgs(self):
        print >>DEBUGSTREAM, "component: processCommonCreateAndChangeArgs"
        options, args = self.options, self.args

        # print "UH_component:processCommonCreateAndChangeArgs"
        # dpathdata = self._processDpathOptions()
        # self._updateDpaths(dpathdata)

        # relocatd base call from end of method.
        Sidlclass.processCommonCreateAndChangeArgs(self)

        if options.usesPort:
            self.newUses = self._processSymbolAssociationOptions(options.usesPort, '--uses/-u')
                
        if options.providesPort:
            self.newProvides = self._processSymbolAssociationOptions(options.providesPort, '--provides/-p')
            
        print >>DEBUGSTREAM, "\nComponent: newProvides = ", self.newProvides, \
                            "\nComponent: newUses = ", self.newUses

        for newp in self.newUses + self.newProvides:
            for p in [x.getName() for x in self._b_uses + self._b_provides]:
                if p == newp.getName():
                    err('This component already uses or provides a port of this name: ' + str(p) 
                           + ' (port names must be unique within a component),')
        for newp in self.newProvides:
            for i in [x.getType() for x in self._b_provides] + self._b_implements.keys():
                if i == newp.getType():
                    err('This component already implements this interface or provides a port of this type: ' + str(i))
                    
            if [x.getType() for x in self.newProvides].count(newp) > 1:
                err('A port cannot be provided more than once: ' + str(newp))
                            
        # relocating base call to beginning of method
        
        return
Ejemplo n.º 10
0
 def defineArgs(self, action):
     '''Defines command line options and defaults for this command. This is 
        invoked in the constructor of the parent class Subcommand.
     '''
     if (action == 'create'):
         self.defineArgsCreate()
     elif action == 'copy':
         Sidlclass.defineArgsCopy(self)
     elif action == 'rename':
         pass
     elif action == 'display':
         Sidlclass.defineArgs(self, action)
     elif action == 'change':
         self.defineArgsChange()
     elif action == 'edit' or action == 'whereis':
         Sidlclass.defineArgs(self, action)
     elif action == 'remove':
         Sidlclass.defineArgsRemove(self)
     else:
         err('Component verb "' + action + '" NOT implemented yet.', 3)
     return
Ejemplo n.º 11
0
 def processArgs(self, action):
     """ Dispatch argument processing based in required action
     """
     print >> DEBUGSTREAM, "Component called with options ", \
                           str(self.options) , " leaving args " , str(self.args)
     if (action == 'create'):
         self.processCreateArgs()
     elif (action == 'change'):
         self.processChangeArgs()
     elif (action == 'display'):
         Sidlclass.processDisplayArgs(self)
     elif (action == 'rename'):
         self.processRenameArgs()
     elif (action == 'edit' or action == 'whereis'):
         Sidlclass.processArgs(self, action)
     elif (action == 'remove'):
         Sidlclass.processRemoveArgs(self)
     elif (action == 'copy'):
         Sidlclass.processCopyArgs(self)
     else:
         err("Action "+ action + " NOT implemented yet", 3)
     return
Ejemplo n.º 12
0
 def display(self):
     """display component SIDL_SYMBOL
     """
     return Sidlclass.display(self) 
Ejemplo n.º 13
0
 def processCreateArgs(self):
     """ Process command line arguments passed to the "component create" command
     """
     print >>DEBUGSTREAM, "component: processCreateArgs"
     Sidlclass.processCreateArgs(self)
     return
Ejemplo n.º 14
0
 def _internalRename(self):
     return Sidlclass._internalRename(self)       
Ejemplo n.º 15
0
 def processRenameArgs(self):
     """ Process command line arguments passed to the "component rename" command
     """
     Sidlclass.processRenameArgs(self)
     return    
Ejemplo n.º 16
0
    def processChangeArgs(self):
        """Process command line arguments passed to the "component change" command
        """
        Sidlclass.processChangeArgs(self)

        return
Ejemplo n.º 17
0
 def edit(self):
     '''edit component SIDL_SYMBOL [optional method name] options
     '''
     return Sidlclass.edit(self)
Ejemplo n.º 18
0
 def whereis(self):
     '''whereis component SIDL_SYMBOL [optional method name] options
     '''
     return Sidlclass.whereis(self)
Ejemplo n.º 19
0
 def remove(self):
     """remove component SIDL_SYMBOL
     """
     return Sidlclass.remove(self)
Ejemplo n.º 20
0
 def rename(self):
     """rename component OLD_SIDL_SYMBOL NEW_SIDL_SYMBOL
     """
     #return self.renameTarget._internalRename()
     Sidlclass.rename(self)
Ejemplo n.º 21
0
 def create(self):
     """create component [options] SIDL_SYMBOL
     """
     Sidlclass.create(self)
     return 0