def includes1Visit(self, obj): """ Defined to generate includes within a file. Usually used for the base classes but also for Port types @parms args: the instance of the concrete element to operation on. """ relative_path = self.relativePath() # DEBUG.debug("Relative path: %s", relative_path) # c = includes1TopologyH.includes1TopologyH() temp = obj.get_comp_list() # Only generate port connections c.connect_only = False if obj.connect_only: c.connect_only = True # Generate Components as pointers c.is_ptr = False if obj.is_ptr: c.is_ptr = True else: if not obj.connect_only: c.is_ptr = True obj.is_ptr = True c.component_header_list = [] for component in temp: # # Hack to fix the include file so it is consistent... if self.__config.get("component", "XMLDefaultFileName") == "False": namespace = "" else: namespace = component.get_namespace() # # Added configurable override for includes for testing if self.__config.get("includes", "comp_include_path") == "None": if relative_path is not None: path = relative_path else: path = component.get_namespace() else: path = self.__config.get("includes", "comp_include_path") c.path = path c.component_header_list.append( (path, namespace, component.get_kind())) # # Build list of unique component types here... comp_types = [k[2] for k in c.component_header_list] comp_types = self.__model_parser.uniqueList(comp_types) comp_headers = c.component_header_list # # Recreate component_header_list here with only unique types... c.component_header_list = [] for k in comp_types: for comp in comp_headers: if k == comp[2]: c.component_header_list.append(comp) break # ## Create Component Declarations component_list = [] for component in temp: d = { "ns": component.get_namespace(), "name": component.get_name(), "kind": component.get_kind(), } component_list.append(dict(d)) c.component_import_list = [] for xml_name in obj.get_instance_header_dict(): if obj.get_instance_header_dict()[xml_name] is not None: xml_path = obj.get_instance_header_dict()[xml_name] else: xml_path = xml_name xml_path = xml_path.strip() xml_path = xml_path.replace("i.xml", "") xml_path += "c.hpp" c.component_import_list.append(xml_path) c.component_declarations = [] for component in component_list: if obj.is_ptr: declaration_template = """{ns}::{kind}Impl* {name}_ptr = 0;""".format( **component) else: declaration_template = """{ns}::{kind}Impl {name}("{name}");""".format( **component) c.component_declarations.append(declaration_template) self._writeTmpl(c, "includes1Visit")
def includes1Visit(self, obj): """ Defined to generate includes within a file. Usually used for the base classes but also for Port types @parms args: the instance of the concrete element to operation on. """ # If BUILD_ROOT is set get me the relative path to current execution location relative_path = None path = os.getcwd() # normalize path to Linux separators - TKC path = path.replace("\\", "/") if ModelParser.BUILD_ROOT != None: path = os.path.normpath(os.path.realpath(path)) build_root = os.path.normpath( os.path.realpath(ModelParser.BUILD_ROOT)) if path[:len(build_root)].lower() == build_root.lower(): relative_path = path[len(build_root + '/'):] else: PRINT.info( "ERROR: BUILD_ROOT (%s) and current execution path (%s) not consistent!" % (ModelParser.BUILD_ROOT, path)) sys.exit(-1) # DEBUG.debug("Relative path: %s", relative_path) # c = includes1TopologyH.includes1TopologyH() temp = obj.get_comp_list() # Only generate port connections c.connect_only = False if obj.connect_only: c.connect_only = True # Generate Components as pointers c.is_ptr = False if obj.is_ptr: c.is_ptr = True else: if not obj.connect_only: c.is_ptr = True obj.is_ptr = True # # Hack to fix the include file so it is consistent... if self.__config.get("component", "XMLDefaultFileName") == "False": namespace_flag = "" # c.component_header_list = [] for component in temp: # # Hack to fix the include file so it is consistent... if self.__config.get("component", "XMLDefaultFileName") == "False": namespace = "" else: namespace = component.get_namespace() # # Added configurable override for includes for testing if self.__config.get("includes", "comp_include_path") == "None": if relative_path != None: path = relative_path else: path = component.get_namespace() else: path = self.__config.get("includes", "comp_include_path") c.path = path c.component_header_list.append( (path, namespace, component.get_kind())) # # Build list of unique component types here... comp_types = [k[2] for k in c.component_header_list] comp_types = self.__model_parser.uniqueList(comp_types) comp_headers = c.component_header_list # # Recreate component_header_list here with only unique types... c.component_header_list = [] for k in comp_types: for comp in comp_headers: if k == comp[2]: c.component_header_list.append(comp) break # ## Create Component Declarations component_list = [] for component in temp: d = { 'ns': component.get_namespace(), 'name': component.get_name(), 'kind': component.get_kind() } component_list.append(dict(d)) c.component_import_list = [] for xml_name in obj.get_instance_header_dict(): if obj.get_instance_header_dict()[xml_name] != None: xml_path = obj.get_instance_header_dict()[xml_name] else: xml_path = xml_name xml_path = xml_path.strip() xml_path = xml_path.replace("i.xml", '') xml_path = xml_path.replace(ModelParser.BUILD_ROOT, '') xml_path += "c.hpp" c.component_import_list.append(xml_path) c.component_declarations = [] for component in component_list: if obj.is_ptr: declaration_template = """{ns}::{kind}Impl* {name}_ptr = 0;""".format( **component) else: declaration_template = """{ns}::{kind}Impl {name}("{name}");""".format( **component) c.component_declarations.append(declaration_template) self._writeTmpl(c, "includes1Visit")