Exemplo n.º 1
0
def writeGetCode(attrib, output, element):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  if attType == 'lo_element':
    return
  output.write('/*\n')
  output.write(' * Returns the value of the \"{0}\"'.format(attName))
  output.write(' attribute of this {0}.\n'.format(element))
  output.write(' */\n')
  output.write('const {0}\n'.format(attTypeCode))
  output.write('{0}::get{1}() const\n'.format(element, capAttName))
  output.write('{\n')
  output.write('\treturn m{0};\n'.format(capAttName))
  output.write('}\n\n\n')
  if attType == 'element' and attName != 'math':
    output.write('/*\n')
    output.write(' * Creates a new \"{0}\"'.format(attName))
    output.write(' element of this {0} and returns it.\n'.format(element))
    output.write(' */\n')
    output.write('{0}\n'.format(attTypeCode))
    output.write('{0}::create{1}()\n'.format(element, capAttName))
    output.write('{\n')
    output.write('\tm{0} = new {1}();\n'.format(capAttName, attrib['element']))
    output.write('\treturn m{0};\n'.format(capAttName))
    output.write('}\n\n\n')
Exemplo n.º 2
0
def writeAtt(attrib, output):
    att = generalFunctions.parseAttribute(attrib)
    attName = att[0]
    capAttName = att[1]
    attType = att[2]
    attTypeCode = att[3]
    num = att[4]
    if attType == 'string':
        output.write('\tstd::string   m{0};\n'.format(capAttName))
    elif attType == 'element':
        if attTypeCode == 'ASTNode*' or attName == 'Math':
            output.write('\tASTNode*      m{0};\n'.format(capAttName))
        else:
            output.write('\t{0}*      m{1};\n'.format(attrib['element'],
                                                      capAttName))
            return
    elif attType == 'lo_element':
        output.write('\t{0}   m{1};\n'.format(
            generalFunctions.writeListOf(capAttName), capAttName))
    elif num == True:
        while len(attTypeCode) < 13:
            attTypeCode = attTypeCode + ' '
        output.write('\t{1} m{0};\n'.format(capAttName, attTypeCode))
        output.write('\tbool          mIsSet{0};\n'.format(capAttName))
    elif attType == 'boolean':
        output.write('\tbool          m{0};\n'.format(capAttName))
        output.write('\tbool          mIsSet{0};\n'.format(capAttName))
    else:
        output.write('\tFIX ME   {0};\n'.format(attName))
Exemplo n.º 3
0
def writeIsSetCode(attrib, output, element):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  if attType == 'lo_element' or attType == 'inline_lo_element':
    return
  output.write('/*\n')
  output.write(' * Returns true/false if {0} is set.\n'.format(attName))
  output.write(' */\n')
  output.write('bool\n')
  output.write('{0}::isSet{1}() const\n'.format(element, capAttName))
  output.write('{\n')
  if attType == 'string':
    output.write('  return (m{0}.empty() == false);\n'.format(capAttName))
  elif attType == 'element' or attType == 'XMLNode*':
    output.write('  return (m{0} != NULL);\n'.format(capAttName))
  elif num == True:
    output.write('  return mIsSet{0};\n'.format(capAttName))
  elif attType == 'boolean':
    output.write('  return mIsSet{0};\n'.format(capAttName))
  elif attrib['type'] == 'enum':
    output.write('  return m{0} != {1}_UNKNOWN;\n'.format(capAttName, attrib['element'].upper()))
  elif attrib['type'] == 'array':
    output.write('  return (m{0} != NULL);\n'.format(capAttName))
  output.write('}\n\n\n')
Exemplo n.º 4
0
def writeAtt(attrib, output):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  if attType == 'string':
    output.write('\tstd::string   m{0};\n'.format(capAttName))
  elif attType == 'element':    
    if attTypeCode == 'ASTNode*' or attName== 'Math':
      output.write('\tASTNode*      m{0};\n'.format(capAttName))
    else:
      output.write('\t{0}*      m{1};\n'.format(attrib['element'], capAttName))
      return
  elif attType == 'lo_element':
    output.write('\t{0}   m{1};\n'.format(generalFunctions.writeListOf(capAttName), capAttName))
  elif num == True:
    while len(attTypeCode) < 13:
      attTypeCode = attTypeCode + ' '
    output.write('\t{1} m{0};\n'.format(capAttName, attTypeCode))
    output.write('\tbool          mIsSet{0};\n'.format(capAttName))
  elif attType == 'boolean':
    output.write('\tbool          m{0};\n'.format(capAttName))
    output.write('\tbool          mIsSet{0};\n'.format(capAttName))
  else:
    output.write('\tFIX ME   {0};\n'.format(attName))
def writeAtt(attrib, output):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  if attType == 'string':
    output.write('  std::string   m{0};\n'.format(capAttName))
  elif attType == 'element':    
    if attTypeCode == 'ASTNode*' or attName== 'Math':
      output.write('  ASTNode*      m{0};\n'.format(capAttName))
    else:
      output.write('  {0}*      m{1};\n'.format(attrib['element'], capAttName))
      return
  elif attType == 'lo_element':
    output.write('  {0}   m{1};\n'.format(generalFunctions.writeListOf(capAttName), strFunctions.capp(attName)))
  elif attTypeCode == 'XMLNode*':
    output.write('  {0}   m{1};\n'.format('XMLNode*', capAttName))
  elif attTypeCode == 'DimensionDescription*':
    output.write('  {0}   m{1};\n'.format('DimensionDescription*', capAttName))
  elif num == True:
    while len(attTypeCode) < 13:
      attTypeCode = attTypeCode + ' '
    output.write('  {1} m{0};\n'.format(capAttName, attTypeCode))
    output.write('  bool          mIsSet{0};\n'.format(capAttName))
  elif attType == 'boolean':
    output.write('  bool          m{0};\n'.format(capAttName))
    output.write('  bool          mIsSet{0};\n'.format(capAttName))
  elif attType == 'std::vector<double>':
    output.write('  std::vector<double>  m{0};\n'.format( strFunctions.capp(attName)))    
  else:
    output.write('  FIX ME   {0};\n'.format(attName))
def writeIsSetCode(attrib, output, element):
    att = generalFunctions.parseAttribute(attrib)
    attName = att[0]
    capAttName = att[1]
    attType = att[2]
    attTypeCode = att[3]
    num = att[4]
    if attType == 'lo_element':
        return
    elif attrib['type'] == 'std::vector<double>':
        output.write('/**\n')
        output.write(
            ' * Predicate returning @c true or @c false depending on ')
        output.write('whether this\n * {0}\'s \"{1}\" '.format(
            element, attName))
        output.write('element has elements set.\n *\n')
        output.write(' * @return @c true if this {0}\'s \"{1}\"'.format(
            element, attName))
        output.write(' element has been set,\n')
        output.write(' * otherwise @c false is returned.\n')
        output.write(' */\n')
        output.write('bool\n{0}::has{1}() const\n'.format(
            element, strFunctions.capp(capAttName)))
        output.write('{\n')
        output.write('  return m{0}.size() > 0;\n'.format(
            strFunctions.capp(capAttName)))
        output.write('}\n\n\n')
        output.write('/**\n')
        output.write(
            ' * Returning the number of elements in this\n * {0}\'s \"{1}\" '.
            format(element, attName))
        output.write('.\n *\n')
        output.write(
            ' * @return number of elements in this {0}\'s \"{1}\"'.format(
                element, attName))
        output.write('\n')
        output.write(' */\n')
        output.write('unsigned int\n{0}::getNum{1}() const\n'.format(
            element, strFunctions.capp(capAttName)))
        output.write('{\n')
        output.write('  return (unsigned int)m{0}.size();\n'.format(
            strFunctions.capp(capAttName)))
        output.write('}\n\n\n')
    else:
        output.write('/*\n')
        output.write(' * Returns true/false if {0} is set.\n'.format(attName))
        output.write(' */\n')
        output.write('bool\n')
        output.write('{0}::isSet{1}() const\n'.format(element, capAttName))
        output.write('{\n')
        if attType == 'string':
            output.write(
                '  return (m{0}.empty() == false);\n'.format(capAttName))
        elif attType == 'element' or attType == 'XMLNode*' or attType == 'DimensionDescription*':
            output.write('  return (m{0} != NULL);\n'.format(capAttName))
        elif num == True:
            output.write('  return mIsSet{0};\n'.format(capAttName))
        elif attType == 'boolean':
            output.write('  return mIsSet{0};\n'.format(capAttName))
        output.write('}\n\n\n')
Exemplo n.º 7
0
def writeIsSetFunction(attrib, output, element):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  if attrib['type'] == 'lo_element' or attrib['type'] == 'inline_lo_element':
    return
  elif attrib['type'] == 'element':
    output.write('  /**\n')
    output.write('   * Predicate returning @c true or @c false depending on ')
    output.write('whether this\n   * {0}\'s \"{1}\" '.format(element, attName))
    output.write('element has been set.\n   *\n')
    output.write('   * @return @c true if this {0}\'s \"{1}\"'.format(element, attName))
    output.write(' element has been set,\n')
    output.write('   * otherwise @c false is returned.\n')
    output.write('   */\n')
    output.write('  virtual bool isSet{0}() const;\n\n\n'.format(capAttName))
  else:
    output.write('  /**\n')
    output.write('   * Predicate returning @c true or @c false depending on ')
    output.write('whether this\n   * {0}\'s \"{1}\" '.format(element, attName))
    output.write('attribute has been set.\n   *\n')
    output.write('   * @return @c true if this {0}\'s \"{1}\"'.format(element, attName))
    output.write(' attribute has been set,\n')
    output.write('   * otherwise @c false is returned.\n')
    output.write('   */\n')
    output.write('  virtual bool isSet{0}() const;\n\n\n'.format(capAttName))
Exemplo n.º 8
0
def writeIsSetFunction(attrib, output, element):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  if attrib['type'] == 'lo_element' or attrib['type'] == 'inline_lo_element':
    return
  elif attrib['type'] == 'element':
    output.write('  /**\n')
    output.write('   * Predicate returning @c true or @c false depending on ')
    output.write('whether this\n   * {0}\'s \"{1}\" '.format(element, attName))
    output.write('element has been set.\n   *\n')
    output.write('   * @return @c true if this {0}\'s \"{1}\"'.format(element, attName))
    output.write(' element has been set,\n')
    output.write('   * otherwise @c false is returned.\n')
    output.write('   */\n')
    output.write('  virtual bool isSet{0}() const;\n\n\n'.format(capAttName))
  else:
    output.write('  /**\n')
    output.write('   * Predicate returning @c true or @c false depending on ')
    output.write('whether this\n   * {0}\'s \"{1}\" '.format(element, attName))
    output.write('attribute has been set.\n   *\n')
    output.write('   * @return @c true if this {0}\'s \"{1}\"'.format(element, attName))
    output.write(' attribute has been set,\n')
    output.write('   * otherwise @c false is returned.\n')
    output.write('   */\n')
    output.write('  virtual bool isSet{0}() const;\n\n\n'.format(capAttName))
Exemplo n.º 9
0
def writeIsSetCode(attrib, output, element):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  if attType == 'lo_element' or attType == 'inline_lo_element':
    return
  output.write('/*\n')
  output.write(' * Returns true/false if {0} is set.\n'.format(attName))
  output.write(' */\n')
  output.write('bool\n')
  output.write('{0}::isSet{1}() const\n'.format(element, capAttName))
  output.write('{\n')
  if attType == 'string':
    output.write('  return (m{0}.empty() == false);\n'.format(capAttName))
  elif attType == 'element' or attType == 'XMLNode*':
    output.write('  return (m{0} != NULL);\n'.format(capAttName))
  elif num == True:
    output.write('  return mIsSet{0};\n'.format(capAttName))
  elif attType == 'boolean':
    output.write('  return mIsSet{0};\n'.format(capAttName))
  elif attrib['type'] == 'enum':
    output.write('  return m{0} != {1}_UNKNOWN;\n'.format(capAttName, attrib['element'].upper()))
  elif attrib['type'] == 'array':
    output.write('  return (m{0} != NULL);\n'.format(capAttName))
  output.write('}\n\n\n')
Exemplo n.º 10
0
def writeGetCode(attrib, output, element):
    att = generalFunctions.parseAttribute(attrib)
    attName = att[0]
    capAttName = att[1]
    attType = att[2]
    attTypeCode = att[3]
    if attType == 'lo_element':
        return
    output.write('/*\n')
    output.write(' * Returns the value of the \"{0}\"'.format(attName))
    output.write(' attribute of this {0}.\n'.format(element))
    output.write(' */\n')
    output.write('const {0}\n'.format(attTypeCode))
    output.write('{0}::get{1}() const\n'.format(element, capAttName))
    output.write('{\n')
    output.write('\treturn m{0};\n'.format(capAttName))
    output.write('}\n\n\n')
    if attType == 'element' and attName != 'math':
        output.write('/*\n')
        output.write(' * Creates a new \"{0}\"'.format(attName))
        output.write(' element of this {0} and returns it.\n'.format(element))
        output.write(' */\n')
        output.write('{0}\n'.format(attTypeCode))
        output.write('{0}::create{1}()\n'.format(element, capAttName))
        output.write('{\n')
        output.write('\tm{0} = new {1}();\n'.format(capAttName,
                                                    attrib['element']))
        output.write('\treturn m{0};\n'.format(capAttName))
        output.write('}\n\n\n')
Exemplo n.º 11
0
def writeUnsetCode(attrib, output, element):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  if attType == 'lo_element':
    return
  elif attrib['type'] == 'std::vector<double>':
    output.write('/**\n')
    output.write(' * Clears the \"{0}\"'.format(attName))
    output.write(' element of this {0}.\n'.format(element))
    output.write(' *\n')
    output.write(' * @return integer value indicating success/failure of the\n')
    output.write(' * function.  @if clike The value is drawn from the\n')
    output.write(' * enumeration #OperationReturnValues_t. @endif The possible values\n')
    output.write(' * returned by this function are:\n')
    output.write(' * @li LIBSEDML_OPERATION_SUCCESS\n')
    output.write(' * @li LIBSEDML_OPERATION_FAILED\n')
    output.write(' */\n')
    output.write('int\n{0}::clear{1}()\n'.format(element, strFunctions.capp(capAttName)))
    output.write('{\n')
    output.write('\tm{0}.clear();\n'.format(strFunctions.capp(capAttName)))
    output.write('\treturn LIBSEDML_OPERATION_SUCCESS;\n')
    output.write('}\n\n\n')
  else:    
    output.write('/*\n')
    output.write(' * Unsets {0} and returns value indicating success.\n'.format(attName))
    output.write(' */\n')
    output.write('int\n')
    output.write('{0}::unset{1}()\n'.format(element, capAttName))
    output.write('{\n')
    if attType == 'string':
      output.write('\tm{0}.erase();\n\n'.format(capAttName))
      output.write('\tif (m{0}.empty() == true)\n'.format(capAttName))
      output.write('\t{\n\t\treturn LIBSEDML_OPERATION_SUCCESS;\n\t}\n')
      output.write('\telse\n\t{\n')
      output.write('\t\treturn LIBSEDML_OPERATION_FAILED;\n\t}\n')
    elif num == True:
      if attType == 'double':
        output.write('\tm{0} = numeric_limits<double>::quiet_NaN();\n'.format(capAttName))
      else:
        output.write('\tm{0} = SEDML_INT_MAX;\n'.format(capAttName))
      output.write('\tmIsSet{0} = false;\n\n'.format(capAttName))
      output.write('\tif (isSet{0}() == false)\n'.format(capAttName))
      output.write('\t{\n\t\treturn LIBSEDML_OPERATION_SUCCESS;\n\t}\n')
      output.write('\telse\n\t{\n')
      output.write('\t\treturn LIBSEDML_OPERATION_FAILED;\n\t}\n')
    elif attType == 'boolean':
      output.write('\tm{0} = false;\n'.format(capAttName))
      output.write('\tmIsSet{0} = false;\n'.format(capAttName))
      output.write('\treturn LIBSEDML_OPERATION_SUCCESS;\n')
    elif attType == 'element' or attType == 'XMLNode*':
      output.write('\tdelete m{0};\n'.format(capAttName))
      output.write('\tm{0} = NULL;\n'.format(capAttName))
      output.write('\treturn LIBSEDML_OPERATION_SUCCESS;\n')
    output.write('}\n\n\n')
Exemplo n.º 12
0
def writeInclude(attrib, output):
    att = generalFunctions.parseAttribute(attrib)
    attName = att[0]
    capAttName = att[1]
    attType = att[2]
    attTypeCode = att[3]
    num = att[4]
    if attType == 'lo_element':
        output.write('#include <sedml/{0}.h>\n'.format(attrib['element']))
Exemplo n.º 13
0
def writeInclude(attrib, output):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  if attType == 'lo_element':
    output.write('#include <sedml/{0}.h>\n'.format(attrib['element']))  
Exemplo n.º 14
0
def writeSetFunction(attrib, output, element):
    att = generalFunctions.parseAttribute(attrib)
    attName = att[0]
    capAttName = att[1]
    attType = att[2]
    if attType == 'string':
        attTypeCode = 'const std::string&'
    else:
        attTypeCode = att[3]
    num = att[4]
    if attrib['type'] == 'lo_element':
        return
    elif attrib['type'] == 'element':
        output.write('\t/**\n')
        output.write('\t * Sets the \"{0}\"'.format(attName))
        output.write(' element of this {0}.\n'.format(element))
        output.write('\t *\n')
        output.write(
            '\t * @param {0}; {1} determining the value of the "resultLevel" attribute to be set.\n'
            .format(attName, attTypeCode))
        output.write('\t *\n')
        output.write(
            '\t * @return integer value indicating success/failure of the\n')
        output.write('\t * function.  @if clike The value is drawn from the\n')
        output.write(
            '\t * enumeration #OperationReturnValues_t. @endif The possible values\n'
        )
        output.write('\t * returned by this function are:\n')
        output.write('\t * @li LIBSEDML_OPERATION_SUCCESS\n')
        output.write('\t * @li LIBSEDML_INVALID_ATTRIBUTE_VALUE\n')
        output.write('\t */\n')
        output.write('\tvirtual int set{0}('.format(capAttName))
        output.write('{0} {1});\n\n\n'.format(attTypeCode, attName))
    else:
        output.write('\t/**\n')
        output.write('\t * Sets the value of the \"{0}\"'.format(attName))
        output.write(' attribute of this {0}.\n'.format(element))
        output.write('\t *\n')
        output.write(
            '\t * @param {0}; {1} value of the "{0}" attribute to be set\n'.
            format(attName, attTypeCode))
        output.write('\t *\n')
        output.write(
            '\t * @return integer value indicating success/failure of the\n')
        output.write('\t * function.  @if clike The value is drawn from the\n')
        output.write(
            '\t * enumeration #OperationReturnValues_t. @endif The possible values\n'
        )
        output.write('\t * returned by this function are:\n')
        output.write('\t * @li LIBSEDML_OPERATION_SUCCESS\n')
        output.write('\t * @li LIBSEDML_INVALID_ATTRIBUTE_VALUE\n')
        output.write('\t */\n')
        output.write('\tvirtual int set{0}('.format(capAttName))
        output.write('{0} {1});\n\n\n'.format(attTypeCode, attName))
