getTypeCode() public method

public getTypeCode ( ) : int
return int
コード例 #1
0
    /// <summary>
    /// The function actually doing the transforming. This function is called 
    /// once for each SBase element in the model. 
    /// </summary>
    /// <param name="element">the current element</param>
    /// <returns>status code</returns>
    public override int transform(SBase element)
    {
        // return in case we don't have a valid element
        if (element == null || element.getTypeCode() == libsbml.SBML_LOCAL_PARAMETER)
            return libsbml.LIBSBML_OPERATION_SUCCESS;

        // or if there is nothing to do
        if (!element.isSetName() || element.getId() == element.getName())
            return libsbml.LIBSBML_OPERATION_SUCCESS;

        // find the new id
        string newId = getValidIdForName(element.getName());

        // set it
        element.setId(newId);

        // remember it
        existingIds.Add(newId);

        return libsbml.LIBSBML_OPERATION_SUCCESS;
    }
コード例 #2
0
ファイル: libsbml.cs プロジェクト: TotteKarlsson/roadrunner
        public static SBase DowncastSBase(IntPtr cPtr, bool owner)
        {
            if (cPtr.Equals(IntPtr.Zero)) return null;

            SBase sb = new SBase(cPtr, false);
            string pkgName = sb.getPackageName();
            if (pkgName == "core")
            {
            switch( sb.getTypeCode() )
            {
                case (int) libsbml.SBML_COMPARTMENT:
                    return new Compartment(cPtr, owner);

                case (int) libsbml.SBML_COMPARTMENT_TYPE:
                    return new CompartmentType(cPtr, owner);

                case (int) libsbml.SBML_CONSTRAINT:
                    return new Constraint(cPtr, owner);

                case (int) libsbml.SBML_DOCUMENT:
                    return new SBMLDocument(cPtr, owner);

                case (int) libsbml.SBML_DELAY:
                    return new Delay(cPtr, owner);

                case (int) libsbml.SBML_EVENT:
                    return new Event(cPtr, owner);

                case (int) libsbml.SBML_EVENT_ASSIGNMENT:
                    return new EventAssignment(cPtr, owner);

                case (int) libsbml.SBML_FUNCTION_DEFINITION:
                    return new FunctionDefinition(cPtr, owner);

                case (int) libsbml.SBML_INITIAL_ASSIGNMENT:
                    return new InitialAssignment(cPtr, owner);

                case (int) libsbml.SBML_KINETIC_LAW:
                    return new KineticLaw(cPtr, owner);

                case (int) libsbml.SBML_LIST_OF:
                     string name = sb.getElementName();
                     if(name == "listOf")
                         {
                    return new ListOf(cPtr, owner);
                     }
                     else if(name == "listOfCompartments")
                     {
                    return new ListOfCompartments(cPtr, owner);
                     }
                     else if(name == "listOfCompartmentTypes")
                     {
                    return new ListOfCompartmentTypes(cPtr, owner);
                     }
                     else if(name == "listOfConstraints")
                     {
                    return new ListOfConstraints(cPtr, owner);
                     }
                     else if(name == "listOfEvents")
                     {
                         return new ListOfEvents(cPtr, owner);
                                 }
                                 else if(name == "listOfEventAssignments")
                                 {
                    return new ListOfEventAssignments(cPtr, owner);
                         }
                         else if(name == "listOfFunctionDefinitions")
                         {
             		               return new ListOfFunctionDefinitions(cPtr, owner);
                         }
                         else if(name == "listOfInitialAssignments")
                         {
                           return new ListOfInitialAssignments(cPtr, owner);
                         }
                         else if(name == "listOfParameters")
                         {
                           return new ListOfParameters(cPtr, owner);
                         }
                         else if(name == "listOfLocalParameters")
                         {
                           return new ListOfLocalParameters(cPtr, owner);
                         }
                     else if(name == "listOfReactions")
                         {
                           return new ListOfReactions(cPtr, owner);
                         }
                         else if(name == "listOfRules")
                         {
                           return new ListOfRules(cPtr, owner);
                                 }
                         else if(name == "listOfSpecies")
                         {
                           return new ListOfSpecies(cPtr, owner);
                                 }
                         else if(name == "listOfUnknowns")
                         {
                           return new ListOfSpeciesReferences(cPtr, owner);
                                 }
                         else if(name == "listOfReactants")
                         {
                           return new ListOfSpeciesReferences(cPtr, owner);
                                 }
                         else if(name == "listOfProducts")
                         {
                           return new ListOfSpeciesReferences(cPtr, owner);
                                 }
                         else if(name == "listOfModifiers")
                         {
                           return new ListOfSpeciesReferences(cPtr, owner);
                                 }
                         else if(name == "listOfSpeciesTypes")
                         {
                           return new ListOfSpeciesTypes(cPtr, owner);
                                 }
                         else if(name == "listOfUnits")
                         {
                           return new ListOfUnits(cPtr, owner);
                                 }
                         else if(name == "listOfUnitDefinitions")
                         {
                           return new ListOfUnitDefinitions(cPtr, owner);
                                 }
                         return new ListOf(cPtr, owner);

                case (int) libsbml.SBML_MODEL:
                    return new Model(cPtr, owner);

                case (int) libsbml.SBML_PARAMETER:
                    return new Parameter(cPtr, owner);

            case (int) libsbml.SBML_PRIORITY:
                return new Priority(cPtr, owner);

                case (int) libsbml.SBML_LOCAL_PARAMETER:
                    return new LocalParameter(cPtr, owner);

                case (int) libsbml.SBML_REACTION:
                    return new Reaction(cPtr, owner);

                case (int) libsbml.SBML_SPECIES:
                    return new Species(cPtr, owner);

                case (int) libsbml.SBML_SPECIES_REFERENCE:
                    return new SpeciesReference(cPtr, owner);

                case (int) libsbml.SBML_MODIFIER_SPECIES_REFERENCE:
                    return new ModifierSpeciesReference(cPtr, owner);

                case (int) libsbml.SBML_SPECIES_TYPE:
                    return new SpeciesType(cPtr, owner);

                case (int) libsbml.SBML_TRIGGER:
                    return new Trigger(cPtr, owner);

                case (int) libsbml.SBML_UNIT_DEFINITION:
                    return new UnitDefinition(cPtr, owner);

                case (int) libsbml.SBML_UNIT:
                    return new Unit(cPtr, owner);

                case (int) libsbml.SBML_ALGEBRAIC_RULE:
                    return new AlgebraicRule(cPtr, owner);

                case (int) libsbml.SBML_ASSIGNMENT_RULE:
                    return new AssignmentRule(cPtr, owner);

                case (int) libsbml.SBML_RATE_RULE:
                    return new RateRule(cPtr, owner);

                case (int) libsbml.SBML_STOICHIOMETRY_MATH:
                    return new StoichiometryMath(cPtr, owner);

                default:
                    return new SBase(cPtr, owner);
            }
            }
            else
            {
            SBMLExtension sbmlext = SBMLExtensionRegistry.getInstance().getExtension(pkgName);
            if (sbmlext != null)
            {
                return sbmlext.DowncastSBase(cPtr,owner);
            }
            }
            return new SBase(cPtr, owner);
        }