def create(self, the_type): """ Create and return a code generator that generates a specific portion of code for all the visitor producers. Each of the producer visitors provides an interface to generate a portion of the code. The following portions are supported -- referenced by a string name. initFiles startSource includes1 includes2 namespace public protected private finishSource StartCommand CommandHeader The visitors correspond to source code files that are generated and kept here as a hardwired list of classes. The project parameter can be used to hardwire a different set of code generators. """ # Get the list of code producing visitors. The hardwired list is # based on the project argument. A different set of visitors can # be assembled by project. project_visitor_list = self._buildVisitorList() # Instance the needed code snippet generator here. if the_type == "initFiles": code_section_generator = InitFiles.InitFiles() elif the_type == "startSource": code_section_generator = StartSource.StartSource() elif the_type == "includes1": code_section_generator = Includes1.Includes1() elif the_type == "includes2": code_section_generator = Includes2.Includes2() elif the_type == "namespace": code_section_generator = Namespace.Namespace() elif the_type == "public": code_section_generator = Public.Public() elif the_type == "protected": code_section_generator = Protected.Protected() elif the_type == "private": code_section_generator = Private.Private() elif the_type == "finishSource": code_section_generator = FinishSource.FinishSource() elif the_type == "DictStart": code_section_generator = DictStart.DictStart() elif the_type == "DictHeader": code_section_generator = DictHeader.DictHeader() elif the_type == "DictBody": code_section_generator = DictBody.DictBody() elif the_type == "InstanceDictStart": code_section_generator = InstanceDictStart.InstanceDictStart() elif the_type == "InstanceDictHeader": code_section_generator = InstanceDictHeader.InstanceDictHeader() elif the_type == "InstanceDictBody": code_section_generator = InstanceDictBody.InstanceDictBody() elif the_type == "HtmlStart": code_section_generator = HtmlStartPage.HtmlStartPage() elif the_type == "HtmlDoc": code_section_generator = HtmlDocPage.HtmlDocPage() elif the_type == "MdStart": code_section_generator = MdStartPage.MdStartPage() elif the_type == "MdDoc": code_section_generator = MdDocPage.MdDocPage() else: print "GenFactory: unsupported code section (%s)." % (the_type) return None self._addVisitor(code_section_generator, project_visitor_list) return code_section_generator