Exemplo n.º 15
0
def writeGetFunction(attrib, output, element):
    att = generalFunctions.parseAttribute(attrib)
    attName = att[0]
    capAttName = att[1]
    attType = att[2]
    attTypeCode = att[3]
    num = att[4]
    if attrib['type'] == 'lo_element':
        return
    elif attrib['type'] == 'element':
        if attrib['name'] == 'Math' or attrib['name'] == 'math':
            output.write('\t/**\n')
            output.write('\t * Returns the \"{0}\"'.format(attName))
            output.write(' element of this {0}.\n'.format(element))
            output.write('\t *\n')
            output.write('\t * @return the \"{0}\"'.format(attName))
            output.write(' element of this {0}.\n'.format(element))
            output.write('\t */\n')
            output.write('\tvirtual const ASTNode*')
            output.write(' get{0}() const;\n\n\n'.format(capAttName))
        else:
            output.write('\t/**\n')
            output.write('\t * Returns the \"{0}\"'.format(attName))
            output.write(' element of this {0}.\n'.format(element))
            output.write('\t *\n')
            output.write('\t * @return the \"{0}\"'.format(attName))
            output.write(' element of this {0}.\n'.format(element))
            output.write('\t */\n')
            output.write('\tvirtual const {0}*'.format(attrib['element']))
            output.write(' get{0}() const;\n\n\n'.format(capAttName))
            output.write('\t/**\n')
            output.write('\t * Creates a new \"{0}\"'.format(
                attrib['element']))
            output.write(' and sets it for this {0}.\n'.format(element))
            output.write('\t *\n')
            output.write('\t * @return the created \"{0}\"'.format(
                attrib['element']))
            output.write(' element of this {0}.\n'.format(element))
            output.write('\t */\n')
            output.write('\tvirtual {0}*'.format(attrib['element']))
            output.write(' create{0}();\n\n\n'.format(capAttName))
    else:
        output.write('\t/**\n')
        output.write('\t * Returns the value of the \"{0}\"'.format(attName))
        output.write(' attribute of this {0}.\n'.format(element))
        output.write('\t *\n')
        output.write('\t * @return the value of the \"{0}\"'.format(attName))
        output.write(' attribute of this {0} as a {1}.\n'.format(
            element, attType))
        output.write('\t */\n')
        output.write('\tvirtual const {0}'.format(attTypeCode))
        output.write(' get{0}() const;\n\n\n'.format(capAttName))
def writeInclude(attrib, output):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  if attType == 'lo_element':
    output.write('#include <sedml/{0}.h>\n'.format(attrib['element']))
  elif attType == 'std::vector<double>':
    output.write('#include <vector>\n')
  elif attType == 'DimensionDescription*':
    output.write('#include <numl/DimensionDescription.h>\n')
Exemplo n.º 17
0
def writeGetFunction(attrib, output, element):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  if attrib['type'] == 'lo_element':
    return
  elif attrib['type'] == 'element':
    if attrib['name'] == 'Math' or attrib['name'] == 'math':
      output.write('\t/**\n')
      output.write('\t * Returns the \"{0}\"'.format(attName))
      output.write(' element of this {0}.\n'.format(element))
      output.write('\t *\n')
      output.write('\t * @return the \"{0}\"'.format(attName))
      output.write(' element of this {0}.\n'.format(element))
      output.write('\t */\n')
      output.write('\tvirtual const ASTNode*')
      output.write(' get{0}() const;\n\n\n'.format(capAttName))
    else:
      output.write('\t/**\n')
      output.write('\t * Returns the \"{0}\"'.format(attName))
      output.write(' element of this {0}.\n'.format(element))
      output.write('\t *\n')
      output.write('\t * @return the \"{0}\"'.format(attName))
      output.write(' element of this {0}.\n'.format(element))
      output.write('\t */\n')
      output.write('\tvirtual const {0}*'.format(attrib['element']))
      output.write(' get{0}() const;\n\n\n'.format(capAttName))
      output.write('\t/**\n')
      output.write('\t * Creates a new \"{0}\"'.format(attrib['element']))
      output.write(' and sets it for this {0}.\n'.format(element))
      output.write('\t *\n')
      output.write('\t * @return the created \"{0}\"'.format(attrib['element']))
      output.write(' element of this {0}.\n'.format(element))
      output.write('\t */\n')
      output.write('\tvirtual {0}*'.format(attrib['element']))
      output.write(' create{0}();\n\n\n'.format(capAttName))
  else:
    output.write('\t/**\n')
    output.write('\t * Returns the value of the \"{0}\"'.format(attName))
    output.write(' attribute of this {0}.\n'.format(element))
    output.write('\t *\n')
    output.write('\t * @return the value of the \"{0}\"'.format(attName))
    output.write(' attribute of this {0} as a {1}.\n'.format(element, attType))
    output.write('\t */\n')
    output.write('\tvirtual const {0}'.format(attTypeCode))
    output.write(' get{0}() const;\n\n\n'.format(capAttName))
Exemplo n.º 18
0
def writeIsSetCode(attrib, output, element):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  if attType == 'lo_element':
    return
  elif attrib['type'] == 'std::vector<double>':
    output.write('/**\n')
    output.write(' * Predicate returning @c true or @c false depending on ')
    output.write('whether this\n * {0}\'s \"{1}\" '.format(element, attName))
    output.write('element has elements set.\n *\n')
    output.write(' * @return @c true if this {0}\'s \"{1}\"'.format(element, attName))
    output.write(' element has been set,\n')
    output.write(' * otherwise @c false is returned.\n')
    output.write(' */\n')
    output.write('bool\n{0}::has{1}() const\n'.format(element, strFunctions.capp(capAttName)))  
    output.write('{\n')
    output.write('\treturn m{0}.size() > 0;\n'.format(strFunctions.capp(capAttName)))
    output.write('}\n\n\n')
    output.write('/**\n')
    output.write(' * Returning the number of elements in this\n * {0}\'s \"{1}\" '.format(element, attName))
    output.write('.\n *\n')
    output.write(' * @return number of elements in this {0}\'s \"{1}\"'.format(element, attName))
    output.write(' \n')
    output.write(' */\n')
    output.write('unsigned int\n{0}::getNum{1}() const\n'.format(element, strFunctions.capp(capAttName)))  
    output.write('{\n')
    output.write('\treturn (unsigned int)m{0}.size();\n'.format(strFunctions.capp(capAttName)))
    output.write('}\n\n\n')
  else:
    output.write('/*\n')
    output.write(' * Returns true/false if {0} is set.\n'.format(attName))
    output.write(' */\n')
    output.write('bool\n')
    output.write('{0}::isSet{1}() const\n'.format(element, capAttName))
    output.write('{\n')
    if attType == 'string':
      output.write('\treturn (m{0}.empty() == false);\n'.format(capAttName))
    elif attType == 'element' or attType == 'XMLNode*':
      output.write('\treturn (m{0} != NULL);\n'.format(capAttName))
    elif num == True:
      output.write('\treturn mIsSet{0};\n'.format(capAttName))
    elif attType == 'boolean':
      output.write('\treturn mIsSet{0};\n'.format(capAttName))
    output.write('}\n\n\n')
Exemplo n.º 19
0
def writeUnsetCode(attrib, output, element):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  if attType == 'lo_element' or attType == 'inline_lo_element':
    return
  output.write('/*\n')
  output.write(' * Unsets {0} and returns value indicating success.\n'.format(attName))
  output.write(' */\n')
  output.write('int\n')
  output.write('{0}::unset{1}()\n'.format(element, capAttName))
  output.write('{\n')
  if attType == 'string':
    output.write('  m{0}.erase();\n\n'.format(capAttName))
    output.write('  if (m{0}.empty() == true)\n'.format(capAttName))
    output.write('  {\n    return LIBSBML_OPERATION_SUCCESS;\n  }\n')
    output.write('  else\n  {\n')
    output.write('    return LIBSBML_OPERATION_FAILED;\n  }\n')
  elif num == True:
    if attType == 'double':
      output.write('  m{0} = numeric_limits<double>::quiet_NaN();\n'.format(capAttName))
    else:
      output.write('  m{0} = SBML_INT_MAX;\n'.format(capAttName))
    output.write('  mIsSet{0} = false;\n\n'.format(capAttName))
    output.write('  if (isSet{0}() == false)\n'.format(capAttName))
    output.write('  {\n    return LIBSBML_OPERATION_SUCCESS;\n  }\n')
    output.write('  else\n  {\n')
    output.write('    return LIBSBML_OPERATION_FAILED;\n  }\n')
  elif attType == 'boolean':
    output.write('  m{0} = false;\n'.format(capAttName))
    output.write('  mIsSet{0} = false;\n'.format(capAttName))
    output.write('  return LIBSBML_OPERATION_SUCCESS;\n')
  elif attType == 'element':
    output.write('  delete m{0};\n'.format(capAttName))
    output.write('  m{0} = NULL;\n'.format(capAttName))
    output.write('  return LIBSBML_OPERATION_SUCCESS;\n')
  elif attrib['type'] == 'enum':
    output.write('  m{0} = {1}_UNKNOWN;\n'.format(capAttName, attrib['element'].upper()))
    output.write('  return LIBSBML_OPERATION_SUCCESS;\n')
  elif attrib['type'] == 'array':
    output.write('  if (m{0} != NULL)\n'.format(capAttName))
    output.write('   delete[] m{0};\n'.format(capAttName))
    output.write('  m{0} = NULL;\n'.format(capAttName))
    output.write('  return unset{0}Length();\n'.format(capAttName))
  output.write('}\n\n\n')
Exemplo n.º 20
0
def writeUnsetCode(attrib, output, element):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  if attType == 'lo_element' or attType == 'inline_lo_element':
    return
  output.write('/*\n')
  output.write(' * Unsets {0} and returns value indicating success.\n'.format(attName))
  output.write(' */\n')
  output.write('int\n')
  output.write('{0}::unset{1}()\n'.format(element, capAttName))
  output.write('{\n')
  if attType == 'string':
    output.write('  m{0}.erase();\n\n'.format(capAttName))
    output.write('  if (m{0}.empty() == true)\n'.format(capAttName))
    output.write('  {\n    return LIBSBML_OPERATION_SUCCESS;\n  }\n')
    output.write('  else\n  {\n')
    output.write('    return LIBSBML_OPERATION_FAILED;\n  }\n')
  elif num == True:
    if attType == 'double':
      output.write('  m{0} = numeric_limits<double>::quiet_NaN();\n'.format(capAttName))
    else:
      output.write('  m{0} = SBML_INT_MAX;\n'.format(capAttName))
    output.write('  mIsSet{0} = false;\n\n'.format(capAttName))
    output.write('  if (isSet{0}() == false)\n'.format(capAttName))
    output.write('  {\n    return LIBSBML_OPERATION_SUCCESS;\n  }\n')
    output.write('  else\n  {\n')
    output.write('    return LIBSBML_OPERATION_FAILED;\n  }\n')
  elif attType == 'boolean':
    output.write('  m{0} = false;\n'.format(capAttName))
    output.write('  mIsSet{0} = false;\n'.format(capAttName))
    output.write('  return LIBSBML_OPERATION_SUCCESS;\n')
  elif attType == 'element':
    output.write('  delete m{0};\n'.format(capAttName))
    output.write('  m{0} = NULL;\n'.format(capAttName))
    output.write('  return LIBSBML_OPERATION_SUCCESS;\n')
  elif attrib['type'] == 'enum':
    output.write('  m{0} = {1}_UNKNOWN;\n'.format(capAttName, attrib['element'].upper()))
    output.write('  return LIBSBML_OPERATION_SUCCESS;\n')
  elif attrib['type'] == 'array':
    output.write('  if (m{0} != NULL)\n'.format(capAttName))
    output.write('   delete[] m{0};\n'.format(capAttName))
    output.write('  m{0} = NULL;\n'.format(capAttName))
    output.write('  return unset{0}Length();\n'.format(capAttName))
  output.write('}\n\n\n')
def writeIsSetFunction(attrib, output, element):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  if attrib['type'] == 'lo_element':
    return
  elif attrib['type'] == 'std::vector<double>':
    output.write('  /**\n')
    output.write('   * Predicate returning @c true or @c false depending on ')
    output.write('whether this\n   * {0}\'s \"{1}\" '.format(element, attName))
    output.write('element has elements set.\n   *\n')
    output.write('   * @return @c true if this {0}\'s \"{1}\"'.format(element, attName))
    output.write(' element has been set,\n')
    output.write('   * otherwise @c false is returned.\n')
    output.write('   */\n')
    output.write('  virtual bool has{0}() const;\n\n\n'.format(strFunctions.capp(capAttName)))  
    output.write('  /**\n')
    output.write('   * Returning the number of elements in this\n   * {0}\'s \"{1}\" '.format(element, attName))
    output.write('.\n   *\n')
    output.write('   * @return number of elements in this {0}\'s \"{1}\"'.format(element, attName))
    output.write('\n')
    output.write('   */\n')
    output.write('  virtual unsigned int getNum{0}() const;\n\n\n'.format(strFunctions.capp(capAttName)))  
  elif attrib['type'] == 'element':
    output.write('  /**\n')
    output.write('   * Predicate returning @c true or @c false depending on ')
    output.write('whether this\n   * {0}\'s \"{1}\" '.format(element, attName))
    output.write('element has been set.\n   *\n')
    output.write('   * @return @c true if this {0}\'s \"{1}\"'.format(element, attName))
    output.write(' element has been set,\n')
    output.write('   * otherwise @c false is returned.\n')
    output.write('   */\n')
    output.write('  virtual bool isSet{0}() const;\n\n\n'.format(capAttName))
  else:
    output.write('  /**\n')
    output.write('   * Predicate returning @c true or @c false depending on ')
    output.write('whether this\n   * {0}\'s \"{1}\" '.format(element, attName))
    output.write('attribute has been set.\n   *\n')
    output.write('   * @return @c true if this {0}\'s \"{1}\"'.format(element, attName))
    output.write(' attribute has been set,\n')
    output.write('   * otherwise @c false is returned.\n')
    output.write('   */\n')
    output.write('  virtual bool isSet{0}() const;\n\n\n'.format(capAttName))
Exemplo n.º 22
0
def writeSetFunction(attrib, output, element):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  if attType == 'string':
    attTypeCode = 'const std::string&' 
  else:
    attTypeCode = att[3]
  num = att[4]
  if attrib['type'] == 'lo_element':
    return
  elif attrib['type'] == 'element':    
    output.write('\t/**\n')
    output.write('\t * Sets the \"{0}\"'.format(attName))
    output.write(' element of this {0}.\n'.format(element))
    output.write('\t *\n')
    output.write('\t * @param {0}; {1} determining the value of the "resultLevel" attribute to be set.\n'.format(attName, attTypeCode))
    output.write('\t *\n')
    output.write('\t * @return integer value indicating success/failure of the\n')
    output.write('\t * function.  @if clike The value is drawn from the\n')
    output.write('\t * enumeration #OperationReturnValues_t. @endif The possible values\n')
    output.write('\t * returned by this function are:\n')
    output.write('\t * @li LIBSEDML_OPERATION_SUCCESS\n')
    output.write('\t * @li LIBSEDML_INVALID_ATTRIBUTE_VALUE\n')
    output.write('\t */\n')
    output.write('\tvirtual int set{0}('.format(capAttName))
    output.write('{0} {1});\n\n\n'.format(attTypeCode, attName))    
  else:
    output.write('\t/**\n')
    output.write('\t * Sets the value of the \"{0}\"'.format(attName))
    output.write(' attribute of this {0}.\n'.format(element))
    output.write('\t *\n')
    output.write('\t * @param {0}; {1} value of the "{0}" attribute to be set\n'.format(attName, attTypeCode))
    output.write('\t *\n')
    output.write('\t * @return integer value indicating success/failure of the\n')
    output.write('\t * function.  @if clike The value is drawn from the\n')
    output.write('\t * enumeration #OperationReturnValues_t. @endif The possible values\n')
    output.write('\t * returned by this function are:\n')
    output.write('\t * @li LIBSEDML_OPERATION_SUCCESS\n')
    output.write('\t * @li LIBSEDML_INVALID_ATTRIBUTE_VALUE\n')
    output.write('\t */\n')
    output.write('\tvirtual int set{0}('.format(capAttName))
    output.write('{0} {1});\n\n\n'.format(attTypeCode, attName))
