001/* ----------------------------------------------------------------------------
002 * This file was automatically generated by SWIG (http://www.swig.org).
003 * Version 2.0.12
004 *
005 * Do not make changes to this file unless you know what you are doing--modify
006 * the SWIG interface file instead.
007 * ----------------------------------------------------------------------------- */
008
009package org.sbml.libsbml;
010
011/** 
012 * <span class="pkg-marker pkg-color-comp"><a href="group__comp.html">comp</a></span>
013 A convenience subclass of the ReplacedElement and
014 * ReplacedBy constructs from the &ldquo;comp&rdquo; package.
015 <p>
016 * The {@link Replacing} class does not exist officialy in the the 
017 * 'Hierarchical Model Composition' package
018 * (&ldquo;comp&rdquo;), but is implemented here as a convenience subclass of
019 * the {@link ReplacedElement} and {@link ReplacedBy} classes, since both of those classes
020 * define a 'submodelRef' attribute.
021 <p>
022 * The required attribute 'submodelRef' takes a value of type
023 * SIdRef, which must be the identifier of a {@link Submodel} object in
024 * the containing model.  The model referenced by the
025 * {@link Submodel} object establishes the object namespaces for the
026 * 'portRef', 'idRef', 'unitRef' and 'metaIdRef'
027 * attributes: only objects within the {@link Model} object may be referenced by
028 * those attributes.
029 */
030
031public class Replacing extends SBaseRef {
032   private long swigCPtr;
033
034   protected Replacing(long cPtr, boolean cMemoryOwn)
035   {
036     super(libsbmlJNI.Replacing_SWIGUpcast(cPtr), cMemoryOwn);
037     swigCPtr = cPtr;
038   }
039
040   protected static long getCPtr(Replacing obj)
041   {
042     return (obj == null) ? 0 : obj.swigCPtr;
043   }
044
045   protected static long getCPtrAndDisown (Replacing obj)
046   {
047     long ptr = 0;
048
049     if (obj != null)
050     {
051       ptr             = obj.swigCPtr;
052       obj.swigCMemOwn = false;
053     }
054
055     return ptr;
056   }
057
058  protected void finalize() {
059    delete();
060  }
061
062  public synchronized void delete() {
063    if (swigCPtr != 0) {
064      if (swigCMemOwn) {
065        swigCMemOwn = false;
066        libsbmlJNI.delete_Replacing(swigCPtr);
067      }
068      swigCPtr = 0;
069    }
070    super.delete();
071  }
072
073  
074/**
075   * Returns the value of the 'submodelRef' attribute of this {@link SBaseRef}.
076   <p>
077   * @return the value of the 'submodelRef' attribute of this {@link SBaseRef}.
078   */ public
079 String getSubmodelRef() {
080    return libsbmlJNI.Replacing_getSubmodelRef(swigCPtr, this);
081  }
082
083  
084/**
085   * Predicate returning <code>true</code> or <code>false</code> depending on whether this
086   * {@link SBaseRef}'s 'submodelRef' attribute has been set.
087   <p>
088   * @return <code>true</code> if this {@link SBaseRef}'s 'submodelRef' attribute has been set, 
089   * otherwise <code>false</code> is returned.
090   */ public
091 boolean isSetSubmodelRef() {
092    return libsbmlJNI.Replacing_isSetSubmodelRef(swigCPtr, this);
093  }
094
095  
096/**
097   * Sets the value of the 'submodelRef' attribute of this {@link SBaseRef}.  Fails
098   * if the id is not a valid syntax for an SIdRef.
099   <p>
100   * @return integer value indicating success/failure of the
101   * operation. The possible return values are:
102   * <ul>
103   * <li> {@link  libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS }
104   * <li> {@link  libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE }
105   * </ul>
106   */ public
107 int setSubmodelRef(String id) {
108    return libsbmlJNI.Replacing_setSubmodelRef(swigCPtr, this, id);
109  }
110
111  
112/**
113   * Unsets the value of the 'SubmodelRef' attribute of this {@link SBaseRef}.
114   <p>
115   * @return integer value indicating success/failure of the
116   * operation. The possible return values are:
117   * <ul>
118   * <li> {@link  libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS }
119   * <li> {@link  libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED }
120   * </ul>
121   */ public
122 int unsetSubmodelRef() {
123    return libsbmlJNI.Replacing_unsetSubmodelRef(swigCPtr, this);
124  }
125
126  
127/**
128   * Returns true if getNumReferents() is exactly 1 and if the submodelRef is set.
129   <p>
130   * @return boolean: 'true' if the attributes are correctly set; 'false' if not.
131   */ public
132 boolean hasRequiredAttributes() {
133    return libsbmlJNI.Replacing_hasRequiredAttributes(swigCPtr, this);
134  }
135
136  
137/**
138   * Finds and stores the referenced object.  Finds the {@link Submodel} to which
139   * it refers, getting the instantiated {@link Model} inside that {@link Submodel}, calling
140   * 'getReferencedElementFrom' on that model, and storing the result.
141   <p>
142   * @return integer value indicating success/failure of the
143   * operation. The possible return values are:
144   * <ul>
145   * <li> {@link  libsbmlConstants#LIBSBML_OPERATION_SUCCESS LIBSBML_OPERATION_SUCCESS }
146   * <li> {@link  libsbmlConstants#LIBSBML_INVALID_OBJECT LIBSBML_INVALID_OBJECT }
147   * <li> {@link  libsbmlConstants#LIBSBML_INVALID_ATTRIBUTE_VALUE LIBSBML_INVALID_ATTRIBUTE_VALUE }
148   * <li> {@link  libsbmlConstants#LIBSBML_OPERATION_FAILED LIBSBML_OPERATION_FAILED }
149   * </ul>
150   */ public
151 int saveReferencedElement() {
152    return libsbmlJNI.Replacing_saveReferencedElement(swigCPtr, this);
153  }
154
155  
156/**
157   * Renames all the SIdRef attributes on this element if they match
158   * <code>oldid</code>, but not any found in child or plugin elements.
159   */ public
160 void renameSIdRefs(String oldid, String newid) {
161    libsbmlJNI.Replacing_renameSIdRefs(swigCPtr, this, oldid, newid);
162  }
163
164  
165/**
166   * DEPRECATED FUNCTION:  DO NOT USE
167   <p>
168   * To retain old functionality, this function calls performReplacementAndCollect,
169   * and then actually removes the now-redundant element.  However, this can lead
170   * to doubly-deleted elements, as well as the incorrect interpretation of some
171   * models.  The replacement function performReplacementAndCollect
172   * has been marked protected, in the hopes that people will instead simply
173   * use CompModelPlugin.instantiateSubmodels, which hides all the complexity while
174   * still allowing access to a non-flattened version of a hierarchical model.
175   */ public
176 int performReplacement() {
177    return libsbmlJNI.Replacing_performReplacement(swigCPtr, this);
178  }
179
180  
181/** * @internal */ public
182 int replaceWithAndMaybeDelete(SBase replacement, boolean deleteme, ASTNode conversionFactor) {
183    return libsbmlJNI.Replacing_replaceWithAndMaybeDelete(swigCPtr, this, SBase.getCPtr(replacement), replacement, deleteme, ASTNode.getCPtr(conversionFactor), conversionFactor);
184  }
185
186}