def writeClass(attributes, header, nameOfElement, nameOfPackage, hasChildren, hasMath, isListOf, elementDict): header.write('class LIBSBML_EXTERN {0} :'.format(nameOfElement)) baseClass = 'SBase' childrenOverwrite = elementDict.has_key('childrenOverwriteElementName') and elementDict['childrenOverwriteElementName'] if elementDict.has_key('baseClass') and elementDict['baseClass'] != None: baseClass = elementDict['baseClass'] header.write(' public {0}\n{1}\n\n'.format(baseClass, '{')) writeAttributes(attributes, header) if childrenOverwrite: header.write(' std::string mElementName;\n\n') header.write('public:\n\n') writeConstructors(nameOfElement, nameOfPackage, header) writeAttributeFunctions(attributes, header, nameOfElement, elementDict) if hasMath == True or generalFunctions.hasSIdRef(attributes) == True: generalFunctions.writeRenameSIdHeader(header) if hasChildren == True: generalFunctions.writeGetAllElements(header) generalFunctions.writeCommonHeaders(header, nameOfElement, attributes, False, hasChildren, hasMath) generalFunctions.writeInternalHeaders(header, isListOf, hasChildren) if generalFunctions.hasArray(elementDict): header.write(' virtual void write(XMLOutputStream& stream) const;\n\n\n') if childrenOverwrite: header.write(' virtual void setElementName(const std::string& name);\n\n\n') header.write('protected:\n\n') generalFunctions.writeProtectedHeaders(header, attributes, hasChildren, hasMath, baseClass, elementDict) if generalFunctions.hasArray(elementDict): header.write(' virtual void setElementText(const std::string &text);\n\n\n') if elementDict.has_key('addDecls'): header.write(open(elementDict['addDecls'], 'r').read()) header.write('\n};\n\n')
def writeClass(header, nameOfElement, typeOfElement, nameOfPackage, elementDict): header.write('class LIBSEDML_EXTERN {0} :'.format(generalFunctions.writeListOf(nameOfElement))) header.write(' public SedListOf\n{0}\n\n'.format('{')) header.write('public:\n\n') writeConstructors(nameOfElement, typeOfElement, nameOfPackage, header) writeGetFunctions(header, nameOfElement, typeOfElement) header.write(' /**\n') header.write(' * Adds a copy the given \"{0}\" to this {1}.\n'.format(nameOfElement, generalFunctions.writeListOf(nameOfElement))) header.write(' *\n') header.write(' * @param {0}; the {1} object to add\n'.format(strFunctions.objAbbrev(nameOfElement), nameOfElement)) header.write(' *\n') header.write(' * @return integer value indicating success/failure of the\n') header.write(' * function. @if clike The value is drawn from the\n') header.write(' * enumeration #OperationReturnValues_t. @endif The possible values\n') header.write(' * returned by this function are:\n') header.write(' * @li LIBSEDML_OPERATION_SUCCESS\n') header.write(' * @li LIBSEDML_INVALID_ATTRIBUTE_VALUE\n') header.write(' */\n') header.write(' int add{0}(const {1}* {2});\n\n\n'.format(nameOfElement, typeOfElement, strFunctions.objAbbrev(nameOfElement))) header.write(' /**\n') header.write(' * Get the number of {0} objects in this {1}.\n'.format(nameOfElement, generalFunctions.writeListOf(nameOfElement))) header.write(' *\n') header.write(' * @return the number of {0} objects in this {1}\n'.format(nameOfElement, generalFunctions.writeListOf(nameOfElement))) header.write(' */\n') header.write(' unsigned int getNum{0}s() const;\n\n\n'.format(nameOfElement)) if elementDict.has_key('abstract') == False or (elementDict.has_key('abstract') and elementDict['abstract'] == False): header.write(' /**\n') header.write(' * Creates a new {0} object, adds it to the\n'.format(nameOfElement)) header.write(' * {0} and returns the {1} object created.\n'.format(generalFunctions.writeListOf(nameOfElement), nameOfElement)) header.write(' *\n') header.write(' * @return a new {0} object instance\n'.format(nameOfElement)) header.write(' *\n') header.write(' * @see add{0}(const {1}* {2})\n'.format(nameOfElement, typeOfElement, strFunctions.objAbbrev(nameOfElement))) header.write(' */\n') header.write(' {0}* create{1}();\n\n\n'.format(typeOfElement, nameOfElement)) elif elementDict.has_key('concrete'): for elem in elementDict['concrete']: header.write(' /**\n') header.write(' * Creates a new {0} object, adds it to the\n'.format(nameOfElement)) header.write(' * {0} and returns the {1} object created.\n'.format(generalFunctions.writeListOf(nameOfElement), nameOfElement)) header.write(' *\n') header.write(' * @return a new {0} object instance\n'.format(nameOfElement)) header.write(' *\n') header.write(' * @see add{0}(const {1}* {2})\n'.format(nameOfElement, typeOfElement, strFunctions.objAbbrev(nameOfElement))) header.write(' */\n') header.write(' {0}* create{1}();\n\n\n'.format(elem['element'], strFunctions.cap(elem['name']))) writeRemoveFunctions(header, nameOfElement, typeOfElement) generalFunctions.writeCommonHeaders(header, nameOfElement, None, True) header.write('protected:\n\n') writeProtectedFunctions(header, nameOfElement, nameOfPackage) header.write('\n};\n\n')
def writeClass(header, nameOfElement, typeOfElement, nameOfPackage, elementDict): header.write('class LIBSEDML_EXTERN {0} :'.format(generalFunctions.writeListOf(nameOfElement))) header.write(' public SedListOf\n{0}\n\n'.format('{')) header.write('public:\n\n') writeConstructors(nameOfElement, typeOfElement, nameOfPackage, header) writeGetFunctions(header, nameOfElement, typeOfElement) header.write('\t/**\n') header.write('\t * Adds a copy the given \"{0}\" to this {1}.\n'.format(nameOfElement, generalFunctions.writeListOf(nameOfElement))) header.write('\t *\n') header.write('\t * @param {0}; the {1} object to add\n'.format(strFunctions.objAbbrev(nameOfElement), nameOfElement)) header.write('\t *\n') header.write('\t * @return integer value indicating success/failure of the\n') header.write('\t * function. @if clike The value is drawn from the\n') header.write('\t * enumeration #OperationReturnValues_t. @endif The possible values\n') header.write('\t * returned by this function are:\n') header.write('\t * @li LIBSEDML_OPERATION_SUCCESS\n') header.write('\t * @li LIBSEDML_INVALID_ATTRIBUTE_VALUE\n') header.write('\t */\n') header.write('\tint add{0}(const {1}* {2});\n\n\n'.format(nameOfElement, typeOfElement, strFunctions.objAbbrev(nameOfElement))) header.write('\t/**\n') header.write('\t * Get the number of {0} objects in this {1}.\n'.format(nameOfElement, generalFunctions.writeListOf(nameOfElement))) header.write('\t *\n') header.write('\t * @return the number of {0} objects in this {1}\n'.format(nameOfElement, generalFunctions.writeListOf(nameOfElement))) header.write('\t */\n') header.write('\tunsigned int getNum{0}s() const;\n\n\n'.format(nameOfElement)) if elementDict.has_key('abstract') == False or (elementDict.has_key('abstract') and elementDict['abstract'] == False): header.write('\t/**\n') header.write('\t * Creates a new {0} object, adds it to the\n'.format(nameOfElement)) header.write('\t * {0} and returns the {1} object created. \n'.format(generalFunctions.writeListOf(nameOfElement), nameOfElement)) header.write('\t *\n') header.write('\t * @return a new {0} object instance\n'.format(nameOfElement)) header.write('\t *\n') header.write('\t * @see add{0}(const {1}* {2})\n'.format(nameOfElement, typeOfElement, strFunctions.objAbbrev(nameOfElement))) header.write('\t */\n') header.write('\t{0}* create{1}();\n\n\n'.format(typeOfElement, nameOfElement)) elif elementDict.has_key('concrete'): for elem in elementDict['concrete']: header.write('\t/**\n') header.write('\t * Creates a new {0} object, adds it to the\n'.format(nameOfElement)) header.write('\t * {0} and returns the {1} object created. \n'.format(generalFunctions.writeListOf(nameOfElement), nameOfElement)) header.write('\t *\n') header.write('\t * @return a new {0} object instance\n'.format(nameOfElement)) header.write('\t *\n') header.write('\t * @see add{0}(const {1}* {2})\n'.format(nameOfElement, typeOfElement, strFunctions.objAbbrev(nameOfElement))) header.write('\t */\n') header.write('\t{0}* create{1}();\n\n\n'.format(elem['element'], strFunctions.cap(elem['name']))) writeRemoveFunctions(header, nameOfElement, typeOfElement) generalFunctions.writeCommonHeaders(header, nameOfElement, None, True) header.write('protected:\n\n') writeProtectedFunctions(header, nameOfElement, nameOfPackage) header.write('\n};\n\n')
def writeClass(attributes, header, nameOfElement, nameOfPackage, hasChildren, hasMath, isSedListOf, elementDict): writeAdditionalIncludes(attributes, header, elementDict) header.write('class LIBSEDML_EXTERN {0} :'.format(nameOfElement)) baseClass = 'SedBase' if elementDict.has_key('baseClass'): baseClass = elementDict['baseClass'] header.write(' public {0}\n{1}\n\n'.format(baseClass, '{')) writeAttributes(attributes, header) header.write('public:\n\n') writeConstructors(nameOfElement, nameOfPackage, header) writeAttributeFunctions(attributes, header, nameOfElement, elementDict) generalFunctions.writeCommonHeaders(header, nameOfElement, attributes, False, hasChildren, hasMath) generalFunctions.writeInternalHeaders(header, isSedListOf, hasChildren) header.write('protected:\n\n') generalFunctions.writeProtectedHeaders(header, hasChildren, hasMath, baseClass) if elementDict.has_key('additionalCPPDecls'): header.write(open(elementDict['additionalCPPDecls'], 'r').read()) header.write('\n};\n\n')
def writeClass(attributes, header, nameOfElement, nameOfPackage, hasChildren, hasMath, isSedListOf, elementDict): writeAdditionalIncludes(attributes, header, elementDict) writeCPPStart(header) header.write('class LIBSEDML_EXTERN {0} :'.format(nameOfElement)) baseClass = 'SedBase' if elementDict.has_key('baseClass'): baseClass = elementDict['baseClass'] header.write(' public {0}\n{1}\n\n'.format(baseClass, '{')) writeAttributes(attributes, header) header.write('public:\n\n') writeConstructors(nameOfElement, nameOfPackage, header) writeAttributeFunctions(attributes, header, nameOfElement, elementDict) generalFunctions.writeCommonHeaders(header, nameOfElement, attributes, False, hasChildren, hasMath) generalFunctions.writeInternalHeaders(header, isSedListOf, hasChildren) header.write('protected:\n\n') generalFunctions.writeProtectedHeaders(header, attributes, hasChildren, hasMath, baseClass) if elementDict.has_key('additionalCPPDecls'): header.write(open(elementDict['additionalCPPDecls'], 'r').read()) header.write('\n};\n\n')
def writeClass(header, nameOfElement, typeOfElement, nameOfPackage, elementDict): listOf = generalFunctions.getListOfClassName(elementDict, typeOfElement) header.write('class LIBSBML_EXTERN {0} :'.format(listOf)) header.write(' public ListOf\n{0}\n\n'.format('{')) header.write('public:\n\n') writeConstructors(nameOfElement, typeOfElement, nameOfPackage, header,elementDict) writeGetFunctions(header, nameOfElement, typeOfElement, False, "", elementDict) header.write('\t/**\n') header.write('\t * Adds a copy the given \"{0}\" to this {1}.\n'.format(nameOfElement, listOf)) header.write('\t *\n') header.write('\t * @param {0}; the {1} object to add\n'.format(strFunctions.objAbbrev(nameOfElement), nameOfElement)) header.write('\t *\n') header.write('\t * @return integer value indicating success/failure of the\n') header.write('\t * function. @if clike The value is drawn from the\n') header.write('\t * enumeration #OperationReturnValues_t. @endif The possible values\n') header.write('\t * returned by this function are:\n') header.write('\t * @li LIBSEDML_OPERATION_SUCCESS\n') header.write('\t * @li LIBSEDML_INVALID_ATTRIBUTE_VALUE\n') header.write('\t */\n') header.write('\tint add{0}(const {1}* {2});\n\n\n'.format(nameOfElement, typeOfElement, strFunctions.objAbbrev(nameOfElement))) header.write('\t/**\n') header.write('\t * Get the number of {0} objects in this {1}.\n'.format(nameOfElement, listOf)) header.write('\t *\n') header.write('\t * @return the number of {0} objects in this {1}\n'.format(nameOfElement, listOf)) header.write('\t */\n') header.write('\tunsigned int getNum{0}() const;\n\n\n'.format(strFunctions.capp(nameOfElement))) if elementDict.has_key('abstract') == False or (elementDict.has_key('abstract') and elementDict['abstract'] == False): header.write('\t/**\n') header.write('\t * Creates a new {0} object, adds it to the\n'.format(nameOfElement)) header.write('\t * {0} and returns the {1} object created. \n'.format(listOf, nameOfElement)) header.write('\t *\n') header.write('\t * @return a new {0} object instance\n'.format(nameOfElement)) header.write('\t *\n') header.write('\t * @see add{0}(const {1}* {2})\n'.format(nameOfElement, typeOfElement, strFunctions.objAbbrev(nameOfElement))) header.write('\t */\n') header.write('\t{0}* create{1}();\n\n\n'.format(typeOfElement, nameOfElement)) elif elementDict.has_key('concrete'): for elem in generalFunctions.getConcretes(elementDict['root'], elementDict['concrete']): header.write('\t/**\n') header.write('\t * Creates a new {0} object, adds it to the\n'.format(nameOfElement)) header.write('\t * {0} and returns the {1} object created. \n'.format(listOf, nameOfElement)) header.write('\t *\n') header.write('\t * @return a new {0} object instance\n'.format(nameOfElement)) header.write('\t *\n') header.write('\t * @see add{0}(const {1}* {2})\n'.format(nameOfElement, typeOfElement, strFunctions.objAbbrev(nameOfElement))) header.write('\t */\n') header.write('\t{0}* create{1}();\n\n\n'.format(elem['element'], strFunctions.cap(elem['name']))) writeRemoveFunctions(header, nameOfElement, typeOfElement, False, "", elementDict) generalFunctions.writeCommonHeaders(header, typeOfElement, None, True, False, False, elementDict) header.write('protected:\n\n') writeProtectedFunctions(header, nameOfElement, nameOfPackage, elementDict) if elementDict.has_key('concrete'): header.write('\tvirtual bool isValidTypeForList(SBase * item) {\n') header.write('\t\tint code = item->getTypeCode();\n') header.write('\t\treturn code == getItemTypeCode() ') for elem in generalFunctions.getConcretes(elementDict['root'], elementDict['concrete']): typecode = 'SBML_{0}_{1}'.format(nameOfPackage.upper(),elem['element'].upper()) if elem.has_key('root'): concrete = generalFunctions.getElement(elem['root'], elem['element']) if (concrete != None): typecode = concrete['typecode'] header.write('|| code == {0} '.format(typecode)) header.write(';\n') header.write('\t}\n\n\n'); friends = getInlineListOfClasses(elementDict, typeOfElement) for friend in friends: header.write('\tfriend class {0};\n'.format(friend)) header.write('\n};\n\n')
def writeClass(header, nameOfElement, typeOfElement, nameOfPackage, elementDict): listOf = generalFunctions.getListOfClassName(elementDict, typeOfElement) header.write('class LIBSBML_EXTERN {0} :'.format(listOf)) header.write(' public ListOf\n{0}\n\n'.format('{')) header.write('public:\n\n') writeConstructors(nameOfElement, typeOfElement, nameOfPackage, header, elementDict) writeGetFunctions(header, nameOfElement, typeOfElement, False, "", elementDict) header.write('\t/**\n') header.write('\t * Adds a copy the given \"{0}\" to this {1}.\n'.format( nameOfElement, listOf)) header.write('\t *\n') header.write('\t * @param {0}; the {1} object to add\n'.format( strFunctions.objAbbrev(nameOfElement), nameOfElement)) header.write('\t *\n') header.write( '\t * @return integer value indicating success/failure of the\n') header.write('\t * function. @if clike The value is drawn from the\n') header.write( '\t * enumeration #OperationReturnValues_t. @endif The possible values\n' ) header.write('\t * returned by this function are:\n') header.write('\t * @li LIBSEDML_OPERATION_SUCCESS\n') header.write('\t * @li LIBSEDML_INVALID_ATTRIBUTE_VALUE\n') header.write('\t */\n') header.write('\tint add{0}(const {1}* {2});\n\n\n'.format( nameOfElement, typeOfElement, strFunctions.objAbbrev(nameOfElement))) header.write('\t/**\n') header.write('\t * Get the number of {0} objects in this {1}.\n'.format( nameOfElement, listOf)) header.write('\t *\n') header.write('\t * @return the number of {0} objects in this {1}\n'.format( nameOfElement, listOf)) header.write('\t */\n') header.write('\tunsigned int getNum{0}() const;\n\n\n'.format( strFunctions.capp(nameOfElement))) if elementDict.has_key('abstract') == False or ( elementDict.has_key('abstract') and elementDict['abstract'] == False): header.write('\t/**\n') header.write('\t * Creates a new {0} object, adds it to the\n'.format( nameOfElement)) header.write('\t * {0} and returns the {1} object created. \n'.format( listOf, nameOfElement)) header.write('\t *\n') header.write( '\t * @return a new {0} object instance\n'.format(nameOfElement)) header.write('\t *\n') header.write('\t * @see add{0}(const {1}* {2})\n'.format( nameOfElement, typeOfElement, strFunctions.objAbbrev(nameOfElement))) header.write('\t */\n') header.write('\t{0}* create{1}();\n\n\n'.format( typeOfElement, nameOfElement)) elif elementDict.has_key('concrete'): for elem in generalFunctions.getConcretes(elementDict['root'], elementDict['concrete']): header.write('\t/**\n') header.write( '\t * Creates a new {0} object, adds it to the\n'.format( nameOfElement)) header.write( '\t * {0} and returns the {1} object created. \n'.format( listOf, nameOfElement)) header.write('\t *\n') header.write('\t * @return a new {0} object instance\n'.format( nameOfElement)) header.write('\t *\n') header.write('\t * @see add{0}(const {1}* {2})\n'.format( nameOfElement, typeOfElement, strFunctions.objAbbrev(nameOfElement))) header.write('\t */\n') header.write('\t{0}* create{1}();\n\n\n'.format( elem['element'], strFunctions.cap(elem['name']))) writeRemoveFunctions(header, nameOfElement, typeOfElement, False, "", elementDict) generalFunctions.writeCommonHeaders(header, typeOfElement, None, True, False, False, elementDict) header.write('protected:\n\n') writeProtectedFunctions(header, nameOfElement, nameOfPackage, elementDict) if elementDict.has_key('concrete'): header.write('\tvirtual bool isValidTypeForList(SBase * item) {\n') header.write('\t\tint code = item->getTypeCode();\n') header.write('\t\treturn code == getItemTypeCode() ') for elem in generalFunctions.getConcretes(elementDict['root'], elementDict['concrete']): typecode = 'SBML_{0}_{1}'.format(nameOfPackage.upper(), elem['element'].upper()) if elem.has_key('root'): concrete = generalFunctions.getElement(elem['root'], elem['element']) if (concrete != None): typecode = concrete['typecode'] header.write('|| code == {0} '.format(typecode)) header.write(';\n') header.write('\t}\n\n\n') friends = getInlineListOfClasses(elementDict, typeOfElement) for friend in friends: header.write('\tfriend class {0};\n'.format(friend)) header.write('\n};\n\n')