Exemplo n.º 23
0
def writeUnsetCode(attrib, output, element):
    att = generalFunctions.parseAttribute(attrib)
    attName = att[0]
    capAttName = att[1]
    attType = att[2]
    attTypeCode = att[3]
    num = att[4]
    if attType == 'lo_element':
        return
    output.write('/*\n')
    output.write(
        ' * Unsets {0} and returns value indicating success.\n'.format(
            attName))
    output.write(' */\n')
    output.write('int\n')
    output.write('{0}::unset{1}()\n'.format(element, capAttName))
    output.write('{\n')
    if attType == 'string':
        output.write('\tm{0}.erase();\n\n'.format(capAttName))
        output.write('\tif (m{0}.empty() == true)\n'.format(capAttName))
        output.write('\t{\n\t\treturn LIBSEDML_OPERATION_SUCCESS;\n\t}\n')
        output.write('\telse\n\t{\n')
        output.write('\t\treturn LIBSEDML_OPERATION_FAILED;\n\t}\n')
    elif num == True:
        if attType == 'double':
            output.write(
                '\tm{0} = numeric_limits<double>::quiet_NaN();\n'.format(
                    capAttName))
        else:
            output.write('\tm{0} = SEDML_INT_MAX;\n'.format(capAttName))
        output.write('\tmIsSet{0} = false;\n\n'.format(capAttName))
        output.write('\tif (isSet{0}() == false)\n'.format(capAttName))
        output.write('\t{\n\t\treturn LIBSEDML_OPERATION_SUCCESS;\n\t}\n')
        output.write('\telse\n\t{\n')
        output.write('\t\treturn LIBSEDML_OPERATION_FAILED;\n\t}\n')
    elif attType == 'boolean':
        output.write('\tm{0} = false;\n'.format(capAttName))
        output.write('\tmIsSet{0} = false;\n'.format(capAttName))
        output.write('\treturn LIBSEDML_OPERATION_SUCCESS;\n')
    elif attType == 'element':
        output.write('\tdelete m{0};\n'.format(capAttName))
        output.write('\tm{0} = NULL;\n'.format(capAttName))
        output.write('\treturn LIBSEDML_OPERATION_SUCCESS;\n')
    output.write('}\n\n\n')
Exemplo n.º 24
0
def writeUnsetCode(attrib, output, element):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  if attType == 'lo_element':
    return
  output.write('/*\n')
  output.write(' * Unsets {0} and returns value indicating success.\n'.format(attName))
  output.write(' */\n')
  output.write('int\n')
  output.write('{0}::unset{1}()\n'.format(element, capAttName))
  output.write('{\n')
  if attType == 'string':
    output.write('\tm{0}.erase();\n\n'.format(capAttName))
    output.write('\tif (m{0}.empty() == true)\n'.format(capAttName))
    output.write('\t{\n\t\treturn LIBSEDML_OPERATION_SUCCESS;\n\t}\n')
    output.write('\telse\n\t{\n')
    output.write('\t\treturn LIBSEDML_OPERATION_FAILED;\n\t}\n')
  elif num == True:
    if attType == 'double':
      output.write('\tm{0} = numeric_limits<double>::quiet_NaN();\n'.format(capAttName))
    else:
      output.write('\tm{0} = SEDML_INT_MAX;\n'.format(capAttName))
    output.write('\tmIsSet{0} = false;\n\n'.format(capAttName))
    output.write('\tif (isSet{0}() == false)\n'.format(capAttName))
    output.write('\t{\n\t\treturn LIBSEDML_OPERATION_SUCCESS;\n\t}\n')
    output.write('\telse\n\t{\n')
    output.write('\t\treturn LIBSEDML_OPERATION_FAILED;\n\t}\n')
  elif attType == 'boolean':
    output.write('\tm{0} = false;\n'.format(capAttName))
    output.write('\tmIsSet{0} = false;\n'.format(capAttName))
    output.write('\treturn LIBSEDML_OPERATION_SUCCESS;\n')
  elif attType == 'element':
    output.write('\tdelete m{0};\n'.format(capAttName))
    output.write('\tm{0} = NULL;\n'.format(capAttName))
    output.write('\treturn LIBSEDML_OPERATION_SUCCESS;\n')
  output.write('}\n\n\n')
Exemplo n.º 25
0
def writeIsSetCode(attrib, output, element):
    att = generalFunctions.parseAttribute(attrib)
    attName = att[0]
    capAttName = att[1]
    attType = att[2]
    attTypeCode = att[3]
    num = att[4]
    if attType == 'lo_element':
        return
    output.write('/*\n')
    output.write(' * Returns true/false if {0} is set.\n'.format(attName))
    output.write(' */\n')
    output.write('bool\n')
    output.write('{0}::isSet{1}() const\n'.format(element, capAttName))
    output.write('{\n')
    if attType == 'string':
        output.write('\treturn (m{0}.empty() == false);\n'.format(capAttName))
    elif attType == 'element':
        output.write('\treturn (m{0} != NULL);\n'.format(capAttName))
    elif num == True:
        output.write('\treturn mIsSet{0};\n'.format(capAttName))
    elif attType == 'boolean':
        output.write('\treturn mIsSet{0};\n'.format(capAttName))
    output.write('}\n\n\n')
Exemplo n.º 26
0
def writeAtt(attrib, output):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  if attType == 'string':
    output.write('  std::string   m{0};\n'.format(capAttName))
  elif attType == 'element':
    if attTypeCode == 'const ASTNode*' or attName== 'Math':
      output.write('  ASTNode*      m{0};\n'.format(capAttName))
    else:
      output.write('  {0}*      m{1};\n'.format(attrib['element'], capAttName))
      return
  elif attType == 'lo_element' or attType == 'inline_lo_element':
    if attrib.has_key('element'):
      output.write('  {0}   m{1};\n'.format(generalFunctions.getListOfClassName(attrib,attrib['element']), strFunctions.capp(attrib['name'])))
    else:
      output.write('  {0}   m{1};\n'.format(generalFunctions.getListOfClassName(attrib,capAttName), strFunctions.capp(attName)))
  elif attTypeCode == 'XMLNode*':
    output.write('  {0}   m{1};\n'.format('XMLNode*', capAttName))
  elif num == True:
    while len(attTypeCode) < 13:
      attTypeCode = attTypeCode + ' '
    output.write('  {1} m{0};\n'.format(capAttName, attTypeCode))
    output.write('  bool          mIsSet{0};\n'.format(capAttName))
  elif attType == 'boolean':
    output.write('  bool          m{0};\n'.format(capAttName))
    output.write('  bool          mIsSet{0};\n'.format(capAttName))
  elif attrib['type'] == 'enum':
    output.write('  {0}_t   m{1};\n'.format(attrib['element'], capAttName))
  elif attrib['type'] == 'array':
    output.write('  {0}*         m{1};\n'.format(attrib['element'], capAttName))
  else:
    output.write('  FIX ME   {0};\n'.format(attName))
Exemplo n.º 27
0
def writeIsSetCode(attrib, output, element):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  if attType == 'lo_element':
    return
  output.write('/*\n')
  output.write(' * Returns true/false if {0} is set.\n'.format(attName))
  output.write(' */\n')
  output.write('bool\n')
  output.write('{0}::isSet{1}() const\n'.format(element, capAttName))
  output.write('{\n')
  if attType == 'string':
    output.write('\treturn (m{0}.empty() == false);\n'.format(capAttName))
  elif attType == 'element':
    output.write('\treturn (m{0} != NULL);\n'.format(capAttName))
  elif num == True:
    output.write('\treturn mIsSet{0};\n'.format(capAttName))
  elif attType == 'boolean':
    output.write('\treturn mIsSet{0};\n'.format(capAttName))
  output.write('}\n\n\n')
Exemplo n.º 28
0
def writeAtt(attrib, output):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  if attType == 'string':
    output.write('  std::string   m{0};\n'.format(capAttName))
  elif attType == 'element':
    if attTypeCode == 'const ASTNode*' or attName== 'Math':
      output.write('  ASTNode*      m{0};\n'.format(capAttName))
    else:
      output.write('  {0}*      m{1};\n'.format(attrib['element'], capAttName))
      return
  elif attType == 'lo_element' or attType == 'inline_lo_element':
    if attrib.has_key('element'):
      output.write('  {0}   m{1};\n'.format(generalFunctions.getListOfClassName(attrib,attrib['element']), strFunctions.capp(attrib['name'])))
    else:
      output.write('  {0}   m{1};\n'.format(generalFunctions.getListOfClassName(attrib,capAttName), strFunctions.capp(attName)))
  elif attTypeCode == 'XMLNode*':
    output.write('  {0}   m{1};\n'.format('XMLNode*', capAttName))
  elif num == True:
    while len(attTypeCode) < 13:
      attTypeCode = attTypeCode + ' '
    output.write('  {1} m{0};\n'.format(capAttName, attTypeCode))
    output.write('  bool          mIsSet{0};\n'.format(capAttName))
  elif attType == 'boolean':
    output.write('  bool          m{0};\n'.format(capAttName))
    output.write('  bool          mIsSet{0};\n'.format(capAttName))
  elif attrib['type'] == 'enum':
    output.write('  {0}_t   m{1};\n'.format(attrib['element'], capAttName))
  elif attrib['type'] == 'array':
    output.write('  {0}*         m{1};\n'.format(attrib['element'], capAttName))
  else:
    output.write('  FIX ME   {0};\n'.format(attName))
Exemplo n.º 29
0
def writeGetFunction(attrib, output, element):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  if attrib['type'] == 'lo_element' or attrib['type'] == 'inline_lo_element':
    return
  elif attrib['type'] == 'array':
    output.write('  /**\n');
    output.write('   * The "{0}" attribute of this {1} is returned in an {2} array (pointer)\n'.format(attName, element, attTypeCode));
    output.write('   * that is passed as argument to the method (this is needed while using SWIG to\n');
    output.write('   * convert int[] from C++ to Java). The method itself has a return type void.\n');
    output.write('   *\n');
    output.write('   * NOTE: you have to pre-allocate the array with the correct length!');
    output.write('   *\n');
    output.write('   * @return void.\n');
    output.write('   */\n');
    output.write('  void get{0}({1} outArray) const;\n\n\n'.format(capAttName, attTypeCode));
  elif attrib['type'] == 'element':
    if attrib['name'] == 'Math' or attrib['name'] == 'math':
      output.write('  /**\n')
      output.write('   * Returns the \"{0}\"'.format(attName))
      output.write(' element of this {0}.\n'.format(element))
      output.write('   *\n')
      output.write('   * @return the \"{0}\"'.format(attName))
      output.write(' element of this {0}.\n'.format(element))
      output.write('   */\n')
      output.write('  virtual const ASTNode*')
      output.write(' get{0}() const;\n\n\n'.format(capAttName))
    else:
      output.write('  /**\n')
      output.write('   * Returns the \"{0}\"'.format(attName))
      output.write(' element of this {0}.\n'.format(element))
      output.write('   *\n')
      output.write('   * @return the \"{0}\"'.format(attName))
      output.write(' element of this {0}.\n'.format(element))
      output.write('   */\n')
      output.write('  virtual const {0}*'.format(attrib['element']))
      output.write(' get{0}() const;\n\n\n'.format(capAttName))
      
      output.write('  /**\n')
      output.write('   * Returns the \"{0}\"'.format(attName))
      output.write(' element of this {0}.\n'.format(element))
      output.write('   *\n')
      output.write('   * @return the \"{0}\"'.format(attName))
      output.write(' element of this {0}.\n'.format(element))
      output.write('   */\n')
      output.write('  virtual {0}*'.format(attrib['element']))
      output.write(' get{0}();\n\n\n'.format(capAttName))

      if attrib['abstract'] == False:
        output.write('  /**\n')
        output.write('   * Creates a new \"{0}\"'.format(attrib['element']))
        output.write(' and sets it for this {0}.\n'.format(element))
        output.write('   *\n')
        output.write('   * @return the created \"{0}\"'.format(attrib['element']))
        output.write(' element of this {0}.\n'.format(element))
        output.write('   */\n')
        output.write('  virtual {0}*'.format(attrib['element']))
        output.write(' create{0}();\n\n\n'.format(capAttName))
      else:
        for concrete in generalFunctions.getConcretes(attrib['root'], attrib['concrete']):
          output.write('  /**\n')
          output.write('   * Creates a new \"{0}\"'.format(attName))
          output.write(' and sets it for this {0}.\n'.format(element))
          output.write('   */\n')
          output.write('  virtual {0}*'.format(concrete['element']))
          output.write(' create{0}();\n\n\n'.format(strFunctions.cap(concrete['name'])))
  else:
    output.write('  /**\n')
    output.write('   * Returns the value of the \"{0}\"'.format(attName))
    output.write(' attribute of this {0}.\n'.format(element))
    output.write('   *\n')
    output.write('   * @return the value of the \"{0}\"'.format(attName))
    output.write(' attribute of this {0} as a {1}.\n'.format(element, attType))
    output.write('   */\n')
    output.write('  virtual {0}'.format(attTypeCode))
    output.write(' get{0}() const;\n\n\n'.format(capAttName))
def writeGetCode(attrib, output, element):
    att = generalFunctions.parseAttribute(attrib)
    attName = att[0]
    capAttName = att[1]
    attType = att[2]
    attTypeCode = att[3]
    if attType == 'lo_element':
        return
    if attType == 'std::vector<double>':
        output.write('/*\n')
        output.write(' * Returns the value of the \"{0}\"'.format(attName))
        output.write(' attribute of this {0}.\n'.format(element))
        output.write(' */\n')
        output.write('const {0}&\n'.format(attTypeCode))
        output.write('{0}::get{1}() const\n'.format(
            element, strFunctions.capp(capAttName)))
        output.write('{\n')
        output.write('  return m{0};\n'.format(strFunctions.capp(capAttName)))
        output.write('}\n\n\n')
        output.write('/*\n')
        output.write(' * Returns the value of the \"{0}\"'.format(attName))
        output.write(' attribute of this {0}.\n'.format(element))
        output.write(' */\n')
        output.write('{0}&\n'.format(attTypeCode))
        output.write('{0}::get{1}()\n'.format(element,
                                              strFunctions.capp(capAttName)))
        output.write('{\n')
        output.write('  return m{0};\n'.format(strFunctions.capp(capAttName)))
        output.write('}\n\n\n')
    else:
        output.write('/*\n')
        output.write(' * Returns the value of the \"{0}\"'.format(attName))
        output.write(' attribute of this {0}.\n'.format(element))
        output.write(' */\n')
        output.write('const {0}\n'.format(attTypeCode))
        output.write('{0}::get{1}() const\n'.format(element, capAttName))
        output.write('{\n')
        output.write('  return m{0};\n'.format(capAttName))
        output.write('}\n\n\n')
        if attrib['type'] == 'element' and attName != 'math':
            output.write('/*\n')
            output.write(' * Returns the value of the \"{0}\"'.format(attName))
            output.write(' attribute of this {0}.\n'.format(element))
            output.write(' */\n')
            output.write('{0}\n'.format(attTypeCode))
            output.write('{0}::get{1}()\n'.format(element, capAttName))
            output.write('{\n')
            output.write('  return m{0};\n'.format(capAttName))
            output.write('}\n\n\n')
    if attType == 'element' and attName != 'math':
        output.write('/*\n')
        output.write(' * Creates a new \"{0}\"'.format(attName))
        output.write(' element of this {0} and returns it.\n'.format(element))
        output.write(' */\n')
        output.write('{0}\n'.format(attTypeCode))
        output.write('{0}::create{1}()\n'.format(element, capAttName))
        output.write('{\n')
        output.write('  m{0} = new {1}();\n'.format(capAttName,
                                                    attrib['element']))
        output.write('  return m{0};\n'.format(capAttName))
        output.write('}\n\n\n')
    if attType == 'DimensionDescription*':
        output.write('/*\n')
        output.write(' * Creates a new \"{0}\"'.format(attName))
        output.write(' element of this {0} and returns it.\n'.format(element))
        output.write(' */\n')
        output.write('{0}\n'.format(attTypeCode))
        output.write('{0}::create{1}()\n'.format(element, capAttName))
        output.write('{\n')
        output.write(
            '  if (m{0} != NULL)\n    delete m{0};\n\n'.format(capAttName))
        output.write('  m{0} = new {1}();\n'.format(capAttName,
                                                    'DimensionDescription'))
        output.write('  return m{0};\n'.format(capAttName))
        output.write('}\n\n\n')
def writeSetCode(attrib, output, element):
    att = generalFunctions.parseAttribute(attrib)
    attName = att[0]
    capAttName = att[1]
    attType = att[2]
    if attType == 'string':
        attTypeCode = 'const std::string&'
    else:
        attTypeCode = att[3]
    num = att[4]
    if attType == 'lo_element':
        return
    elif attrib['type'] == 'std::vector<double>':
        output.write('/**\n')
        output.write(' * Sets the value of the \"{0}\"'.format(attName))
        output.write(' attribute of this {0}.\n'.format(element))
        output.write(' *\n')
        output.write(
            ' * @param {0}; {1} value of the "{0}" attribute to be set\n'.
            format(attName, attTypeCode))
        output.write(' *\n')
        output.write(
            ' * @return integer value indicating success/failure of the\n')
        output.write(' * function.  @if clike The value is drawn from the\n')
        output.write(
            ' * enumeration #OperationReturnValues_t. @endif The possible values\n'
        )
        output.write(' * returned by this function are:\n')
        output.write(' * @li LIBSEDML_OPERATION_SUCCESS\n')
        output.write(' * @li LIBSEDML_INVALID_ATTRIBUTE_VALUE\n')
        output.write(' */\n')
        output.write('int\n{0}::set{1}('.format(element,
                                                strFunctions.capp(capAttName)))
        output.write('const {0}& {1})\n'.format(attTypeCode, attName))
        output.write('{\n')
        output.write('  m{0} = {1};\n'.format(strFunctions.capp(capAttName),
                                              attName))
        output.write('  return LIBSEDML_OPERATION_SUCCESS;\n')
        output.write('}\n\n\n')
        output.write('/**\n')
        output.write(' * Adds another value to the \"{0}\"'.format(attName))
        output.write(' attribute of this {0}.\n'.format(element))
        output.write(' *\n')
        output.write(
            ' * @param {0}; {1} value of the "{0}" attribute to be added\n'.
            format(attName, 'double'))
        output.write(' *\n')
        output.write(
            ' * @return integer value indicating success/failure of the\n')
        output.write(' * function.  @if clike The value is drawn from the\n')
        output.write(
            ' * enumeration #OperationReturnValues_t. @endif The possible values\n'
        )
        output.write(' * returned by this function are:\n')
        output.write(' * @li LIBSEDML_OPERATION_SUCCESS\n')
        output.write(' * @li LIBSEDML_INVALID_ATTRIBUTE_VALUE\n')
        output.write(' */\n')
        output.write('int\n{0}::add{1}('.format(element, capAttName))
        output.write('{0} {1})\n'.format('double', attName))
        output.write('{\n')
        output.write('  m{0}.push_back({1});\n'.format(
            strFunctions.capp(capAttName), attName))
        output.write('  return LIBSEDML_OPERATION_SUCCESS;\n')
        output.write('}\n\n\n')
    else:
        output.write('/*\n')
        output.write(
            ' * Sets {0} and returns value indicating success.\n'.format(
                attName))
        output.write(' */\n')
        output.write('int\n')
        output.write('{0}::set{1}({2} {3})\n'.format(element, capAttName,
                                                     attTypeCode, attName))
        output.write('{\n')
        if attType == 'string':
            if attName == 'id':
                output.write(
                    '  return SyntaxChecker::checkAndSetSId({0}, m{1});\n'.
                    format(attName, capAttName))
            else:
                if attrib['type'] == 'SIdRef':
                    output.write(
                        '  if (!(SyntaxChecker::isValidInternalSId({0})))\n'.
                        format(attName))
                    output.write(
                        '  {\n    return LIBSEDML_INVALID_ATTRIBUTE_VALUE;\n  }\n'
                    )
                    output.write('  else\n')
                output.write('  {\n')
                output.write('    m{0} = {1};\n'.format(capAttName, attName))
                output.write('    return LIBSEDML_OPERATION_SUCCESS;\n  }\n')
        elif num == True:
            output.write('  m{0} = {1};\n'.format(capAttName, attName))
            output.write('  mIsSet{0} = true;\n'.format(capAttName))
            output.write('  return LIBSEDML_OPERATION_SUCCESS;\n')
        elif attType == 'boolean':
            output.write('  m{0} = {1};\n'.format(capAttName, attName))
            output.write('  mIsSet{0} = true;\n'.format(capAttName))
            output.write('  return LIBSEDML_OPERATION_SUCCESS;\n')
        elif attType == 'XMLNode*' or attType == 'DimensionDescription*':
            output.write('  if (m{0} == {1})\n'.format(capAttName, attName))
            output.write('  {\n    return LIBSEDML_OPERATION_SUCCESS;\n  }\n')
            output.write('  else if ({0} == NULL)\n'.format(attName))
            output.write('  {\n')
            output.write('    delete m{0};\n'.format(capAttName))
            output.write('    m{0} = NULL;\n'.format(capAttName))
            output.write('    return LIBSEDML_OPERATION_SUCCESS;\n  }\n')
            output.write('  delete m{0};\n'.format(capAttName))
            output.write('  m{0} = ({1} != NULL) ?\n'.format(
                capAttName, attName))
            output.write('    {0}->clone() : NULL;\n'.format(attName))
            output.write('  return LIBSEDML_OPERATION_SUCCESS;\n')
        elif attType == 'element':
            output.write('  if (m{0} == {1})\n'.format(capAttName, attName))
            output.write('  {\n    return LIBSEDML_OPERATION_SUCCESS;\n  }\n')
            output.write('  else if ({0} == NULL)\n'.format(attName))
            output.write('  {\n')
            output.write('    delete m{0};\n'.format(capAttName))
            output.write('    m{0} = NULL;\n'.format(capAttName))
            output.write('    return LIBSEDML_OPERATION_SUCCESS;\n  }\n')
            if attTypeCode == 'ASTNode*':
                output.write(
                    '  else if (!({0}->isWellFormedASTNode()))\n'.format(
                        attName))
                output.write('  {\n    return LIBSEDML_INVALID_OBJECT;\n  }\n')
            output.write('  else\n  {\n')
            output.write('    delete m{0};\n'.format(capAttName))
            output.write('    m{0} = ({1} != NULL) ?\n'.format(
                capAttName, attName))
            if attTypeCode == 'ASTNode*':
                output.write('      {0}->deepCopy() : NULL;\n'.format(attName))
            else:
                output.write(
                    '      static_cast<{0}*>({1}->clone()) : NULL;\n'.format(
                        attrib['element'], attName))
            output.write('    if (m{0} != NULL)\n'.format(capAttName))
            output.write('    {\n')
            #if attTypeCode == 'ASTNode*':
            #  output.write('      m{0}->setParentSEDMLObject(this);\n'.format(capAttName, attName))
            #else:
            #  output.write('      m{0}->connectToParent(this);\n'.format(capAttName, attName))
            if attTypeCode != 'ASTNode*':
                output.write('      m{0}->connectToParent(this);\n'.format(
                    capAttName, attName))
            output.write('    }\n')
            output.write('    return LIBSEDML_OPERATION_SUCCESS;\n  }\n')
        output.write('}\n\n\n')
def writeUnsetCode(attrib, output, element):
    att = generalFunctions.parseAttribute(attrib)
    attName = att[0]
    capAttName = att[1]
    attType = att[2]
    attTypeCode = att[3]
    num = att[4]
    if attType == 'lo_element':
        return
    elif attrib['type'] == 'std::vector<double>':
        output.write('/**\n')
        output.write(' * Clears the \"{0}\"'.format(attName))
        output.write(' element of this {0}.\n'.format(element))
        output.write(' *\n')
        output.write(
            ' * @return integer value indicating success/failure of the\n')
        output.write(' * function.  @if clike The value is drawn from the\n')
        output.write(
            ' * enumeration #OperationReturnValues_t. @endif The possible values\n'
        )
        output.write(' * returned by this function are:\n')
        output.write(' * @li LIBSEDML_OPERATION_SUCCESS\n')
        output.write(' * @li LIBSEDML_OPERATION_FAILED\n')
        output.write(' */\n')
        output.write('int\n{0}::clear{1}()\n'.format(
            element, strFunctions.capp(capAttName)))
        output.write('{\n')
        output.write('  m{0}.clear();\n'.format(strFunctions.capp(capAttName)))
        output.write('  return LIBSEDML_OPERATION_SUCCESS;\n')
        output.write('}\n\n\n')
    else:
        output.write('/*\n')
        output.write(
            ' * Unsets {0} and returns value indicating success.\n'.format(
                attName))
        output.write(' */\n')
        output.write('int\n')
        output.write('{0}::unset{1}()\n'.format(element, capAttName))
        output.write('{\n')
        if attType == 'string':
            output.write('  m{0}.erase();\n\n'.format(capAttName))
            output.write('  if (m{0}.empty() == true)\n'.format(capAttName))
            output.write('  {\n    return LIBSEDML_OPERATION_SUCCESS;\n  }\n')
            output.write('  else\n  {\n')
            output.write('    return LIBSEDML_OPERATION_FAILED;\n  }\n')
        elif num == True:
            if attType == 'double':
                output.write(
                    '  m{0} = numeric_limits<double>::quiet_NaN();\n'.format(
                        capAttName))
            else:
                output.write('  m{0} = SEDML_INT_MAX;\n'.format(capAttName))
            output.write('  mIsSet{0} = false;\n\n'.format(capAttName))
            output.write('  if (isSet{0}() == false)\n'.format(capAttName))
            output.write('  {\n    return LIBSEDML_OPERATION_SUCCESS;\n  }\n')
            output.write('  else\n  {\n')
            output.write('    return LIBSEDML_OPERATION_FAILED;\n  }\n')
        elif attType == 'boolean':
            output.write('  m{0} = false;\n'.format(capAttName))
            output.write('  mIsSet{0} = false;\n'.format(capAttName))
            output.write('  return LIBSEDML_OPERATION_SUCCESS;\n')
        elif attType == 'element' or attType == 'XMLNode*' or attType == 'DimensionDescription*':
            output.write('  delete m{0};\n'.format(capAttName))
            output.write('  m{0} = NULL;\n'.format(capAttName))
            output.write('  return LIBSEDML_OPERATION_SUCCESS;\n')
        output.write('}\n\n\n')
Exemplo n.º 33
0
def writeListOfSubFunctions(attrib, output, element):
    loname = generalFunctions.writeListOf(strFunctions.cap(attrib['name']))
    att = generalFunctions.parseAttribute(attrib)
    attName = att[0]
    capAttName = att[1]
    attType = att[2]
    attTypeCode = att[3]
    num = att[4]
    output.write('/*\n')
    output.write(' * Returns the  \"{0}\"'.format(loname))
    output.write(' in this {0} object.\n'.format(element))
    output.write(' */\n')
    output.write('const {0}*\n'.format(loname))
    output.write('{0}::getListOf{1}s() const\n'.format(
        element, strFunctions.cap(attrib['name'])))
    output.write('{\n')
    output.write('\treturn &m{0};\n'.format(capAttName))
    output.write('}\n\n\n')
    writeListOfCode.writeRemoveFunctions(output,
                                         strFunctions.cap(attrib['name']),
                                         attrib['element'], True, element,
                                         capAttName)
    writeListOfCode.writeGetFunctions(output, strFunctions.cap(attrib['name']),
                                      attrib['element'], True, element,
                                      capAttName)
    output.write('/**\n')
    output.write(' * Adds a copy the given \"{0}\" to this {1}.\n'.format(
        attrib['element'], element))
    output.write(' *\n')
    output.write(' * @param {0}; the {1} object to add\n'.format(
        strFunctions.objAbbrev(attrib['element']), attrib['element']))
    output.write(' *\n')
    output.write(
        ' * @return integer value indicating success/failure of the\n')
    output.write(' * function.  @if clike The value is drawn from the\n')
    output.write(
        ' * enumeration #OperationReturnValues_t. @endif The possible values\n'
    )
    output.write(' * returned by this function are:\n')
    output.write(' * @li LIBSEDML_OPERATION_SUCCESS\n')
    output.write(' * @li LIBSEDML_INVALID_ATTRIBUTE_VALUE\n')
    output.write(' */\n')
    output.write('int\n')
    output.write('{0}::add{1}(const {2}* {3})\n'.format(
        element, strFunctions.cap(attrib['name']), attrib['element'],
        strFunctions.objAbbrev(attrib['element'])))
    output.write('{\n')
    output.write(
        '\tif({0} == NULL) return LIBSEDML_INVALID_ATTRIBUTE_VALUE;\n'.format(
            strFunctions.objAbbrev(attrib['element'])))
    output.write('\tm{0}.append({1});\n'.format(
        strFunctions.cap(attrib['name']),
        strFunctions.objAbbrev(attrib['element'])))
    output.write('\treturn LIBSEDML_OPERATION_SUCCESS;\n')
    output.write('}\n\n\n')
    output.write('/**\n')
    output.write(' * Get the number of {0} objects in this {1}.\n'.format(
        attrib['element'], element))
    output.write(' *\n')
    output.write(' * @return the number of {0} objects in this {1}\n'.format(
        attrib['element'], element))
    output.write(' */\n')
    output.write('unsigned int \n')
    output.write('{0}::getNum{1}s() const\n'.format(
        element, strFunctions.cap(attrib['name'])))
    output.write('{\n')
    output.write('\treturn m{0}.size();\n'.format(
        strFunctions.cap(attrib['name'])))
    output.write('}\n\n')
    if attrib.has_key('abstract') == False or (attrib.has_key('abstract') and
                                               attrib['abstract'] == False):
        output.write('/**\n')
        output.write(
            ' * Creates a new {0} object, adds it to this {1}s\n'.format(
                attrib['element'], element))
        output.write(' * {0} and returns the {1} object created. \n'.format(
            element, attrib['element']))
        output.write(' *\n')
        output.write(' * @return a new {0} object instance\n'.format(
            attrib['element']))
        output.write(' *\n')
        output.write(' * @see add{0}(const {0}* {1})\n'.format(
            attrib['element'], strFunctions.objAbbrev(attrib['element'])))
        output.write(' */\n')
        output.write('{0}* \n'.format(attrib['element']))
        output.write('{0}::create{1}()\n'.format(
            element, strFunctions.cap(attrib['name'])))
        output.write('{\n')
        output.write('\t{0} *temp = new {0}();\n'.format(attrib['element']))
        output.write('\tif (temp != NULL) m{0}.appendAndOwn(temp);\n'.format(
            strFunctions.cap(attrib['name'])))
        output.write('\treturn temp;\n')
        output.write('}\n\n')
    elif attrib.has_key('concrete'):
        for elem in attrib['concrete']:
            output.write('/**\n')
            output.write(
                ' * Creates a new {0} object, adds it to this {1}s\n'.format(
                    elem['element'], element))
            output.write(
                ' * {0} and returns the {1} object created. \n'.format(
                    element, elem['element']))
            output.write(' *\n')
            output.write(' * @return a new {0} object instance\n'.format(
                elem['element']))
            output.write(' *\n')
            output.write(' * @see add{0}(const {1}* {2})\n'.format(
                strFunctions.cap(elem['name']), attrib['element'],
                strFunctions.objAbbrev(attrib['element'])))
            output.write(' */\n')
            output.write('{0}* \n'.format(elem['element']))
            output.write('{0}::create{1}()\n'.format(
                element, strFunctions.cap(elem['name'])))
            output.write('{\n')
            output.write('\t{0} *temp = new {0}();\n'.format(elem['element']))
            output.write(
                '\tif (temp != NULL) m{0}.appendAndOwn(temp);\n'.format(
                    strFunctions.cap(attrib['name'])))
            output.write('\treturn temp;\n')
            output.write('}\n\n')
Exemplo n.º 34
0
def writeGetCode(attrib, output, element):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  if attType == 'lo_element' or attType == 'inline_lo_element':
    return

  if attrib['type'] == 'array':
    output.write('/*\n');
    output.write(' * The "{0}" attribute of this {1} is returned in an {2} array (pointer)\n'.format(attName, element, attTypeCode));
    output.write(' * that is passed as argument to the method (this is needed while using SWIG to\n');
    output.write(' * convert int[] from C++ to Java). The method itself has a return type void.\n');
    output.write(' *\n');
    output.write(' * NOTE: you have to pre-allocate the array with the correct length!'); 
    output.write(' *\n');
    output.write(' * @return void.\n');
    output.write(' */\n');
    output.write('void\n{0}::get{1}({2} outArray) const\n'.format(element,capAttName, attTypeCode));
    output.write('{\n');
    output.write('   if (outArray == NULL || m{0} == NULL) return;\n\n'.format(capAttName))
    output.write('   memcpy(outArray , m{0}, sizeof({1})*m{0}Length);\n'.format(capAttName, attrib['element']));
    output.write('}\n\n\n');
    return

  output.write('/*\n')
  output.write(' * Returns the value of the \"{0}\"'.format(attName))
  output.write(' attribute of this {0}.\n'.format(element))
  output.write(' */\n')
  if attType == 'element' and attTypeCode != 'const ASTNode*':
    output.write('const {0}\n'.format(attTypeCode))
  else:
    output.write('{0}\n'.format(attTypeCode))
  output.write('{0}::get{1}() const\n'.format(element, capAttName))
  output.write('{\n')
  output.write('  return m{0};\n'.format(capAttName))
  output.write('}\n\n\n')

  if attType == 'element' and attName != 'math':
    # return non-const elements as well
    output.write('/*\n')
    output.write(' * Returns the value of the \"{0}\"'.format(attName))
    output.write(' attribute of this {0}.\n'.format(element))
    output.write(' */\n')
    output.write('{0}\n'.format(attTypeCode))
    output.write('{0}::get{1}()\n'.format(element, capAttName))
    output.write('{\n')
    output.write('  return m{0};\n'.format(capAttName))
    output.write('}\n\n\n')

    pkgName = attrib['root']['name']

    if attrib['abstract'] == False:
      output.write('/*\n')
      output.write(' * Creates a new \"{0}\"'.format(attName))
      output.write(' element of this {0} and returns it.\n'.format(element))
      output.write(' */\n')
      output.write('{0}\n'.format(attTypeCode))
      output.write('{0}::create{1}()\n'.format(element, capAttName))
      output.write('{\n')
      if attName == 'math' or attName == 'Math' or attType == 'XMLNode*':
        output.write('  if (m{0} != NULL) delete m{0};\n'.format(capAttName))
        output.write('  m{0} = new {1}();\n'.format(capAttName, attrib['element']))
        output.write('  return m{0};\n'.format(capAttName))
      else:
        output.write('  if (m{0} != NULL) delete m{0};\n'.format(capAttName))
        output.write('  {0}_CREATE_NS({1}ns, getSBMLNamespaces());\n'.format(pkgName.upper(), pkgName.lower()))
        output.write('  m{0} = new {1}({2}ns);\n'.format(capAttName, attrib['element'], pkgName.lower()))
        if generalFunctions.overridesElementName(attrib):
          output.write('  m{0}->setElementName("{1}");\n'.format(capAttName, attrib['name']));
        output.write('  delete {0}ns;\n'.format(pkgName.lower()))
        output.write('  connectToChild();\n'.format(pkgName.lower()))          
        output.write('  return m{0};\n'.format(capAttName))
      output.write('}\n\n\n')
    else:
      for concrete in generalFunctions.getConcretes(attrib['root'], attrib['concrete']):
        output.write('/*\n')
        output.write(' * Creates a new \"{0}\"'.format(attName))
        output.write(' element of this {0} and returns it.\n'.format(element))
        output.write(' */\n')
        output.write('{0}*\n'.format(concrete['element']))
        output.write('{0}::create{1}()\n'.format(element, strFunctions.cap(concrete['name'])))
        output.write('{\n')
        output.write('  if (m{0} != NULL) delete m{0};\n'.format(capAttName))
        output.write('  {0}_CREATE_NS({1}ns, getSBMLNamespaces());\n'.format(pkgName.upper(), pkgName.lower()))
        output.write('  m{0} = new {1}({2}ns);\n'.format(capAttName, concrete['element'], pkgName.lower()))
        if generalFunctions.overridesElementName(concrete):
          output.write('  m{0}->setElementName("{1}");\n'.format(capAttName, attrib['name']));
        output.write('  delete {0}ns;\n'.format(pkgName.lower()))
        output.write('  connectToChild();\n'.format(pkgName.lower()))          
        output.write('  return static_cast<{0}*>(m{1});\n'.format(concrete['element'], capAttName))
        output.write('}\n\n\n')
Exemplo n.º 35
0
def writeGetFunction(attrib, output, element):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  if attrib['type'] == 'lo_element' or attrib['type'] == 'inline_lo_element':
    return
  elif attrib['type'] == 'array':
    output.write('  /**\n');
    output.write('   * The "{0}" attribute of this {1} is returned in an {2} array (pointer)\n'.format(attName, element, attTypeCode));
    output.write('   * that is passed as argument to the method (this is needed while using SWIG to\n');
    output.write('   * convert int[] from C++ to Java). The method itself has a return type void.\n');
    output.write('   *\n');
    output.write('   * NOTE: you have to pre-allocate the array with the correct length!');
    output.write('   *\n');
    output.write('   * @return void.\n');
    output.write('   */\n');
    output.write('  void get{0}({1} outArray) const;\n\n\n'.format(capAttName, attTypeCode));
  elif attrib['type'] == 'element':
    if attrib['name'] == 'Math' or attrib['name'] == 'math':
      output.write('  /**\n')
      output.write('   * Returns the \"{0}\"'.format(attName))
      output.write(' element of this {0}.\n'.format(element))
      output.write('   *\n')
      output.write('   * @return the \"{0}\"'.format(attName))
      output.write(' element of this {0}.\n'.format(element))
      output.write('   */\n')
      output.write('  virtual const ASTNode*')
      output.write(' get{0}() const;\n\n\n'.format(capAttName))
    else:
      output.write('  /**\n')
      output.write('   * Returns the \"{0}\"'.format(attName))
      output.write(' element of this {0}.\n'.format(element))
      output.write('   *\n')
      output.write('   * @return the \"{0}\"'.format(attName))
      output.write(' element of this {0}.\n'.format(element))
      output.write('   */\n')
      output.write('  virtual const {0}*'.format(attrib['element']))
      output.write(' get{0}() const;\n\n\n'.format(capAttName))
      
      output.write('  /**\n')
      output.write('   * Returns the \"{0}\"'.format(attName))
      output.write(' element of this {0}.\n'.format(element))
      output.write('   *\n')
      output.write('   * @return the \"{0}\"'.format(attName))
      output.write(' element of this {0}.\n'.format(element))
      output.write('   */\n')
      output.write('  virtual {0}*'.format(attrib['element']))
      output.write(' get{0}();\n\n\n'.format(capAttName))

      if attrib['abstract'] == False:
        output.write('  /**\n')
        output.write('   * Creates a new \"{0}\"'.format(attrib['element']))
        output.write(' and sets it for this {0}.\n'.format(element))
        output.write('   *\n')
        output.write('   * @return the created \"{0}\"'.format(attrib['element']))
        output.write(' element of this {0}.\n'.format(element))
        output.write('   */\n')
        output.write('  virtual {0}*'.format(attrib['element']))
        output.write(' create{0}();\n\n\n'.format(capAttName))
      else:
        for concrete in generalFunctions.getConcretes(attrib['root'], attrib['concrete']):
          output.write('  /**\n')
          output.write('   * Creates a new \"{0}\"'.format(attName))
          output.write(' and sets it for this {0}.\n'.format(element))
          output.write('   */\n')
          output.write('  virtual {0}*'.format(concrete['element']))
          output.write(' create{0}();\n\n\n'.format(strFunctions.cap(concrete['name'])))
  else:
    output.write('  /**\n')
    output.write('   * Returns the value of the \"{0}\"'.format(attName))
    output.write(' attribute of this {0}.\n'.format(element))
    output.write('   *\n')
    output.write('   * @return the value of the \"{0}\"'.format(attName))
    output.write(' attribute of this {0} as a {1}.\n'.format(element, attType))
    output.write('   */\n')
    output.write('  virtual {0}'.format(attTypeCode))
    output.write(' get{0}() const;\n\n\n'.format(capAttName))
Exemplo n.º 36
0
def writeSetFunction(attrib, output, element):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  if attType == 'string':
    attTypeCode = 'const std::string&' 
  else:
    attTypeCode = att[3]
  num = att[4]
  if attrib['type'] == 'lo_element' or attrib['type'] == 'inline_lo_element':
    return
  elif attrib['type'] == 'array':
    output.write('  /**\n')
    output.write('   * Sets the \"{0}\"'.format(attName))
    output.write(' element of this {0}.\n'.format(element))
    output.write('   *\n')
    output.write('   * @param inArray; {1} array to be set (it will be copied).\n'.format(attName, attTypeCode))
    output.write('   * @param arrayLength; the length of the array.\n')
    output.write('   *\n')
    output.write('   * @return integer value indicating success/failure of the\n')
    output.write('   * function.  @if clike The value is drawn from the\n')
    output.write('   * enumeration #OperationReturnValues_t. @endif The possible values\n')
    output.write('   * returned by this function are:\n')
    output.write('   * @li LIBSBML_OPERATION_SUCCESS\n')
    output.write('   * @li LIBSBML_INVALID_ATTRIBUTE_VALUE\n')
    output.write('   */\n')
    output.write('  virtual int set{0}('.format(capAttName))
    output.write('{0} inArray, int arrayLength);\n\n\n'.format(attTypeCode))
  elif attrib['type'] == 'element':
    output.write('  /**\n')
    output.write('   * Sets the \"{0}\"'.format(attName))
    output.write(' element of this {0}.\n'.format(element))
    output.write('   *\n')
    output.write('   * @param {0}; {1} to be set.\n'.format(strFunctions.cleanStr(attName), attTypeCode))
    output.write('   *\n')
    output.write('   * @return integer value indicating success/failure of the\n')
    output.write('   * function.  @if clike The value is drawn from the\n')
    output.write('   * enumeration #OperationReturnValues_t. @endif The possible values\n')
    output.write('   * returned by this function are:\n')
    output.write('   * @li LIBSBML_OPERATION_SUCCESS\n')
    output.write('   * @li LIBSBML_INVALID_ATTRIBUTE_VALUE\n')
    output.write('   */\n')
    output.write('  virtual int set{0}('.format(capAttName))
    output.write('{0} {1});\n\n\n'.format(attTypeCode, strFunctions.cleanStr(attName)))
  else:
    output.write('  /**\n')
    output.write('   * Sets the value of the \"{0}\"'.format(attName))
    output.write(' attribute of this {0}.\n'.format(element))
    output.write('   *\n')
    output.write('   * @param {0}; {1} value of the "{2}" attribute to be set\n'.format(strFunctions.cleanStr(attName), attTypeCode, attName))
    output.write('   *\n')
    output.write('   * @return integer value indicating success/failure of the\n')
    output.write('   * function.  @if clike The value is drawn from the\n')
    output.write('   * enumeration #OperationReturnValues_t. @endif The possible values\n')
    output.write('   * returned by this function are:\n')
    output.write('   * @li LIBSBML_OPERATION_SUCCESS\n')
    output.write('   * @li LIBSBML_INVALID_ATTRIBUTE_VALUE\n')
    output.write('   */\n')
    output.write('  virtual int set{0}('.format(capAttName))
    output.write('{0} {1});\n\n\n'.format(attTypeCode, strFunctions.cleanStr(attName)))

    if attrib['type'] == 'enum':
      output.write('  /**\n')
      output.write('   * Sets the value of the \"{0}\"'.format(strFunctions.cleanStr(attName)))
      output.write(' attribute of this {0}.\n'.format(element))
      output.write('   *\n')
      output.write('   * @param {0}; string value of the "{1}" attribute to be set\n'.format(strFunctions.cleanStr(attName), attName))
      output.write('   *\n')
      output.write('   * @return integer value indicating success/failure of the\n')
      output.write('   * function.  @if clike The value is drawn from the\n')
      output.write('   * enumeration #OperationReturnValues_t. @endif The possible values\n')
      output.write('   * returned by this function are:\n')
      output.write('   * @li LIBSBML_OPERATION_SUCCESS\n')
      output.write('   * @li LIBSBML_INVALID_ATTRIBUTE_VALUE\n')
      output.write('   */\n')
      output.write('  virtual int set{0}('.format(capAttName))
      output.write('const std::string& {0});\n\n\n'.format(strFunctions.cleanStr(attName)))
Exemplo n.º 37
0
def writeListOfSubFunctions(attrib, output, element, pkgName):
  lotype = generalFunctions.getListOfClassName(attrib, strFunctions.cap(attrib['element']))
  loname = generalFunctions.writeListOf(strFunctions.cap(attrib['name']))
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  output.write('/*\n')
  output.write(' * Returns the  \"{0}\"'.format(lotype))
  output.write(' in this {0} object.\n'.format(element))
  output.write(' */\n')
  output.write('const {0}*\n'.format(lotype))
  output.write('{0}::get{1}() const\n'.format(element, loname))
  output.write('{\n')
  output.write('  return &m{0};\n'.format(strFunctions.capp(attName)))
  output.write('}\n\n\n')
  output.write('/*\n')
  output.write(' * Returns the  \"{0}\"'.format(lotype))
  output.write(' in this {0} object.\n'.format(element))
  output.write(' */\n')
  output.write('{0}*\n'.format(lotype))
  output.write('{0}::get{1}()\n'.format(element, loname))
  output.write('{\n')
  output.write('  return &m{0};\n'.format(strFunctions.capp(attName)))
  output.write('}\n\n\n')
  writeListOfCode.writeRemoveFunctions(output, strFunctions.cap(attrib['name']), attrib['element'], True, element, capAttName, attrib)
  writeListOfCode.writeGetFunctions(output, strFunctions.cap(attrib['name']), attrib['element'], True, element, capAttName, attrib)
  output.write('/*\n')
  output.write(' * Adds a copy the given \"{0}\" to this {1}.\n'.format(attrib['element'], element))
  output.write(' *\n')
  output.write(' * @param {0}; the {1} object to add\n'.format(strFunctions.objAbbrev(attrib['element']), attrib['element']))
  output.write(' *\n')
  output.write(' * @return integer value indicating success/failure of the\n')
  output.write(' * function.  @if clike The value is drawn from the\n')
  output.write(' * enumeration #OperationReturnValues_t. @endif The possible values\n')
  output.write(' * returned by this function are:\n')
  output.write(' * @li LIBSBML_OPERATION_SUCCESS\n')
  output.write(' * @li LIBSBML_INVALID_ATTRIBUTE_VALUE\n')
  output.write(' */\n')
  output.write('int\n')
  output.write('{0}::add{1}(const {2}* {3})\n'.format(element, strFunctions.cap(attrib['name']), attrib['element'], strFunctions.objAbbrev(attrib['element'])))
  output.write('{\n')
  output.write('  if ({0} == NULL)\n'.format(strFunctions.objAbbrev(attrib['element'])))
  output.write('  {\n')
  output.write('    return LIBSBML_OPERATION_FAILED;\n')
  output.write('  }\n')
  output.write('  else if ({0}->hasRequiredAttributes() == false)\n'.format(strFunctions.objAbbrev(attrib['element'])))
  output.write('  {\n')
  output.write('    return LIBSBML_INVALID_OBJECT;\n')
  output.write('  }\n')
  output.write('  else if (getLevel() != {0}->getLevel())\n'.format(strFunctions.objAbbrev(attrib['element'])))
  output.write('  {\n')
  output.write('    return LIBSBML_LEVEL_MISMATCH;\n')
  output.write('  }\n')
  output.write('  else if (getVersion() != {0}->getVersion())\n'.format(strFunctions.objAbbrev(attrib['element'])))
  output.write('  {\n')
  output.write('    return LIBSBML_VERSION_MISMATCH;\n')
  output.write('  }\n')
  if not element.endswith('Plugin'):
    output.write(
      '  else if (matchesRequiredSBMLNamespacesForAddition(static_cast<const SBase *>({0})) == false)\n'.format(
        strFunctions.objAbbrev(attrib['element'])))
    output.write('  {\n')
    output.write('    return LIBSBML_NAMESPACES_MISMATCH;\n')
    output.write('  }\n')
  output.write('  else\n'.format(strFunctions.objAbbrev(attrib['element'])))
  output.write('  {\n')
  output.write('    m{0}.append({1});\n'.format(strFunctions.capp(attrib['name']),strFunctions.objAbbrev(attrib['element'])))
  output.write('    return LIBSBML_OPERATION_SUCCESS;\n')
  output.write('  }\n')
  output.write('}\n\n\n')
  output.write('/*\n')
  output.write(' * Get the number of {0} objects in this {1}.\n'.format(attrib['element'], element))
  output.write(' *\n')
  output.write(' * @return the number of {0} objects in this {1}\n'.format(attrib['element'], element))
  output.write(' */\n')
  output.write('unsigned int\n')
  output.write('{0}::getNum{1}() const\n'.format(element, strFunctions.capp(attrib['name'])))
  output.write('{\n')
  output.write('  return m{0}.size();\n'.format(strFunctions.capp(attrib['name'])))
  output.write('}\n\n\n')
  if attrib.has_key('abstract') == False or (attrib.has_key('abstract') and attrib['abstract'] == False):
      output.write('/*\n')
      output.write(' * Creates a new {0} object, adds it to this {1}s\n'.format(attrib['element'], element))
      output.write(' * {0} and returns the {1} object created. \n'.format(element, attrib['element']))
      output.write(' *\n')
      output.write(' * @return a new {0} object instance\n'.format(attrib['element']))
      output.write(' *\n')
      output.write(' * @see add{0}(const {0}* {1})\n'.format(attrib['element'], strFunctions.objAbbrev(attrib['element'])))
      output.write(' */\n')
      output.write('{0}*\n'.format(attrib['element']))
      output.write('{0}::create{1}()\n'.format(element, strFunctions.cap(attrib['name'])))
      output.write('{\n')
      output.write('  {0}* {1} = NULL;\n\n'.format(attrib['element'], strFunctions.objAbbrev(attrib['element'])))
      output.write('  try\n')
      output.write('  {\n')
      output.write('    {0}_CREATE_NS({1}ns, getSBMLNamespaces());\n'.format(pkgName.upper(), pkgName.lower()))
      output.write(
        '    {0} = new {1}({2}ns);\n'.format(strFunctions.objAbbrev(attrib['element']), attrib['element'], pkgName.lower()))
      output.write('    delete {0}ns;\n'.format(pkgName.lower()))
      output.write('  }\n')
      output.write('  catch (...)\n')
      output.write('  {\n')
      output.write('    /* here we do not create a default object as the level/version must\n')
      output.write('     * match the parent object\n')
      output.write('     *\n')
      output.write('     * do nothing\n')
      output.write('     */\n')
      output.write('  }\n\n')
      output.write('  if({0} != NULL)\n'.format(strFunctions.objAbbrev(attrib['element'])))
      output.write('  {\n')
      output.write('    m{0}.appendAndOwn({1});\n'.format(strFunctions.capp(attrib['name']), strFunctions.objAbbrev(attrib['element'])))
      output.write('  }\n\n')
      output.write('  return {0};\n'.format(strFunctions.objAbbrev(attrib['element'])))
      output.write('}\n\n\n')
  elif attrib.has_key('concrete'):
    for elem in generalFunctions.getConcretes(attrib['root'], attrib['concrete']):
      output.write('/**\n')
      output.write(' * Creates a new {0} object, adds it to this {1}s\n'.format(elem['element'], element))
      output.write(' * {0} and returns the {1} object created. \n'.format(lotype, elem['element']))
      output.write(' *\n')
      output.write(' * @return a new {0} object instance\n'.format(elem['element']))
      output.write(' *\n')
      output.write(' * @see add{0}(const {0}*)\n'.format(strFunctions.cap(attrib['element'])))
      output.write(' */\n')
      output.write('{0}* \n'.format(elem['element']))
      output.write('{0}::create{1}()\n'.format(element, strFunctions.cap(elem['name'])))
      output.write('{\n')
      output.write('  {0}* {1} = NULL;\n\n'.format(elem['element'], strFunctions.objAbbrev(elem['element'])))
      output.write('  try\n')
      output.write('  {\n')
      output.write('    {0}_CREATE_NS({1}ns, getSBMLNamespaces());\n'.format(pkgName.upper(), pkgName.lower()))
      output.write(
        '    {0} = new {1}({2}ns);\n'.format(strFunctions.objAbbrev(elem['element']), elem['element'], pkgName.lower()))
      output.write('    delete {0}ns;\n'.format(pkgName.lower()))
      output.write('  }\n')
      output.write('  catch (...)\n')
      output.write('  {\n')
      output.write('    /* here we do not create a default object as the level/version must\n')
      output.write('     * match the parent object\n')
      output.write('     *\n')
      output.write('     * do nothing\n')
      output.write('     */\n')
      output.write('  }\n\n')
      output.write('  if({0} != NULL)\n'.format(strFunctions.objAbbrev(elem['element'])))
      output.write('  {\n')
      output.write('    m{0}.appendAndOwn({1});\n'.format(strFunctions.capp(attrib['name']), strFunctions.objAbbrev(elem['element'])))
      output.write('  }\n\n')
      output.write('  return {0};\n'.format(strFunctions.objAbbrev(elem['element'])))
      output.write('}\n\n\n')
Exemplo n.º 38
0
def writeSetCode(attrib, output, element):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  if attType == 'string':
    attTypeCode = 'const std::string&'
  else:
    attTypeCode = att[3]
  num = att[4]
  if attType == 'lo_element':
    return
  output.write('/*\n')
  output.write(' * Sets {0} and returns value indicating success.\n'.format(attName))
  output.write(' */\n')
  output.write('int\n')
  output.write('{0}::set{1}({2} {3})\n'.format(element, capAttName, attTypeCode, attName))
  output.write('{\n')
  if attType == 'string':
    if attName == 'id':
      output.write('\treturn SyntaxChecker::checkAndSetSId({0}, m{1});\n'.format(attName, capAttName ))
    else:
      output.write('\tif (&({0}) == NULL)\n'.format(attName))
      output.write('\t{\n\t\treturn LIBSEDML_INVALID_ATTRIBUTE_VALUE;\n\t}\n')
      if attrib['type'] == 'SIdRef':
        output.write('\telse if (!(SyntaxChecker::isValidInternalSId({0})))\n'.format(attName))
        output.write('\t{\n\t\treturn LIBSEDML_INVALID_ATTRIBUTE_VALUE;\n\t}\n')
      output.write('\telse\n\t{\n')
      output.write('\t\tm{0} = {1};\n'.format(capAttName, attName))
      output.write('\t\treturn LIBSEDML_OPERATION_SUCCESS;\n\t}\n')
  elif num == True:
    output.write('\tm{0} = {1};\n'.format(capAttName, attName))
    output.write('\tmIsSet{0} = true;\n'.format(capAttName))
    output.write('\treturn LIBSEDML_OPERATION_SUCCESS;\n')
  elif attType == 'boolean':
    output.write('\tm{0} = {1};\n'.format(capAttName, attName))
    output.write('\tmIsSet{0} = true;\n'.format(capAttName))
    output.write('\treturn LIBSEDML_OPERATION_SUCCESS;\n')
  elif attType == 'element':
    output.write('\tif (m{0} == {1})\n'.format(capAttName, attName))
    output.write('\t{\n\t\treturn LIBSEDML_OPERATION_SUCCESS;\n\t}\n')
    output.write('\telse if ({0} == NULL)\n'.format(attName))
    output.write('\t{\n')
    output.write('\t\tdelete m{0};\n'.format(capAttName))
    output.write('\t\tm{0} = NULL;\n'.format(capAttName))
    output.write('\t\treturn LIBSEDML_OPERATION_SUCCESS;\n\t}\n')
    if attTypeCode == 'ASTNode*':
      output.write('\telse if (!({0}->isWellFormedASTNode()))\n'.format(attName))
      output.write('\t{\n\t\treturn LIBSEDML_INVALID_OBJECT;\n\t}\n')
    output.write('\telse\n\t{\n')
    output.write('\t\tdelete m{0};\n'.format(capAttName))
    output.write('\t\tm{0} = ({1} != NULL) ?\n'.format(capAttName, attName))
    if attTypeCode == 'ASTNode*':
      output.write('\t\t\t{0}->deepCopy() : NULL;\n'.format(attName))
    else:
      output.write('\t\t\tstatic_cast<{0}*>({1}->clone()) : NULL;\n'.format(attrib['element'], attName))
    output.write('\t\tif (m{0} != NULL)\n'.format(capAttName))
    output.write('\t\t{\n')
    #if attTypeCode == 'ASTNode*':
    #  output.write('\t\t\tm{0}->setParentSEDMLObject(this);\n'.format(capAttName, attName))
    #else:
    #  output.write('\t\t\tm{0}->connectToParent(this);\n'.format(capAttName, attName))
    if attTypeCode != 'ASTNode*':
      output.write('\t\t\tm{0}->connectToParent(this);\n'.format(capAttName, attName))
    output.write('\t\t}\n')
    output.write('\t\treturn LIBSEDML_OPERATION_SUCCESS;\n\t}\n')
  output.write('}\n\n\n')
Exemplo n.º 39
0
def writeSetCode(attrib, output, element):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  cleanName = strFunctions.cleanStr(attName)
  capAttName = att[1]
  attType = att[2]
  if attType == 'string':
    attTypeCode = 'const std::string&'
  else:
    attTypeCode = att[3]
  num = att[4]
  if attType == 'lo_element' or attType == 'inline_lo_element':
    return
  if attrib['type'] == 'array':
    output.write('/*\n')
    output.write(' * Sets the \"{0}\"'.format(attName))
    output.write(' element of this {0}.\n'.format(element))
    output.write(' *\n')
    output.write(' * @param inArray; {1} array to be set (it will be copied).\n'.format(attName, attTypeCode))
    output.write(' * @param arrayLength; the length of the array.\n')
    output.write(' *\n')
    output.write(' * @return integer value indicating success/failure of the\n')
    output.write(' * function.  @if clike The value is drawn from the\n')
    output.write(' * enumeration #OperationReturnValues_t. @endif The possible values\n')
    output.write(' * returned by this function are:\n')
    output.write(' * @li LIBSBML_OPERATION_SUCCESS\n')
    output.write(' * @li LIBSBML_INVALID_ATTRIBUTE_VALUE\n')
    output.write(' */\n')
    output.write('int\n{0}::set{1}('.format(element, capAttName))
    output.write('{0} inArray, int arrayLength)\n'.format(attTypeCode))
    output.write('{\n')
    output.write('  if (inArray == NULL) return LIBSBML_INVALID_ATTRIBUTE_VALUE;\n')
    output.write('\n')
    output.write('  if (m{0} != NULL) delete[] m{0};\n'.format(capAttName))
    output.write('  m{0} = new {1}[arrayLength];\n'.format(capAttName, attrib['element']))
    output.write('  memcpy(m{0}, inArray, sizeof({1})*arrayLength);\n'.format(capAttName, attrib['element']))
    output.write('  mIsSet{0}Length = true;\n'.format(capAttName))
    output.write('  m{0}Length = arrayLength;\n'.format(capAttName))
    output.write('\n')
    output.write('  return LIBSBML_OPERATION_SUCCESS;\n')
    output.write('}\n')
    return
  output.write('/*\n')
  output.write(' * Sets {0} and returns value indicating success.\n'.format(attName))
  output.write(' */\n')
  output.write('int\n')
  output.write('{0}::set{1}({2} {3})\n'.format(element, capAttName, attTypeCode, cleanName))
  output.write('{\n')
  if attType == 'string':
    if attName == 'id':
      output.write('  return SyntaxChecker::checkAndSetSId({0}, m{1});\n'.format(attName, capAttName))
    else:
      output.write('  if (&({0}) == NULL)\n'.format(cleanName))
      output.write('  {\n    return LIBSBML_INVALID_ATTRIBUTE_VALUE;\n  }\n')
      if attrib['type'] == 'SIdRef':
        output.write('  else if (!(SyntaxChecker::isValidInternalSId({0})))\n'.format(cleanName))
        output.write('  {\n    return LIBSBML_INVALID_ATTRIBUTE_VALUE;\n  }\n')
      output.write('  else\n  {\n')
      output.write('    m{0} = {1};\n'.format(capAttName, cleanName))
      output.write('    return LIBSBML_OPERATION_SUCCESS;\n  }\n')
  elif num == True:
    output.write('  m{0} = {1};\n'.format(capAttName, cleanName))
    output.write('  mIsSet{0} = true;\n'.format(capAttName))
    output.write('  return LIBSBML_OPERATION_SUCCESS;\n')
  elif attrib['type'] == 'enum':
    output.write('  m{0} = {1};\n'.format(capAttName, cleanName))
    output.write('  return LIBSBML_OPERATION_SUCCESS;\n')
  elif attrib['type'] == 'array':
    output.write('  m{0} = {1};\n'.format(capAttName, cleanName))
    output.write('  return LIBSBML_OPERATION_SUCCESS;\n')
  elif attType == 'boolean':
    output.write('  m{0} = {1};\n'.format(capAttName, cleanName))
    output.write('  mIsSet{0} = true;\n'.format(capAttName))
    output.write('  return LIBSBML_OPERATION_SUCCESS;\n')
  elif attType == 'XMLNode*':
      output.write('  if (m{0} == {1})\n'.format(capAttName, cleanName))
      output.write('  {\n    return LIBSBML_OPERATION_SUCCESS;\n  }\n')
      output.write('  else if ({0} == NULL)\n'.format(cleanName))
      output.write('  {\n')
      output.write('    delete m{0};\n'.format(capAttName))
      output.write('    m{0} = NULL;\n'.format(capAttName))
      output.write('    return LIBSBML_OPERATION_SUCCESS;\n  }\n')
      output.write('  delete m{0};\n'.format(capAttName))
      output.write('  m{0} = ({1} != NULL) ?\n'.format(capAttName, cleanName))
      output.write('    {0}->clone() : NULL;\n'.format(cleanName))
      output.write('  return LIBSBML_OPERATION_SUCCESS;\n')
  elif attType == 'element':
    output.write('  if (m{0} == {1})\n'.format(capAttName, cleanName))
    output.write('  {\n    return LIBSBML_OPERATION_SUCCESS;\n  }\n')
    output.write('  else if ({0} == NULL)\n'.format(cleanName))
    output.write('  {\n')
    output.write('    delete m{0};\n'.format(capAttName))
    output.write('    m{0} = NULL;\n'.format(capAttName))
    output.write('    return LIBSBML_OPERATION_SUCCESS;\n  }\n')
    if attTypeCode == 'const ASTNode*':
      output.write('  else if (!({0}->isWellFormedASTNode()))\n'.format(cleanName))
      output.write('  {\n    return LIBSBML_INVALID_OBJECT;\n  }\n')
    output.write('  else\n  {\n')
    output.write('    delete m{0};\n'.format(capAttName))
    output.write('    m{0} = ({1} != NULL) ?\n'.format(capAttName, cleanName))
    if attTypeCode == 'const ASTNode*':
      output.write('      {0}->deepCopy() : NULL;\n'.format(cleanName))
    else:
      output.write('      static_cast<{0}>({1}->clone()) : NULL;\n'.format(attTypeCode, cleanName))
    output.write('    if (m{0} != NULL)\n'.format(capAttName))
    output.write('    {\n')
    if attTypeCode == 'const ASTNode*':
      output.write('      m{0}->setParentSBMLObject(this);\n'.format(capAttName, cleanName))
    else:
      if generalFunctions.overridesElementName(attrib):
        output.write('      m{0}->setElementName("{1}");\n'.format(capAttName, cleanName))
      output.write('      m{0}->connectToParent(this);\n'.format(capAttName, cleanName))
    output.write('    }\n')
    output.write('    return LIBSBML_OPERATION_SUCCESS;\n  }\n')
  output.write('}\n\n\n')

  if attrib['type'] == 'enum':
    output.write('/*\n')
    output.write(' * Sets {0} and returns value indicating success.\n'.format(attName))
    output.write(' */\n')
    output.write('int\n')
    output.write('{0}::set{1}(const std::string& {2})\n'.format(element, capAttName, cleanName))
    output.write('{\n')
    output.write('  {0}_t parsed = {0}_parse({1}.c_str());\n'.format(attrib['element'], cleanName))
    output.write('  if (parsed == {0}_UNKNOWN) return LIBSBML_INVALID_ATTRIBUTE_VALUE;\n'.format(attrib['element'].upper(), cleanName))
    output.write('  m{0} = parsed;\n'.format(capAttName))
    output.write('  return LIBSBML_OPERATION_SUCCESS;\n')
    output.write('}\n\n\n')
Exemplo n.º 40
0
def writeSetFunction(attrib, output, element):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  if attType == 'string':
    attTypeCode = 'const std::string&' 
  else:
    attTypeCode = att[3]
  num = att[4]
  if attrib['type'] == 'lo_element' or attrib['type'] == 'inline_lo_element':
    return
  elif attrib['type'] == 'array':
    output.write('  /**\n')
    output.write('   * Sets the \"{0}\"'.format(attName))
    output.write(' element of this {0}.\n'.format(element))
    output.write('   *\n')
    output.write('   * @param inArray; {1} array to be set (it will be copied).\n'.format(attName, attTypeCode))
    output.write('   * @param arrayLength; the length of the array.\n')
    output.write('   *\n')
    output.write('   * @return integer value indicating success/failure of the\n')
    output.write('   * function.  @if clike The value is drawn from the\n')
    output.write('   * enumeration #OperationReturnValues_t. @endif The possible values\n')
    output.write('   * returned by this function are:\n')
    output.write('   * @li LIBSBML_OPERATION_SUCCESS\n')
    output.write('   * @li LIBSBML_INVALID_ATTRIBUTE_VALUE\n')
    output.write('   */\n')
    output.write('  virtual int set{0}('.format(capAttName))
    output.write('{0} inArray, int arrayLength);\n\n\n'.format(attTypeCode))
  elif attrib['type'] == 'element':
    output.write('  /**\n')
    output.write('   * Sets the \"{0}\"'.format(attName))
    output.write(' element of this {0}.\n'.format(element))
    output.write('   *\n')
    output.write('   * @param {0}; {1} to be set.\n'.format(strFunctions.cleanStr(attName), attTypeCode))
    output.write('   *\n')
    output.write('   * @return integer value indicating success/failure of the\n')
    output.write('   * function.  @if clike The value is drawn from the\n')
    output.write('   * enumeration #OperationReturnValues_t. @endif The possible values\n')
    output.write('   * returned by this function are:\n')
    output.write('   * @li LIBSBML_OPERATION_SUCCESS\n')
    output.write('   * @li LIBSBML_INVALID_ATTRIBUTE_VALUE\n')
    output.write('   */\n')
    output.write('  virtual int set{0}('.format(capAttName))
    output.write('{0} {1});\n\n\n'.format(attTypeCode, strFunctions.cleanStr(attName)))
  else:
    output.write('  /**\n')
    output.write('   * Sets the value of the \"{0}\"'.format(attName))
    output.write(' attribute of this {0}.\n'.format(element))
    output.write('   *\n')
    output.write('   * @param {0}; {1} value of the "{2}" attribute to be set\n'.format(strFunctions.cleanStr(attName), attTypeCode, attName))
    output.write('   *\n')
    output.write('   * @return integer value indicating success/failure of the\n')
    output.write('   * function.  @if clike The value is drawn from the\n')
    output.write('   * enumeration #OperationReturnValues_t. @endif The possible values\n')
    output.write('   * returned by this function are:\n')
    output.write('   * @li LIBSBML_OPERATION_SUCCESS\n')
    output.write('   * @li LIBSBML_INVALID_ATTRIBUTE_VALUE\n')
    output.write('   */\n')
    output.write('  virtual int set{0}('.format(capAttName))
    output.write('{0} {1});\n\n\n'.format(attTypeCode, strFunctions.cleanStr(attName)))

    if attrib['type'] == 'enum':
      output.write('  /**\n')
      output.write('   * Sets the value of the \"{0}\"'.format(strFunctions.cleanStr(attName)))
      output.write(' attribute of this {0}.\n'.format(element))
      output.write('   *\n')
      output.write('   * @param {0}; string value of the "{1}" attribute to be set\n'.format(strFunctions.cleanStr(attName), attName))
      output.write('   *\n')
      output.write('   * @return integer value indicating success/failure of the\n')
      output.write('   * function.  @if clike The value is drawn from the\n')
      output.write('   * enumeration #OperationReturnValues_t. @endif The possible values\n')
      output.write('   * returned by this function are:\n')
      output.write('   * @li LIBSBML_OPERATION_SUCCESS\n')
      output.write('   * @li LIBSBML_INVALID_ATTRIBUTE_VALUE\n')
      output.write('   */\n')
      output.write('  virtual int set{0}('.format(capAttName))
      output.write('const std::string& {0});\n\n\n'.format(strFunctions.cleanStr(attName)))
Exemplo n.º 41
0
def writeSetCode(attrib, output, element):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  cleanName = strFunctions.cleanStr(attName)
  capAttName = att[1]
  attType = att[2]
  if attType == 'string':
    attTypeCode = 'const std::string&'
  else:
    attTypeCode = att[3]
  num = att[4]
  if attType == 'lo_element' or attType == 'inline_lo_element':
    return
  if attrib['type'] == 'array':
    output.write('/*\n')
    output.write(' * Sets the \"{0}\"'.format(attName))
    output.write(' element of this {0}.\n'.format(element))
    output.write(' *\n')
    output.write(' * @param inArray; {1} array to be set (it will be copied).\n'.format(attName, attTypeCode))
    output.write(' * @param arrayLength; the length of the array.\n')
    output.write(' *\n')
    output.write(' * @return integer value indicating success/failure of the\n')
    output.write(' * function.  @if clike The value is drawn from the\n')
    output.write(' * enumeration #OperationReturnValues_t. @endif The possible values\n')
    output.write(' * returned by this function are:\n')
    output.write(' * @li LIBSBML_OPERATION_SUCCESS\n')
    output.write(' * @li LIBSBML_INVALID_ATTRIBUTE_VALUE\n')
    output.write(' */\n')
    output.write('int\n{0}::set{1}('.format(element, capAttName))
    output.write('{0} inArray, int arrayLength)\n'.format(attTypeCode))
    output.write('{\n')
    output.write('  if (inArray == NULL) return LIBSBML_INVALID_ATTRIBUTE_VALUE;\n')
    output.write('\n')
    output.write('  if (m{0} != NULL) delete[] m{0};\n'.format(capAttName))
    output.write('  m{0} = new {1}[arrayLength];\n'.format(capAttName, attrib['element']))
    output.write('  memcpy(m{0}, inArray, sizeof({1})*arrayLength);\n'.format(capAttName, attrib['element']))
    output.write('  mIsSet{0}Length = true;\n'.format(capAttName))
    output.write('  m{0}Length = arrayLength;\n'.format(capAttName))
    output.write('\n')
    output.write('  return LIBSBML_OPERATION_SUCCESS;\n')
    output.write('}\n')
    return
  output.write('/*\n')
  output.write(' * Sets {0} and returns value indicating success.\n'.format(attName))
  output.write(' */\n')
  output.write('int\n')
  output.write('{0}::set{1}({2} {3})\n'.format(element, capAttName, attTypeCode, cleanName))
  output.write('{\n')
  if attType == 'string':
    if attName == 'id':
      output.write('  return SyntaxChecker::checkAndSetSId({0}, m{1});\n'.format(attName, capAttName))
    else:
      if attrib['type'] == 'SIdRef':
        output.write('  if (!(SyntaxChecker::isValidInternalSId({0})))\n'.format(cleanName))
        output.write('  {\n    return LIBSBML_INVALID_ATTRIBUTE_VALUE;\n  }\n')
        output.write('  else\n')
      output.write('  {\n')
      output.write('    m{0} = {1};\n'.format(capAttName, cleanName))
      output.write('    return LIBSBML_OPERATION_SUCCESS;\n  }\n')
  elif num == True:
    output.write('  m{0} = {1};\n'.format(capAttName, cleanName))
    output.write('  mIsSet{0} = true;\n'.format(capAttName))
    output.write('  return LIBSBML_OPERATION_SUCCESS;\n')
  elif attrib['type'] == 'enum':
    output.write('  m{0} = {1};\n'.format(capAttName, cleanName))
    output.write('  return LIBSBML_OPERATION_SUCCESS;\n')
  elif attrib['type'] == 'array':
    output.write('  m{0} = {1};\n'.format(capAttName, cleanName))
    output.write('  return LIBSBML_OPERATION_SUCCESS;\n')
  elif attType == 'boolean':
    output.write('  m{0} = {1};\n'.format(capAttName, cleanName))
    output.write('  mIsSet{0} = true;\n'.format(capAttName))
    output.write('  return LIBSBML_OPERATION_SUCCESS;\n')
  elif attType == 'XMLNode*':
      output.write('  if (m{0} == {1})\n'.format(capAttName, cleanName))
      output.write('  {\n    return LIBSBML_OPERATION_SUCCESS;\n  }\n')
      output.write('  else if ({0} == NULL)\n'.format(cleanName))
      output.write('  {\n')
      output.write('    delete m{0};\n'.format(capAttName))
      output.write('    m{0} = NULL;\n'.format(capAttName))
      output.write('    return LIBSBML_OPERATION_SUCCESS;\n  }\n')
      output.write('  delete m{0};\n'.format(capAttName))
      output.write('  m{0} = ({1} != NULL) ?\n'.format(capAttName, cleanName))
      output.write('    {0}->clone() : NULL;\n'.format(cleanName))
      output.write('  return LIBSBML_OPERATION_SUCCESS;\n')
  elif attType == 'element':
    output.write('  if (m{0} == {1})\n'.format(capAttName, cleanName))
    output.write('  {\n    return LIBSBML_OPERATION_SUCCESS;\n  }\n')
    output.write('  else if ({0} == NULL)\n'.format(cleanName))
    output.write('  {\n')
    output.write('    delete m{0};\n'.format(capAttName))
    output.write('    m{0} = NULL;\n'.format(capAttName))
    output.write('    return LIBSBML_OPERATION_SUCCESS;\n  }\n')
    if attTypeCode == 'const ASTNode*':
      output.write('  else if (!({0}->isWellFormedASTNode()))\n'.format(cleanName))
      output.write('  {\n    return LIBSBML_INVALID_OBJECT;\n  }\n')
    output.write('  else\n  {\n')
    output.write('    delete m{0};\n'.format(capAttName))
    output.write('    m{0} = ({1} != NULL) ?\n'.format(capAttName, cleanName))
    if attTypeCode == 'const ASTNode*':
      output.write('      {0}->deepCopy() : NULL;\n'.format(cleanName))
    else:
      output.write('      static_cast<{0}>({1}->clone()) : NULL;\n'.format(attTypeCode, cleanName))
    output.write('    if (m{0} != NULL)\n'.format(capAttName))
    output.write('    {\n')
    if attTypeCode == 'const ASTNode*':
      output.write('      m{0}->setParentSBMLObject(this);\n'.format(capAttName, cleanName))
    else:
      if generalFunctions.overridesElementName(attrib):
        output.write('      m{0}->setElementName("{1}");\n'.format(capAttName, cleanName))
      output.write('      m{0}->connectToParent(this);\n'.format(capAttName, cleanName))
    output.write('    }\n')
    output.write('    return LIBSBML_OPERATION_SUCCESS;\n  }\n')
  output.write('}\n\n\n')

  if attrib['type'] == 'enum':
    output.write('/*\n')
    output.write(' * Sets {0} and returns value indicating success.\n'.format(attName))
    output.write(' */\n')
    output.write('int\n')
    output.write('{0}::set{1}(const std::string& {2})\n'.format(element, capAttName, cleanName))
    output.write('{\n')
    output.write('  {0}_t parsed = {0}_parse({1}.c_str());\n'.format(attrib['element'], cleanName))
    output.write('  if (parsed == {0}_UNKNOWN) return LIBSBML_INVALID_ATTRIBUTE_VALUE;\n'.format(attrib['element'].upper(), cleanName))
    output.write('  m{0} = parsed;\n'.format(capAttName))
    output.write('  return LIBSBML_OPERATION_SUCCESS;\n')
    output.write('}\n\n\n')
Exemplo n.º 42
0
def writeSetCode(attrib, output, element):
    att = generalFunctions.parseAttribute(attrib)
    attName = att[0]
    capAttName = att[1]
    attType = att[2]
    if attType == 'string':
        attTypeCode = 'const std::string&'
    else:
        attTypeCode = att[3]
    num = att[4]
    if attType == 'lo_element':
        return
    output.write('/*\n')
    output.write(
        ' * Sets {0} and returns value indicating success.\n'.format(attName))
    output.write(' */\n')
    output.write('int\n')
    output.write('{0}::set{1}({2} {3})\n'.format(element, capAttName,
                                                 attTypeCode, attName))
    output.write('{\n')
    if attType == 'string':
        if attName == 'id':
            output.write(
                '\treturn SyntaxChecker::checkAndSetSId({0}, m{1});\n'.format(
                    attName, capAttName))
        else:
            output.write('\tif (&({0}) == NULL)\n'.format(attName))
            output.write(
                '\t{\n\t\treturn LIBSEDML_INVALID_ATTRIBUTE_VALUE;\n\t}\n')
            if attrib['type'] == 'SIdRef':
                output.write(
                    '\telse if (!(SyntaxChecker::isValidInternalSId({0})))\n'.
                    format(attName))
                output.write(
                    '\t{\n\t\treturn LIBSEDML_INVALID_ATTRIBUTE_VALUE;\n\t}\n')
            output.write('\telse\n\t{\n')
            output.write('\t\tm{0} = {1};\n'.format(capAttName, attName))
            output.write('\t\treturn LIBSEDML_OPERATION_SUCCESS;\n\t}\n')
    elif num == True:
        output.write('\tm{0} = {1};\n'.format(capAttName, attName))
        output.write('\tmIsSet{0} = true;\n'.format(capAttName))
        output.write('\treturn LIBSEDML_OPERATION_SUCCESS;\n')
    elif attType == 'boolean':
        output.write('\tm{0} = {1};\n'.format(capAttName, attName))
        output.write('\tmIsSet{0} = true;\n'.format(capAttName))
        output.write('\treturn LIBSEDML_OPERATION_SUCCESS;\n')
    elif attType == 'element':
        output.write('\tif (m{0} == {1})\n'.format(capAttName, attName))
        output.write('\t{\n\t\treturn LIBSEDML_OPERATION_SUCCESS;\n\t}\n')
        output.write('\telse if ({0} == NULL)\n'.format(attName))
        output.write('\t{\n')
        output.write('\t\tdelete m{0};\n'.format(capAttName))
        output.write('\t\tm{0} = NULL;\n'.format(capAttName))
        output.write('\t\treturn LIBSEDML_OPERATION_SUCCESS;\n\t}\n')
        if attTypeCode == 'ASTNode*':
            output.write(
                '\telse if (!({0}->isWellFormedASTNode()))\n'.format(attName))
            output.write('\t{\n\t\treturn LIBSEDML_INVALID_OBJECT;\n\t}\n')
        output.write('\telse\n\t{\n')
        output.write('\t\tdelete m{0};\n'.format(capAttName))
        output.write('\t\tm{0} = ({1} != NULL) ?\n'.format(
            capAttName, attName))
        if attTypeCode == 'ASTNode*':
            output.write('\t\t\t{0}->deepCopy() : NULL;\n'.format(attName))
        else:
            output.write(
                '\t\t\tstatic_cast<{0}*>({1}->clone()) : NULL;\n'.format(
                    attrib['element'], attName))
        output.write('\t\tif (m{0} != NULL)\n'.format(capAttName))
        output.write('\t\t{\n')
        #if attTypeCode == 'ASTNode*':
        #  output.write('\t\t\tm{0}->setParentSEDMLObject(this);\n'.format(capAttName, attName))
        #else:
        #  output.write('\t\t\tm{0}->connectToParent(this);\n'.format(capAttName, attName))
        if attTypeCode != 'ASTNode*':
            output.write('\t\t\tm{0}->connectToParent(this);\n'.format(
                capAttName, attName))
        output.write('\t\t}\n')
        output.write('\t\treturn LIBSEDML_OPERATION_SUCCESS;\n\t}\n')
    output.write('}\n\n\n')
Exemplo n.º 43
0
def writeGetCode(attrib, output, element):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  if attType == 'lo_element' or attType == 'inline_lo_element':
    return

  if attrib['type'] == 'array':
    output.write('/*\n');
    output.write(' * The "{0}" attribute of this {1} is returned in an {2} array (pointer)\n'.format(attName, element, attTypeCode));
    output.write(' * that is passed as argument to the method (this is needed while using SWIG to\n');
    output.write(' * convert int[] from C++ to Java). The method itself has a return type void.\n');
    output.write(' *\n');
    output.write(' * NOTE: you have to pre-allocate the array with the correct length!'); 
    output.write(' *\n');
    output.write(' * @return void.\n');
    output.write(' */\n');
    output.write('void\n{0}::get{1}({2} outArray) const\n'.format(element,capAttName, attTypeCode));
    output.write('{\n');
    output.write('   if (outArray == NULL || m{0} == NULL) return;\n\n'.format(capAttName))
    output.write('   memcpy(outArray , m{0}, sizeof({1})*m{0}Length);\n'.format(capAttName, attrib['element']));
    output.write('}\n\n\n');
    return

  output.write('/*\n')
  output.write(' * Returns the value of the \"{0}\"'.format(attName))
  output.write(' attribute of this {0}.\n'.format(element))
  output.write(' */\n')
  if attType == 'element' and attTypeCode != 'const ASTNode*':
    output.write('const {0}\n'.format(attTypeCode))
  else:
    output.write('{0}\n'.format(attTypeCode))
  output.write('{0}::get{1}() const\n'.format(element, capAttName))
  output.write('{\n')
  output.write('  return m{0};\n'.format(capAttName))
  output.write('}\n\n\n')

  if attType == 'element' and attName != 'math':
    # return non-const elements as well
    output.write('/*\n')
    output.write(' * Returns the value of the \"{0}\"'.format(attName))
    output.write(' attribute of this {0}.\n'.format(element))
    output.write(' */\n')
    output.write('{0}\n'.format(attTypeCode))
    output.write('{0}::get{1}()\n'.format(element, capAttName))
    output.write('{\n')
    output.write('  return m{0};\n'.format(capAttName))
    output.write('}\n\n\n')

    pkgName = attrib['root']['name']

    if attrib['abstract'] == False:
      output.write('/*\n')
      output.write(' * Creates a new \"{0}\"'.format(attName))
      output.write(' element of this {0} and returns it.\n'.format(element))
      output.write(' */\n')
      output.write('{0}\n'.format(attTypeCode))
      output.write('{0}::create{1}()\n'.format(element, capAttName))
      output.write('{\n')
      if attName == 'math' or attName == 'Math' or attType == 'XMLNode*':
        output.write('  if (m{0} != NULL) delete m{0};\n'.format(capAttName))
        output.write('  m{0} = new {1}();\n'.format(capAttName, attrib['element']))
        output.write('  return m{0};\n'.format(capAttName))
      else:
        output.write('  if (m{0} != NULL) delete m{0};\n'.format(capAttName))
        output.write('  {0}_CREATE_NS({1}ns, getSBMLNamespaces());\n'.format(pkgName.upper(), pkgName.lower()))
        output.write('  m{0} = new {1}({2}ns);\n'.format(capAttName, attrib['element'], pkgName.lower()))
        if generalFunctions.overridesElementName(attrib):
          output.write('  m{0}->setElementName("{1}");\n'.format(capAttName, attrib['name']));
        output.write('  delete {0}ns;\n'.format(pkgName.lower()))
        output.write('  connectToChild();\n'.format(pkgName.lower()))          
        output.write('  return m{0};\n'.format(capAttName))
      output.write('}\n\n\n')
    else:
      for concrete in generalFunctions.getConcretes(attrib['root'], attrib['concrete']):
        output.write('/*\n')
        output.write(' * Creates a new \"{0}\"'.format(attName))
        output.write(' element of this {0} and returns it.\n'.format(element))
        output.write(' */\n')
        output.write('{0}*\n'.format(concrete['element']))
        output.write('{0}::create{1}()\n'.format(element, strFunctions.cap(concrete['name'])))
        output.write('{\n')
        output.write('  if (m{0} != NULL) delete m{0};\n'.format(capAttName))
        output.write('  {0}_CREATE_NS({1}ns, getSBMLNamespaces());\n'.format(pkgName.upper(), pkgName.lower()))
        output.write('  m{0} = new {1}({2}ns);\n'.format(capAttName, concrete['element'], pkgName.lower()))
        if generalFunctions.overridesElementName(concrete):
          output.write('  m{0}->setElementName("{1}");\n'.format(capAttName, attrib['name']));
        output.write('  delete {0}ns;\n'.format(pkgName.lower()))
        output.write('  connectToChild();\n'.format(pkgName.lower()))          
        output.write('  return static_cast<{0}*>(m{1});\n'.format(concrete['element'], capAttName))
        output.write('}\n\n\n')
Exemplo n.º 44
0
def writeSetCode(attrib, output, element):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  if attType == 'string':
    attTypeCode = 'const std::string&'
  else:
    attTypeCode = att[3]
  num = att[4]
  if attType == 'lo_element':
    return
  elif attrib['type'] == 'std::vector<double>':
    output.write('/**\n')
    output.write(' * Sets the value of the \"{0}\"'.format(attName))
    output.write(' attribute of this {0}.\n'.format(element))
    output.write(' *\n')
    output.write(' * @param {0}; {1} value of the "{0}" attribute to be set\n'.format(attName, attTypeCode))
    output.write(' *\n')
    output.write(' * @return integer value indicating success/failure of the\n')
    output.write(' * function.  @if clike The value is drawn from the\n')
    output.write(' * enumeration #OperationReturnValues_t. @endif The possible values\n')
    output.write(' * returned by this function are:\n')
    output.write(' * @li LIBSEDML_OPERATION_SUCCESS\n')
    output.write(' * @li LIBSEDML_INVALID_ATTRIBUTE_VALUE\n')
    output.write(' */\n')
    output.write('int\n{0}::set{1}('.format(element, strFunctions.capp(capAttName)))
    output.write('const {0}& {1})\n'.format(attTypeCode, attName))
    output.write('{\n')
    output.write('\tm{0} = {1};\n'.format( strFunctions.capp(capAttName), attName))
    output.write('\treturn LIBSEDML_OPERATION_SUCCESS;\n')
    output.write('}\n\n\n')
    output.write('/**\n')
    output.write(' * Adds another value to the \"{0}\"'.format(attName))
    output.write(' attribute of this {0}.\n'.format(element))
    output.write(' *\n')
    output.write(' * @param {0}; {1} value of the "{0}" attribute to be added \n'.format(attName, 'double'))
    output.write(' *\n')
    output.write(' * @return integer value indicating success/failure of the\n')
    output.write(' * function.  @if clike The value is drawn from the\n')
    output.write(' * enumeration #OperationReturnValues_t. @endif The possible values\n')
    output.write(' * returned by this function are:\n')
    output.write(' * @li LIBSEDML_OPERATION_SUCCESS\n')
    output.write(' * @li LIBSEDML_INVALID_ATTRIBUTE_VALUE\n')
    output.write(' */\n')
    output.write('int\n{0}::add{1}('.format(element, capAttName))
    output.write('{0} {1})\n'.format('double', attName))
    output.write('{\n')
    output.write('\tm{0}.push_back({1});\n'.format( strFunctions.capp(capAttName), attName))
    output.write('\treturn LIBSEDML_OPERATION_SUCCESS;\n')
    output.write('}\n\n\n')
  else:
    output.write('/*\n')
    output.write(' * Sets {0} and returns value indicating success.\n'.format(attName))
    output.write(' */\n')
    output.write('int\n')
    output.write('{0}::set{1}({2} {3})\n'.format(element, capAttName, attTypeCode, attName))
    output.write('{\n')
    if attType == 'string':
      if attName == 'id':
        output.write('\treturn SyntaxChecker::checkAndSetSId({0}, m{1});\n'.format(attName, capAttName ))
      else:
        output.write('\tif (&({0}) == NULL)\n'.format(attName))
        output.write('\t{\n\t\treturn LIBSEDML_INVALID_ATTRIBUTE_VALUE;\n\t}\n')
        if attrib['type'] == 'SIdRef':
          output.write('\telse if (!(SyntaxChecker::isValidInternalSId({0})))\n'.format(attName))
          output.write('\t{\n\t\treturn LIBSEDML_INVALID_ATTRIBUTE_VALUE;\n\t}\n')
        output.write('\telse\n\t{\n')
        output.write('\t\tm{0} = {1};\n'.format(capAttName, attName))
        output.write('\t\treturn LIBSEDML_OPERATION_SUCCESS;\n\t}\n')
    elif num == True:
      output.write('\tm{0} = {1};\n'.format(capAttName, attName))
      output.write('\tmIsSet{0} = true;\n'.format(capAttName))
      output.write('\treturn LIBSEDML_OPERATION_SUCCESS;\n')
    elif attType == 'boolean':
      output.write('\tm{0} = {1};\n'.format(capAttName, attName))
      output.write('\tmIsSet{0} = true;\n'.format(capAttName))
      output.write('\treturn LIBSEDML_OPERATION_SUCCESS;\n')
    elif attType == 'XMLNode*':
      output.write('\tif (m{0} == {1})\n'.format(capAttName, attName))
      output.write('\t{\n\t\treturn LIBSEDML_OPERATION_SUCCESS;\n\t}\n')
      output.write('\telse if ({0} == NULL)\n'.format(attName))
      output.write('\t{\n')
      output.write('\t\tdelete m{0};\n'.format(capAttName))
      output.write('\t\tm{0} = NULL;\n'.format(capAttName))
      output.write('\t\treturn LIBSEDML_OPERATION_SUCCESS;\n\t}\n')
      output.write('\tdelete m{0};\n'.format(capAttName))
      output.write('\tm{0} = ({1} != NULL) ?\n'.format(capAttName, attName))
      output.write('\t\t{0}->clone() : NULL;\n'.format(attName))
      output.write('\treturn LIBSEDML_OPERATION_SUCCESS;\n')
    elif attType == 'element':
      output.write('\tif (m{0} == {1})\n'.format(capAttName, attName))
      output.write('\t{\n\t\treturn LIBSEDML_OPERATION_SUCCESS;\n\t}\n')
      output.write('\telse if ({0} == NULL)\n'.format(attName))
      output.write('\t{\n')
      output.write('\t\tdelete m{0};\n'.format(capAttName))
      output.write('\t\tm{0} = NULL;\n'.format(capAttName))
      output.write('\t\treturn LIBSEDML_OPERATION_SUCCESS;\n\t}\n')
      if attTypeCode == 'ASTNode*':
        output.write('\telse if (!({0}->isWellFormedASTNode()))\n'.format(attName))
        output.write('\t{\n\t\treturn LIBSEDML_INVALID_OBJECT;\n\t}\n')
      output.write('\telse\n\t{\n')
      output.write('\t\tdelete m{0};\n'.format(capAttName))
      output.write('\t\tm{0} = ({1} != NULL) ?\n'.format(capAttName, attName))
      if attTypeCode == 'ASTNode*':
        output.write('\t\t\t{0}->deepCopy() : NULL;\n'.format(attName))
      else:
        output.write('\t\t\tstatic_cast<{0}*>({1}->clone()) : NULL;\n'.format(attrib['element'], attName))
      output.write('\t\tif (m{0} != NULL)\n'.format(capAttName))
      output.write('\t\t{\n')
      #if attTypeCode == 'ASTNode*':
      #  output.write('\t\t\tm{0}->setParentSEDMLObject(this);\n'.format(capAttName, attName))
      #else:
      #  output.write('\t\t\tm{0}->connectToParent(this);\n'.format(capAttName, attName))
      if attTypeCode != 'ASTNode*':
        output.write('\t\t\tm{0}->connectToParent(this);\n'.format(capAttName, attName))
      output.write('\t\t}\n')
      output.write('\t\treturn LIBSEDML_OPERATION_SUCCESS;\n\t}\n')
    output.write('}\n\n\n')
Exemplo n.º 45
0
def writeListOfSubFunctions(attrib, output, element, pkgName):
  lotype = generalFunctions.getListOfClassName(attrib, strFunctions.cap(attrib['element']))
  loname = generalFunctions.writeListOf(strFunctions.cap(attrib['name']))
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  output.write('/*\n')
  output.write(' * Returns the  \"{0}\"'.format(lotype))
  output.write(' in this {0} object.\n'.format(element))
  output.write(' */\n')
  output.write('const {0}*\n'.format(lotype))
  output.write('{0}::get{1}() const\n'.format(element, loname))
  output.write('{\n')
  output.write('  return &m{0};\n'.format(strFunctions.capp(attName)))
  output.write('}\n\n\n')
  output.write('/*\n')
  output.write(' * Returns the  \"{0}\"'.format(lotype))
  output.write(' in this {0} object.\n'.format(element))
  output.write(' */\n')
  output.write('{0}*\n'.format(lotype))
  output.write('{0}::get{1}()\n'.format(element, loname))
  output.write('{\n')
  output.write('  return &m{0};\n'.format(strFunctions.capp(attName)))
  output.write('}\n\n\n')
  writeListOfCode.writeRemoveFunctions(output, strFunctions.cap(attrib['name']), attrib['element'], True, element, capAttName, attrib)
  writeListOfCode.writeGetFunctions(output, strFunctions.cap(attrib['name']), attrib['element'], True, element, capAttName, attrib)
  output.write('/*\n')
  output.write(' * Adds a copy the given \"{0}\" to this {1}.\n'.format(attrib['element'], element))
  output.write(' *\n')
  output.write(' * @param {0}; the {1} object to add\n'.format(strFunctions.objAbbrev(attrib['element']), attrib['element']))
  output.write(' *\n')
  output.write(' * @return integer value indicating success/failure of the\n')
  output.write(' * function.  @if clike The value is drawn from the\n')
  output.write(' * enumeration #OperationReturnValues_t. @endif The possible values\n')
  output.write(' * returned by this function are:\n')
  output.write(' * @li LIBSBML_OPERATION_SUCCESS\n')
  output.write(' * @li LIBSBML_INVALID_ATTRIBUTE_VALUE\n')
  output.write(' */\n')
  output.write('int\n')
  output.write('{0}::add{1}(const {2}* {3})\n'.format(element, strFunctions.cap(attrib['name']), attrib['element'], strFunctions.objAbbrev(attrib['element'])))
  output.write('{\n')
  output.write('  if ({0} == NULL)\n'.format(strFunctions.objAbbrev(attrib['element'])))
  output.write('  {\n')
  output.write('    return LIBSBML_OPERATION_FAILED;\n')
  output.write('  }\n')
  output.write('  else if ({0}->hasRequiredAttributes() == false)\n'.format(strFunctions.objAbbrev(attrib['element'])))
  output.write('  {\n')
  output.write('    return LIBSBML_INVALID_OBJECT;\n')
  output.write('  }\n')
  output.write('  else if (getLevel() != {0}->getLevel())\n'.format(strFunctions.objAbbrev(attrib['element'])))
  output.write('  {\n')
  output.write('    return LIBSBML_LEVEL_MISMATCH;\n')
  output.write('  }\n')
  output.write('  else if (getVersion() != {0}->getVersion())\n'.format(strFunctions.objAbbrev(attrib['element'])))
  output.write('  {\n')
  output.write('    return LIBSBML_VERSION_MISMATCH;\n')
  output.write('  }\n')
  if not element.endswith('Plugin'):
    output.write(
      '  else if (matchesRequiredSBMLNamespacesForAddition(static_cast<const SBase *>({0})) == false)\n'.format(
        strFunctions.objAbbrev(attrib['element'])))
    output.write('  {\n')
    output.write('    return LIBSBML_NAMESPACES_MISMATCH;\n')
    output.write('  }\n')
  output.write('  else\n'.format(strFunctions.objAbbrev(attrib['element'])))
  output.write('  {\n')
  output.write('    m{0}.append({1});\n'.format(strFunctions.capp(attrib['name']),strFunctions.objAbbrev(attrib['element'])))
  output.write('    return LIBSBML_OPERATION_SUCCESS;\n')
  output.write('  }\n')
  output.write('}\n\n\n')
  output.write('/*\n')
  output.write(' * Get the number of {0} objects in this {1}.\n'.format(attrib['element'], element))
  output.write(' *\n')
  output.write(' * @return the number of {0} objects in this {1}\n'.format(attrib['element'], element))
  output.write(' */\n')
  output.write('unsigned int\n')
  output.write('{0}::getNum{1}() const\n'.format(element, strFunctions.capp(attrib['name'])))
  output.write('{\n')
  output.write('  return m{0}.size();\n'.format(strFunctions.capp(attrib['name'])))
  output.write('}\n\n\n')
  if attrib.has_key('abstract') == False or (attrib.has_key('abstract') and attrib['abstract'] == False):
      output.write('/*\n')
      output.write(' * Creates a new {0} object, adds it to this {1}s\n'.format(attrib['element'], element))
      output.write(' * {0} and returns the {1} object created. \n'.format(element, attrib['element']))
      output.write(' *\n')
      output.write(' * @return a new {0} object instance\n'.format(attrib['element']))
      output.write(' *\n')
      output.write(' * @see add{0}(const {0}* {1})\n'.format(attrib['element'], strFunctions.objAbbrev(attrib['element'])))
      output.write(' */\n')
      output.write('{0}*\n'.format(attrib['element']))
      output.write('{0}::create{1}()\n'.format(element, strFunctions.cap(attrib['name'])))
      output.write('{\n')
      output.write('  {0}* {1} = NULL;\n\n'.format(attrib['element'], strFunctions.objAbbrev(attrib['element'])))
      output.write('  try\n')
      output.write('  {\n')
      output.write('    {0}_CREATE_NS({1}ns, getSBMLNamespaces());\n'.format(pkgName.upper(), pkgName.lower()))
      output.write(
        '    {0} = new {1}({2}ns);\n'.format(strFunctions.objAbbrev(attrib['element']), attrib['element'], pkgName.lower()))
      output.write('    delete {0}ns;\n'.format(pkgName.lower()))
      output.write('  }\n')
      output.write('  catch (...)\n')
      output.write('  {\n')
      output.write('    /* here we do not create a default object as the level/version must\n')
      output.write('     * match the parent object\n')
      output.write('     *\n')
      output.write('     * do nothing\n')
      output.write('     */\n')
      output.write('  }\n\n')
      output.write('  if({0} != NULL)\n'.format(strFunctions.objAbbrev(attrib['element'])))
      output.write('  {\n')
      output.write('    m{0}.appendAndOwn({1});\n'.format(strFunctions.capp(attrib['name']), strFunctions.objAbbrev(attrib['element'])))
      output.write('  }\n\n')
      output.write('  return {0};\n'.format(strFunctions.objAbbrev(attrib['element'])))
      output.write('}\n\n\n')
  elif attrib.has_key('concrete'):
    for elem in generalFunctions.getConcretes(attrib['root'], attrib['concrete']):
      output.write('/**\n')
      output.write(' * Creates a new {0} object, adds it to this {1}s\n'.format(elem['element'], element))
      output.write(' * {0} and returns the {1} object created. \n'.format(lotype, elem['element']))
      output.write(' *\n')
      output.write(' * @return a new {0} object instance\n'.format(elem['element']))
      output.write(' *\n')
      output.write(' * @see add{0}(const {0}*)\n'.format(strFunctions.cap(attrib['element'])))
      output.write(' */\n')
      output.write('{0}* \n'.format(elem['element']))
      output.write('{0}::create{1}()\n'.format(element, strFunctions.cap(elem['name'])))
      output.write('{\n')
      output.write('  {0}* {1} = NULL;\n\n'.format(elem['element'], strFunctions.objAbbrev(elem['element'])))
      output.write('  try\n')
      output.write('  {\n')
      output.write('    {0}_CREATE_NS({1}ns, getSBMLNamespaces());\n'.format(pkgName.upper(), pkgName.lower()))
      output.write(
        '    {0} = new {1}({2}ns);\n'.format(strFunctions.objAbbrev(elem['element']), elem['element'], pkgName.lower()))
      output.write('    delete {0}ns;\n'.format(pkgName.lower()))
      output.write('  }\n')
      output.write('  catch (...)\n')
      output.write('  {\n')
      output.write('    /* here we do not create a default object as the level/version must\n')
      output.write('     * match the parent object\n')
      output.write('     *\n')
      output.write('     * do nothing\n')
      output.write('     */\n')
      output.write('  }\n\n')
      output.write('  if({0} != NULL)\n'.format(strFunctions.objAbbrev(elem['element'])))
      output.write('  {\n')
      output.write('    m{0}.appendAndOwn({1});\n'.format(strFunctions.capp(attrib['name']), strFunctions.objAbbrev(elem['element'])))
      output.write('  }\n\n')
      output.write('  return {0};\n'.format(strFunctions.objAbbrev(elem['element'])))
      output.write('}\n\n\n')
Exemplo n.º 46
0
def writeListOfSubFunctions(attrib, output, element):
  loname = generalFunctions.writeListOf(strFunctions.cap(attrib['name']))
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  num = att[4]
  output.write('/*\n')
  output.write(' * Returns the  \"{0}\"'.format(loname))
  output.write(' in this {0} object.\n'.format(element))
  output.write(' */\n')
  output.write('const {0}*\n'.format(loname))
  output.write('{0}::getListOf{1}s() const\n'.format(element, strFunctions.cap(attrib['name'])))
  output.write('{\n')
  output.write('\treturn &m{0};\n'.format(strFunctions.capp(attName)))
  output.write('}\n\n\n')
  writeListOfCode.writeRemoveFunctions(output, strFunctions.cap(attrib['name']), attrib['element'], True, element, capAttName)
  writeListOfCode.writeGetFunctions(output, strFunctions.cap(attrib['name']), attrib['element'], True, element, capAttName)
  output.write('/**\n')
  output.write(' * Adds a copy the given \"{0}\" to this {1}.\n'.format(attrib['element'], element))
  output.write(' *\n')
  output.write(' * @param {0}; the {1} object to add\n'.format(strFunctions.objAbbrev(attrib['element']), attrib['element']))
  output.write(' *\n')
  output.write(' * @return integer value indicating success/failure of the\n')
  output.write(' * function.  @if clike The value is drawn from the\n')
  output.write(' * enumeration #OperationReturnValues_t. @endif The possible values\n')
  output.write(' * returned by this function are:\n')
  output.write(' * @li LIBSEDML_OPERATION_SUCCESS\n')
  output.write(' * @li LIBSEDML_INVALID_ATTRIBUTE_VALUE\n')
  output.write(' */\n')
  output.write('int\n')
  output.write('{0}::add{1}(const {2}* {3})\n'.format(element, strFunctions.cap(attrib['name']), attrib['element'], strFunctions.objAbbrev(attrib['element'])))
  output.write('{\n')
  output.write('\tif({0} == NULL) return LIBSEDML_INVALID_ATTRIBUTE_VALUE;\n'.format(strFunctions.objAbbrev(attrib['element'])))
  output.write('\tm{0}.append({1});\n'.format(strFunctions.capp(attrib['name']),strFunctions.objAbbrev(attrib['element'])))
  output.write('\treturn LIBSEDML_OPERATION_SUCCESS;\n')
  output.write('}\n\n\n')
  output.write('/**\n')
  output.write(' * Get the number of {0} objects in this {1}.\n'.format(attrib['element'], element))
  output.write(' *\n')
  output.write(' * @return the number of {0} objects in this {1}\n'.format(attrib['element'], element))
  output.write(' */\n')
  output.write('unsigned int \n')
  output.write('{0}::getNum{1}s() const\n'.format(element, strFunctions.cap(attrib['name'])))
  output.write('{\n')
  output.write('\treturn m{0}.size();\n'.format(strFunctions.capp(attrib['name'])))
  output.write('}\n\n')
  if attrib.has_key('abstract') == False or (attrib.has_key('abstract') and attrib['abstract'] == False):
    output.write('/**\n')
    output.write(' * Creates a new {0} object, adds it to this {1}s\n'.format(attrib['element'], element))
    output.write(' * {0} and returns the {1} object created. \n'.format(element, attrib['element']))
    output.write(' *\n')
    output.write(' * @return a new {0} object instance\n'.format(attrib['element']))
    output.write(' *\n')
    output.write(' * @see add{0}(const {0}* {1})\n'.format(attrib['element'], strFunctions.objAbbrev(attrib['element'])))
    output.write(' */\n')
    output.write('{0}* \n'.format(attrib['element']))
    output.write('{0}::create{1}()\n'.format(element, strFunctions.cap(attrib['name'])))
    output.write('{\n')
    output.write('\t{0} *temp = new {0}();\n'.format(attrib['element']))
    output.write('\tif (temp != NULL) m{0}.appendAndOwn(temp);\n'.format(strFunctions.capp(attrib['name'])))
    output.write('\treturn temp;\n')
    output.write('}\n\n')
  elif attrib.has_key('concrete'):
    for elem in attrib['concrete']:
      output.write('/**\n')
      output.write(' * Creates a new {0} object, adds it to this {1}s\n'.format(elem['element'], element))
      output.write(' * {0} and returns the {1} object created. \n'.format(element, elem['element']))
      output.write(' *\n')
      output.write(' * @return a new {0} object instance\n'.format(elem['element']))
      output.write(' *\n')
      output.write(' * @see add{0}(const {1}* {2})\n'.format(strFunctions.cap(elem['name']), attrib['element'], strFunctions.objAbbrev(attrib['element'])))
      output.write(' */\n')
      output.write('{0}* \n'.format(elem['element']))
      output.write('{0}::create{1}()\n'.format(element, strFunctions.cap(elem['name'])))
      output.write('{\n')
      output.write('\t{0} *temp = new {0}();\n'.format(elem['element']))
      output.write('\tif (temp != NULL) m{0}.appendAndOwn(temp);\n'.format(strFunctions.capp(attrib['name'])))
      output.write('\treturn temp;\n')
      output.write('}\n\n')
Exemplo n.º 47
0
def writeGetCode(attrib, output, element):
  att = generalFunctions.parseAttribute(attrib)
  attName = att[0]
  capAttName = att[1]
  attType = att[2]
  attTypeCode = att[3]
  if attType == 'lo_element':
    return
  if attType == 'std::vector<double>': 
    output.write('/*\n')
    output.write(' * Returns the value of the \"{0}\"'.format(attName))
    output.write(' attribute of this {0}.\n'.format(element))
    output.write(' */\n')
    output.write('const {0}&\n'.format(attTypeCode))
    output.write('{0}::get{1}() const\n'.format(element, strFunctions.capp(capAttName)))
    output.write('{\n')
    output.write('  return m{0};\n'.format(strFunctions.capp(capAttName)))
    output.write('}\n\n\n')
    output.write('/*\n')
    output.write(' * Returns the value of the \"{0}\"'.format(attName))
    output.write(' attribute of this {0}.\n'.format(element))
    output.write(' */\n')
    output.write('{0}&\n'.format(attTypeCode))
    output.write('{0}::get{1}()\n'.format(element, strFunctions.capp(capAttName)))
    output.write('{\n')
    output.write('  return m{0};\n'.format(strFunctions.capp(capAttName)))
    output.write('}\n\n\n')
  else: 
    output.write('/*\n')
    output.write(' * Returns the value of the \"{0}\"'.format(attName))
    output.write(' attribute of this {0}.\n'.format(element))
    output.write(' */\n')
    output.write('const {0}\n'.format(attTypeCode))
    output.write('{0}::get{1}() const\n'.format(element, capAttName))
    output.write('{\n')
    output.write('  return m{0};\n'.format(capAttName))
    output.write('}\n\n\n')
    if attrib['type'] == 'element' and attName != 'math':
      output.write('/*\n')
      output.write(' * Returns the value of the \"{0}\"'.format(attName))
      output.write(' attribute of this {0}.\n'.format(element))
      output.write(' */\n')
      output.write('{0}\n'.format(attTypeCode))
      output.write('{0}::get{1}()\n'.format(element, capAttName))
      output.write('{\n')
      output.write('  return m{0};\n'.format(capAttName))
      output.write('}\n\n\n')
  if attType == 'element' and attName != 'math':
    output.write('/*\n')
    output.write(' * Creates a new \"{0}\"'.format(attName))
    output.write(' element of this {0} and returns it.\n'.format(element))
    output.write(' */\n')
    output.write('{0}\n'.format(attTypeCode))
    output.write('{0}::create{1}()\n'.format(element, capAttName))
    output.write('{\n')
    output.write('  m{0} = new {1}();\n'.format(capAttName, attrib['element']))
    output.write('  return m{0};\n'.format(capAttName))
    output.write('}\n\n\n')
  if attType == 'DimensionDescription*':
    output.write('/*\n')
    output.write(' * Creates a new \"{0}\"'.format(attName))
    output.write(' element of this {0} and returns it.\n'.format(element))
    output.write(' */\n')
    output.write('{0}\n'.format(attTypeCode))
    output.write('{0}::create{1}()\n'.format(element, capAttName))
    output.write('{\n')
    output.write('  if (m{0} != NULL)\n    delete m{0};\n\n'.format(capAttName))
    output.write('  m{0} = new {1}();\n'.format(capAttName, 'DimensionDescription'))
    output.write('  return m{0};\n'.format(capAttName))
    output.write('}\n\n\n')