From: <fbe...@us...> - 2015-05-28 08:09:02
|
Revision: 22270 http://sourceforge.net/p/sbml/code/22270 Author: fbergmann Date: 2015-05-28 08:08:59 +0000 (Thu, 28 May 2015) Log Message: ----------- - first batch of NULL reference checks (and tests) removed Modified Paths: -------------- trunk/libsbml/src/sbml/Compartment.cpp trunk/libsbml/src/sbml/CompartmentType.cpp trunk/libsbml/src/sbml/Constraint.cpp trunk/libsbml/src/sbml/Delay.cpp trunk/libsbml/src/sbml/Event.cpp trunk/libsbml/src/sbml/EventAssignment.cpp trunk/libsbml/src/sbml/FunctionDefinition.cpp trunk/libsbml/src/sbml/InitialAssignment.cpp trunk/libsbml/src/sbml/KineticLaw.cpp trunk/libsbml/src/sbml/LocalParameter.cpp trunk/libsbml/src/sbml/Model.cpp trunk/libsbml/src/sbml/Parameter.cpp trunk/libsbml/src/sbml/Priority.cpp trunk/libsbml/src/sbml/Reaction.cpp trunk/libsbml/src/sbml/Rule.cpp trunk/libsbml/src/sbml/SBMLDocument.cpp trunk/libsbml/src/sbml/SBMLNamespaces.cpp trunk/libsbml/src/sbml/SBMLReader.cpp trunk/libsbml/src/sbml/SBMLWriter.cpp trunk/libsbml/src/sbml/SBase.cpp trunk/libsbml/src/sbml/SimpleSpeciesReference.cpp trunk/libsbml/src/sbml/Species.cpp trunk/libsbml/src/sbml/SpeciesReference.cpp trunk/libsbml/src/sbml/SpeciesType.cpp trunk/libsbml/src/sbml/StoichiometryMath.cpp trunk/libsbml/src/sbml/Trigger.cpp trunk/libsbml/src/sbml/Unit.cpp trunk/libsbml/src/sbml/UnitDefinition.cpp trunk/libsbml/src/sbml/annotation/CVTerm.cpp trunk/libsbml/src/sbml/annotation/Date.cpp trunk/libsbml/src/sbml/annotation/ModelCreator.cpp trunk/libsbml/src/sbml/annotation/ModelHistory.cpp trunk/libsbml/src/sbml/annotation/RDFAnnotationParser.cpp trunk/libsbml/src/sbml/annotation/test/TestCopyAndClone.cpp trunk/libsbml/src/sbml/conversion/ConversionOption.cpp trunk/libsbml/src/sbml/conversion/ConversionProperties.cpp trunk/libsbml/src/sbml/conversion/SBMLConverter.cpp trunk/libsbml/src/sbml/conversion/SBMLFunctionDefinitionConverter.cpp trunk/libsbml/src/sbml/conversion/SBMLIdConverter.cpp trunk/libsbml/src/sbml/conversion/SBMLInferUnitsConverter.cpp trunk/libsbml/src/sbml/conversion/SBMLInitialAssignmentConverter.cpp trunk/libsbml/src/sbml/conversion/SBMLLevel1Version1Converter.cpp trunk/libsbml/src/sbml/conversion/SBMLLevelVersionConverter.cpp trunk/libsbml/src/sbml/conversion/SBMLLocalParameterConverter.cpp trunk/libsbml/src/sbml/conversion/SBMLReactionConverter.cpp trunk/libsbml/src/sbml/conversion/SBMLRuleConverter.cpp trunk/libsbml/src/sbml/conversion/SBMLStripPackageConverter.cpp trunk/libsbml/src/sbml/conversion/SBMLUnitsConverter.cpp trunk/libsbml/src/sbml/conversion/test/TestConversionOption.cpp trunk/libsbml/src/sbml/conversion/test/TestConversionProperties.cpp trunk/libsbml/src/sbml/extension/SBMLDocumentPlugin.cpp trunk/libsbml/src/sbml/extension/SBMLDocumentPluginNotRequired.cpp trunk/libsbml/src/sbml/extension/SBMLExtension.cpp trunk/libsbml/src/sbml/extension/SBMLExtensionRegistry.cpp trunk/libsbml/src/sbml/extension/SBaseExtensionPoint.cpp trunk/libsbml/src/sbml/extension/SBasePlugin.cpp trunk/libsbml/src/sbml/extension/SBasePluginCreatorBase.cpp trunk/libsbml/src/sbml/extension/test/TestSBMLExtension.cpp trunk/libsbml/src/sbml/extension/test/TestSBMLExtensionRegistry.cpp trunk/libsbml/src/sbml/math/ASTBase.cpp trunk/libsbml/src/sbml/math/ASTBinaryFunctionNode.cpp trunk/libsbml/src/sbml/math/ASTCSymbolAvogadroNode.cpp trunk/libsbml/src/sbml/math/ASTCSymbolDelayNode.cpp trunk/libsbml/src/sbml/math/ASTCSymbolTimeNode.cpp trunk/libsbml/src/sbml/math/ASTCiFunctionNode.cpp trunk/libsbml/src/sbml/math/ASTCiNumberNode.cpp trunk/libsbml/src/sbml/math/ASTCnBase.cpp trunk/libsbml/src/sbml/math/ASTConstantNumberNode.cpp trunk/libsbml/src/sbml/math/ASTFunction.cpp trunk/libsbml/src/sbml/math/ASTFunctionBase.cpp trunk/libsbml/src/sbml/math/ASTLambdaFunctionNode.cpp trunk/libsbml/src/sbml/math/ASTNaryFunctionNode.cpp trunk/libsbml/src/sbml/math/ASTPiecewiseFunctionNode.cpp trunk/libsbml/src/sbml/math/ASTQualifierNode.cpp trunk/libsbml/src/sbml/math/ASTSemanticsNode.cpp trunk/libsbml/src/sbml/math/ASTTypes.cpp trunk/libsbml/src/sbml/math/ASTUnaryFunctionNode.cpp trunk/libsbml/src/sbml/math/MathML.cpp trunk/libsbml/src/sbml/math-legacy/MathML.cpp trunk/libsbml/src/sbml/packages/comp/extension/CompSBasePlugin.cpp trunk/libsbml/src/sbml/packages/comp/sbml/CompBase.cpp trunk/libsbml/src/sbml/packages/comp/sbml/ListOfDeletions.cpp trunk/libsbml/src/sbml/packages/comp/sbml/ListOfPorts.cpp trunk/libsbml/src/sbml/packages/comp/sbml/ListOfSubmodels.cpp trunk/libsbml/src/sbml/packages/comp/util/CompFlatteningConverter.cpp trunk/libsbml/src/sbml/packages/comp/util/SBMLFileResolver.cpp trunk/libsbml/src/sbml/packages/comp/util/SBMLResolver.cpp trunk/libsbml/src/sbml/packages/comp/util/SBMLUri.cpp trunk/libsbml/src/sbml/packages/comp/validator/CompValidator.cpp trunk/libsbml/src/sbml/packages/fbc/util/CobraToFbcConverter.cpp trunk/libsbml/src/sbml/packages/fbc/util/FbcToCobraConverter.cpp trunk/libsbml/src/sbml/packages/fbc/validator/FbcValidator.cpp trunk/libsbml/src/sbml/packages/layout/sbml/GraphicalObject.cpp trunk/libsbml/src/sbml/packages/layout/sbml/Layout.cpp trunk/libsbml/src/sbml/packages/layout/validator/LayoutValidator.cpp trunk/libsbml/src/sbml/packages/qual/sbml/DefaultTerm.cpp trunk/libsbml/src/sbml/packages/qual/sbml/FunctionTerm.cpp trunk/libsbml/src/sbml/packages/qual/sbml/Input.cpp trunk/libsbml/src/sbml/packages/qual/sbml/Output.cpp trunk/libsbml/src/sbml/packages/qual/sbml/QualitativeSpecies.cpp trunk/libsbml/src/sbml/packages/qual/sbml/Transition.cpp trunk/libsbml/src/sbml/packages/qual/validator/QualValidator.cpp trunk/libsbml/src/sbml/packages/qual/validator/constraints/QualCSymbolMathCheck.cpp trunk/libsbml/src/sbml/test/TestSBMLConstructorException.cpp trunk/libsbml/src/sbml/units/FormulaUnitsData.cpp trunk/libsbml/src/sbml/util/ElementFilter.h trunk/libsbml/src/sbml/util/IdList.cpp trunk/libsbml/src/sbml/validator/SBMLValidator.cpp trunk/libsbml/src/sbml/validator/VConstraint.cpp trunk/libsbml/src/sbml/validator/Validator.cpp trunk/libsbml/src/sbml/validator/constraints/CiElementMathCheck.cpp trunk/libsbml/src/sbml/validator/constraints/CiElementNot0DComp.cpp trunk/libsbml/src/sbml/validator/constraints/EqualityArgsMathCheck.cpp trunk/libsbml/src/sbml/validator/constraints/FunctionApplyMathCheck.cpp trunk/libsbml/src/sbml/validator/constraints/FunctionNoArgsMathCheck.cpp trunk/libsbml/src/sbml/validator/constraints/LambdaMathCheck.cpp trunk/libsbml/src/sbml/validator/constraints/LocalParameterMathCheck.cpp trunk/libsbml/src/sbml/validator/constraints/LogicalArgsMathCheck.cpp trunk/libsbml/src/sbml/validator/constraints/NumberArgsMathCheck.cpp trunk/libsbml/src/sbml/validator/constraints/NumericArgsMathCheck.cpp trunk/libsbml/src/sbml/validator/constraints/NumericReturnMathCheck.cpp trunk/libsbml/src/sbml/validator/constraints/PieceBooleanMathCheck.cpp trunk/libsbml/src/sbml/validator/constraints/PiecewiseValueMathCheck.cpp trunk/libsbml/src/sbml/validator/constraints/ValidCnUnitsValue.cpp trunk/libsbml/src/sbml/xml/XMLAttributes.cpp trunk/libsbml/src/sbml/xml/XMLError.cpp trunk/libsbml/src/sbml/xml/XMLErrorLog.cpp trunk/libsbml/src/sbml/xml/XMLFileBuffer.cpp trunk/libsbml/src/sbml/xml/XMLNamespaces.cpp trunk/libsbml/src/sbml/xml/XMLNode.cpp trunk/libsbml/src/sbml/xml/XMLNode.h trunk/libsbml/src/sbml/xml/XMLOutputStream.cpp trunk/libsbml/src/sbml/xml/XMLToken.cpp trunk/libsbml/src/sbml/xml/XMLTokenizer.cpp trunk/libsbml/src/sbml/xml/XMLTriple.cpp trunk/libsbml/src/sbml/xml/test/TestXMLExceptions.cpp Modified: trunk/libsbml/src/sbml/Compartment.cpp =================================================================== --- trunk/libsbml/src/sbml/Compartment.cpp 2015-05-20 10:21:59 UTC (rev 22269) +++ trunk/libsbml/src/sbml/Compartment.cpp 2015-05-28 08:08:59 UTC (rev 22270) @@ -143,12 +143,7 @@ Compartment::Compartment(const Compartment& orig) : SBase ( orig ) { - if (&orig == NULL) { - throw SBMLConstructorException("Null argument to copy constructor"); - } - else - { mSpatialDimensions = orig.mSpatialDimensions; mSpatialDimensionsDouble = orig.mSpatialDimensionsDouble; mSize = orig.mSize; @@ -172,12 +167,8 @@ */ Compartment& Compartment::operator=(const Compartment& rhs) { - if (&rhs == NULL) + if(&rhs!=this) { - throw SBMLConstructorException("Null argument to assignment operator"); - } - else if(&rhs!=this) - { this->SBase::operator =(rhs); mSpatialDimensions= rhs.mSpatialDimensions ; mSpatialDimensionsDouble= rhs.mSpatialDimensionsDouble ; @@ -497,14 +488,10 @@ return LIBSBML_UNEXPECTED_ATTRIBUTE; } */ - if (&(sid) == NULL) + if (!(SyntaxChecker::isValidInternalSId(sid))) { return LIBSBML_INVALID_ATTRIBUTE_VALUE; } - else if (!(SyntaxChecker::isValidInternalSId(sid))) - { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } else { mId = sid; @@ -522,12 +509,8 @@ /* if this is setting an L2 name the type is string * whereas if it is setting an L1 name its type is SId */ - if (&(name) == NULL) + if (getLevel() == 1) { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } - else if (getLevel() == 1) - { if (!(SyntaxChecker::isValidInternalSId(name))) { return LIBSBML_INVALID_ATTRIBUTE_VALUE; @@ -552,11 +535,7 @@ int Compartment::setCompartmentType (const std::string& sid) { - if (&(sid) == NULL) - { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } - else if ( (getLevel() < 2) + if ( (getLevel() < 2) || (getLevel() == 2 && getVersion() == 1)) { return LIBSBML_UNEXPECTED_ATTRIBUTE; @@ -674,14 +653,10 @@ int Compartment::setUnits (const std::string& sid) { - if (&(sid) == NULL) + if (!(SyntaxChecker::isValidInternalUnitSId(sid))) { return LIBSBML_INVALID_ATTRIBUTE_VALUE; } - else if (!(SyntaxChecker::isValidInternalUnitSId(sid))) - { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } else { mUnits = sid; @@ -696,14 +671,10 @@ int Compartment::setOutside (const std::string& sid) { - if (&(sid) == NULL) + if (!(SyntaxChecker::isValidInternalSId(sid))) { return LIBSBML_INVALID_ATTRIBUTE_VALUE; } - else if (!(SyntaxChecker::isValidInternalSId(sid))) - { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } else { mOutside = sid; @@ -1570,12 +1541,7 @@ { vector<SBase*>::const_iterator result; - if (&(sid) == NULL) { - return NULL; - } - else - { result = find_if( mItems.begin(), mItems.end(), IdEq<Compartment>(sid) ); return (result == mItems.end()) ? NULL : static_cast <Compartment*> (*result); @@ -1598,15 +1564,12 @@ SBase* item = NULL; vector<SBase*>::iterator result; - if (&(sid) != NULL) + result = find_if( mItems.begin(), mItems.end(), IdEq<Compartment>(sid) ); + + if (result != mItems.end()) { - result = find_if( mItems.begin(), mItems.end(), IdEq<Compartment>(sid) ); - - if (result != mItems.end()) - { - item = *result; - mItems.erase(result); - } + item = *result; + mItems.erase(result); } return static_cast <Compartment*> (item); Modified: trunk/libsbml/src/sbml/CompartmentType.cpp =================================================================== --- trunk/libsbml/src/sbml/CompartmentType.cpp 2015-05-20 10:21:59 UTC (rev 22269) +++ trunk/libsbml/src/sbml/CompartmentType.cpp 2015-05-28 08:08:59 UTC (rev 22270) @@ -86,19 +86,11 @@ /* * Copy constructor. Creates a copy of this CompartmentType. */ -CompartmentType::CompartmentType(const CompartmentType& orig) : - SBase ( orig ) +CompartmentType::CompartmentType(const CompartmentType& orig) + : SBase ( orig ) + , mId (orig.mId) + , mName (orig.mName) { - if (&orig == NULL) - { - throw SBMLConstructorException("Null argument to copy constructor"); - } - else - { - mId = orig.mId; - mName = orig.mName; - } - } @@ -107,12 +99,8 @@ */ CompartmentType& CompartmentType::operator=(const CompartmentType& rhs) { - if (&rhs == NULL) + if(&rhs!=this) { - throw SBMLConstructorException("Null argument to assignment operator"); - } - else if(&rhs!=this) - { this->SBase::operator =(rhs); mId = rhs.mId; mName = rhs.mName; @@ -204,14 +192,10 @@ return LIBSBML_UNEXPECTED_ATTRIBUTE; } */ - if (&(sid) == NULL) + if (!(SyntaxChecker::isValidInternalSId(sid))) { return LIBSBML_INVALID_ATTRIBUTE_VALUE; } - else if (!(SyntaxChecker::isValidInternalSId(sid))) - { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } else { mId = sid; @@ -229,12 +213,8 @@ /* if this is setting an L2 name the type is string * whereas if it is setting an L1 name its type is SId */ - if (&(name) == NULL) + if (getLevel() == 1) { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } - else if (getLevel() == 1) - { if (!(SyntaxChecker::isValidInternalSId(name))) { return LIBSBML_INVALID_ATTRIBUTE_VALUE; @@ -566,16 +546,9 @@ { vector<SBase*>::const_iterator result; - if (&(sid) == NULL) - { - return NULL; - } - else - { - result = find_if( mItems.begin(), mItems.end(), IdEqCT(sid) ); - return (result == mItems.end()) ? NULL : - static_cast <CompartmentType*> (*result); - } + result = find_if( mItems.begin(), mItems.end(), IdEqCT(sid) ); + return (result == mItems.end()) ? NULL : + static_cast <CompartmentType*> (*result); } @@ -594,15 +567,12 @@ SBase* item = NULL; vector<SBase*>::iterator result; - if (&(sid) != NULL) + result = find_if( mItems.begin(), mItems.end(), IdEqCT(sid) ); + + if (result != mItems.end()) { - result = find_if( mItems.begin(), mItems.end(), IdEqCT(sid) ); - - if (result != mItems.end()) - { - item = *result; - mItems.erase(result); - } + item = *result; + mItems.erase(result); } return static_cast <CompartmentType*> (item); Modified: trunk/libsbml/src/sbml/Constraint.cpp =================================================================== --- trunk/libsbml/src/sbml/Constraint.cpp 2015-05-20 10:21:59 UTC (rev 22269) +++ trunk/libsbml/src/sbml/Constraint.cpp 2015-05-28 08:08:59 UTC (rev 22270) @@ -98,19 +98,13 @@ , mMath ( NULL ) , mMessage( NULL ) { - if (&orig == NULL) + if (orig.mMath != NULL) { - throw SBMLConstructorException("Null argument to copy constructor"); + mMath = orig.mMath->deepCopy(); + mMath->setParentSBMLObject(this); } - else - { - if (orig.mMath != NULL) - { - mMath = orig.mMath->deepCopy(); - mMath->setParentSBMLObject(this); - } - if (orig.mMessage != NULL) mMessage = new XMLNode(*orig.mMessage); - } + if (orig.mMessage != NULL) mMessage = new XMLNode(*orig.mMessage); + } @@ -119,12 +113,8 @@ */ Constraint& Constraint::operator=(const Constraint& rhs) { - if (&rhs == NULL) + if(&rhs!=this) { - throw SBMLConstructorException("Null argument to assignment operator"); - } - else if(&rhs!=this) - { this->SBase::operator =(rhs); delete mMath; @@ -297,12 +287,8 @@ bool addXHTMLMarkup) { int success = LIBSBML_OPERATION_FAILED; - if (&(message) == NULL) + if (message.empty()) { - success = LIBSBML_INVALID_ATTRIBUTE_VALUE; - } - else if (message.empty()) - { success = unsetMessage(); } else Modified: trunk/libsbml/src/sbml/Delay.cpp =================================================================== --- trunk/libsbml/src/sbml/Delay.cpp 2015-05-20 10:21:59 UTC (rev 22269) +++ trunk/libsbml/src/sbml/Delay.cpp 2015-05-28 08:08:59 UTC (rev 22270) @@ -93,24 +93,18 @@ /* * Copy constructor. Creates a copy of this Delay. */ -Delay::Delay (const Delay& orig) : - SBase ( orig ) - , mMath ( NULL ) +Delay::Delay (const Delay& orig) + : SBase ( orig ) + , mMath ( NULL ) + , mInternalId ( orig.mInternalId ) { - if (&orig == NULL) + + if (orig.mMath != NULL) { - throw SBMLConstructorException("Null argument to copy constructor"); + mMath = orig.mMath->deepCopy(); + mMath->setParentSBMLObject(this); } - else - { - mInternalId = orig.mInternalId; - - if (orig.mMath != NULL) - { - mMath = orig.mMath->deepCopy(); - mMath->setParentSBMLObject(this); - } - } + } @@ -119,12 +113,8 @@ */ Delay& Delay::operator=(const Delay& rhs) { - if (&rhs == NULL) + if(&rhs!=this) { - throw SBMLConstructorException("Null argument to assignment operator"); - } - else if(&rhs!=this) - { this->SBase::operator =(rhs); this->mInternalId = rhs.mInternalId; Modified: trunk/libsbml/src/sbml/Event.cpp =================================================================== --- trunk/libsbml/src/sbml/Event.cpp 2015-05-20 10:21:59 UTC (rev 22269) +++ trunk/libsbml/src/sbml/Event.cpp 2015-05-28 08:08:59 UTC (rev 22270) @@ -125,40 +125,36 @@ * Copy constructor. Creates a copy of this Event. */ Event::Event (const Event& orig) : - SBase ( orig ) - , mTrigger ( NULL ) - , mDelay ( NULL ) - , mPriority ( NULL ) - , mEventAssignments ( orig.mEventAssignments ) + SBase ( orig ) + , mId ( orig.mId ) + , mName ( orig.mName ) + , mTrigger ( NULL ) + , mDelay ( NULL ) + , mPriority ( NULL ) + , mTimeUnits ( orig.mTimeUnits ) + , mUseValuesFromTriggerTime ( orig.mUseValuesFromTriggerTime ) + , mIsSetUseValuesFromTriggerTime ( orig.mIsSetUseValuesFromTriggerTime ) + , mInternalIdOnly ( orig.mInternalIdOnly ) + , mExplicitlySetUVFTT ( orig.mExplicitlySetUVFTT ) + , mEventAssignments ( orig.mEventAssignments ) { - if (&orig == NULL) + + if (orig.mTrigger != NULL) { - throw SBMLConstructorException("Null argument to copy constructor"); + mTrigger = new Trigger(*orig.getTrigger()); } - else + + if (orig.mDelay != NULL) { - mId = orig.mId; - mName = orig.mName; - mTimeUnits = orig.mTimeUnits; - mUseValuesFromTriggerTime = orig.mUseValuesFromTriggerTime ; - mIsSetUseValuesFromTriggerTime = orig.mIsSetUseValuesFromTriggerTime ; - mExplicitlySetUVFTT = orig.mExplicitlySetUVFTT; - mInternalIdOnly = orig.mInternalIdOnly; - - if (orig.mTrigger != NULL) - { - mTrigger = new Trigger(*orig.getTrigger()); - } - if (orig.mDelay != NULL) - { - mDelay = new Delay(*orig.getDelay()); - } - if (orig.mPriority != NULL) - { - mPriority = new Priority(*orig.getPriority()); - } + mDelay = new Delay(*orig.getDelay()); } + if (orig.mPriority != NULL) + { + mPriority = new Priority(*orig.getPriority()); + } + + connectToChild(); } @@ -168,12 +164,8 @@ */ Event& Event::operator=(const Event& rhs) { - if (&rhs == NULL) + if(&rhs!=this) { - throw SBMLConstructorException("Null argument to assignment operator"); - } - else if(&rhs!=this) - { this->SBase::operator =(rhs); mId = rhs.mId; @@ -535,14 +527,10 @@ return LIBSBML_UNEXPECTED_ATTRIBUTE; } */ - if (&(sid) == NULL) + if (!(SyntaxChecker::isValidInternalSId(sid))) { return LIBSBML_INVALID_ATTRIBUTE_VALUE; } - else if (!(SyntaxChecker::isValidInternalSId(sid))) - { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } else { mId = sid; @@ -561,12 +549,8 @@ /* if this is setting an L2 name the type is string * whereas if it is setting an L1 name its type is SId */ - if (&(name) == NULL) + if (getLevel() == 1) { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } - else if (getLevel() == 1) - { if (!(SyntaxChecker::isValidInternalSId(name))) { return LIBSBML_INVALID_ATTRIBUTE_VALUE; @@ -709,12 +693,8 @@ int Event::setTimeUnits (const std::string& sid) { - if (&(sid) == NULL) + if (getLevel() == 2 && getVersion() > 2) { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } - else if (getLevel() == 2 && getVersion() > 2) - { return LIBSBML_UNEXPECTED_ATTRIBUTE; } else if (!(SyntaxChecker::isValidInternalSId(sid))) @@ -1108,8 +1088,7 @@ const EventAssignment* Event::getEventAssignment (const std::string& variable) const { - return (&variable != NULL ) ? - static_cast<const EventAssignment*>( mEventAssignments.get(variable) ) : NULL; + return static_cast<const EventAssignment*>( mEventAssignments.get(variable) ); } @@ -1120,8 +1099,7 @@ EventAssignment* Event::getEventAssignment (const std::string& variable) { - return (&variable != NULL ) ? - static_cast<EventAssignment*>( mEventAssignments.get(variable) ) : NULL; + return static_cast<EventAssignment*>( mEventAssignments.get(variable) ); } @@ -1153,7 +1131,7 @@ EventAssignment* Event::removeEventAssignment (const std::string& variable) { - return (&variable != NULL) ? mEventAssignments.remove(variable) : NULL; + return mEventAssignments.remove(variable); } @@ -1786,8 +1764,8 @@ Event* ListOfEvents::get (const std::string& sid) { - return (&sid != NULL) ? const_cast<Event*>( - static_cast<const ListOfEvents&>(*this).get(sid) ) : NULL; + return const_cast<Event*>( + static_cast<const ListOfEvents&>(*this).get(sid) ); } @@ -1795,7 +1773,6 @@ const Event* ListOfEvents::get (const std::string& sid) const { - if (&sid == NULL) return NULL; vector<SBase*>::const_iterator result; result = find_if( mItems.begin(), mItems.end(), IdEqE(sid) ); @@ -1818,15 +1795,12 @@ SBase* item = NULL; vector<SBase*>::iterator result; - if (&(sid) != NULL) + result = find_if( mItems.begin(), mItems.end(), IdEqE(sid) ); + + if (result != mItems.end()) { - result = find_if( mItems.begin(), mItems.end(), IdEqE(sid) ); - - if (result != mItems.end()) - { - item = *result; - mItems.erase(result); - } + item = *result; + mItems.erase(result); } return static_cast <Event*> (item); Modified: trunk/libsbml/src/sbml/EventAssignment.cpp =================================================================== --- trunk/libsbml/src/sbml/EventAssignment.cpp 2015-05-20 10:21:59 UTC (rev 22269) +++ trunk/libsbml/src/sbml/EventAssignment.cpp 2015-05-28 08:08:59 UTC (rev 22270) @@ -94,23 +94,16 @@ * Copy constructor. Creates a copy of this EventAssignment. */ EventAssignment::EventAssignment (const EventAssignment& orig) : - SBase ( orig ) - , mMath ( NULL ) + SBase ( orig ) + , mVariable ( orig.mVariable ) + , mMath ( NULL ) { - if (&orig == NULL) + if (orig.mMath != NULL) { - throw SBMLConstructorException("Null argument to copy constructor"); + mMath = orig.mMath->deepCopy(); + mMath->setParentSBMLObject(this); } - else - { - mVariable = orig.mVariable; - - if (orig.mMath != NULL) - { - mMath = orig.mMath->deepCopy(); - mMath->setParentSBMLObject(this); - } - } + } @@ -119,12 +112,8 @@ */ EventAssignment& EventAssignment::operator=(const EventAssignment& rhs) { - if (&rhs == NULL) + if(&rhs!=this) { - throw SBMLConstructorException("Null argument to assignment operator"); - } - else if(&rhs!=this) - { this->SBase::operator =(rhs); this->mVariable = rhs.mVariable; @@ -216,14 +205,10 @@ int EventAssignment::setVariable (const std::string& sid) { - if (&(sid) == NULL) + if (!(SyntaxChecker::isValidInternalSId(sid))) { return LIBSBML_INVALID_ATTRIBUTE_VALUE; } - else if (!(SyntaxChecker::isValidInternalSId(sid))) - { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } else { mVariable = sid; @@ -885,16 +870,9 @@ { vector<SBase*>::const_iterator result; - if (&(sid) == NULL) - { - return NULL; - } - else - { - result = find_if( mItems.begin(), mItems.end(), IdEqEA(sid) ); - return (result == mItems.end()) ? NULL : - static_cast <EventAssignment*> (*result); - } + result = find_if( mItems.begin(), mItems.end(), IdEqEA(sid) ); + return (result == mItems.end()) ? NULL : + static_cast <EventAssignment*> (*result); } @@ -913,15 +891,12 @@ SBase* item = NULL; vector<SBase*>::iterator result; - if (&(sid) != NULL) + result = find_if( mItems.begin(), mItems.end(), IdEqEA(sid) ); + + if (result != mItems.end()) { - result = find_if( mItems.begin(), mItems.end(), IdEqEA(sid) ); - - if (result != mItems.end()) - { - item = *result; - mItems.erase(result); - } + item = *result; + mItems.erase(result); } return static_cast <EventAssignment*> (item); Modified: trunk/libsbml/src/sbml/FunctionDefinition.cpp =================================================================== --- trunk/libsbml/src/sbml/FunctionDefinition.cpp 2015-05-20 10:21:59 UTC (rev 22269) +++ trunk/libsbml/src/sbml/FunctionDefinition.cpp 2015-05-28 08:08:59 UTC (rev 22270) @@ -97,23 +97,17 @@ */ FunctionDefinition::FunctionDefinition (const FunctionDefinition& orig) : SBase ( orig ) - , mMath ( NULL ) + , mId ( orig.mId ) + , mName ( orig.mName ) + , mMath ( NULL ) { - if (&orig == NULL) + + if (orig.mMath != NULL) { - throw SBMLConstructorException("Null argument to copy constructor"); + mMath = orig.mMath->deepCopy(); + mMath->setParentSBMLObject(this); } - else - { - mId = orig.mId; - mName = orig.mName; - if (orig.mMath != NULL) - { - mMath = orig.mMath->deepCopy(); - mMath->setParentSBMLObject(this); - } - } } @@ -122,12 +116,8 @@ */ FunctionDefinition& FunctionDefinition::operator=(const FunctionDefinition& rhs) { - if (&rhs == NULL) + if(&rhs!=this) { - throw SBMLConstructorException("Null argument to assignment operator"); - } - else if(&rhs!=this) - { this->SBase::operator =(rhs); mId = rhs.mId; mName = rhs.mName; @@ -250,14 +240,10 @@ return LIBSBML_UNEXPECTED_ATTRIBUTE; } */ - if (&(sid) == NULL) + if (!(SyntaxChecker::isValidInternalSId(sid))) { return LIBSBML_INVALID_ATTRIBUTE_VALUE; } - else if (!(SyntaxChecker::isValidInternalSId(sid))) - { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } else { mId = sid; @@ -275,12 +261,8 @@ /* if this is setting an L2 name the type is string * whereas if it is setting an L1 name its type is SId */ - if (&(name) == NULL) + if (getLevel() == 1) { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } - else if (getLevel() == 1) - { if (!(SyntaxChecker::isValidInternalSId(name))) { return LIBSBML_INVALID_ATTRIBUTE_VALUE; @@ -1020,16 +1002,10 @@ { vector<SBase*>::const_iterator result; - if (&(sid) == NULL) - { - return NULL; - } - else - { - result = find_if( mItems.begin(), mItems.end(), IdEqFD(sid) ); - return (result == mItems.end()) ? NULL : - static_cast <FunctionDefinition*> (*result); - } + result = find_if( mItems.begin(), mItems.end(), IdEqFD(sid) ); + return (result == mItems.end()) ? NULL : + static_cast <FunctionDefinition*> (*result); + } @@ -1048,15 +1024,12 @@ SBase* item = NULL; vector<SBase*>::iterator result; - if (&(sid) != NULL) + result = find_if( mItems.begin(), mItems.end(), IdEqFD(sid) ); + + if (result != mItems.end()) { - result = find_if( mItems.begin(), mItems.end(), IdEqFD(sid) ); - - if (result != mItems.end()) - { - item = *result; - mItems.erase(result); - } + item = *result; + mItems.erase(result); } return static_cast <FunctionDefinition*> (item); Modified: trunk/libsbml/src/sbml/InitialAssignment.cpp =================================================================== --- trunk/libsbml/src/sbml/InitialAssignment.cpp 2015-05-20 10:21:59 UTC (rev 22269) +++ trunk/libsbml/src/sbml/InitialAssignment.cpp 2015-05-28 08:08:59 UTC (rev 22270) @@ -92,22 +92,15 @@ */ InitialAssignment::InitialAssignment (const InitialAssignment& orig) : SBase ( orig ) + , mSymbol ( orig.mSymbol) , mMath ( NULL ) { - if (&orig == NULL) + if (orig.mMath != NULL) { - throw SBMLConstructorException("Null argument to copy constructor"); + mMath = orig.mMath->deepCopy(); + mMath->setParentSBMLObject(this); } - else - { - mSymbol = orig.mSymbol; - - if (orig.mMath != NULL) - { - mMath = orig.mMath->deepCopy(); - mMath->setParentSBMLObject(this); - } - } + } @@ -116,15 +109,10 @@ */ InitialAssignment& InitialAssignment::operator=(const InitialAssignment& rhs) { - if (&rhs == NULL) + if(&rhs!=this) { - throw SBMLConstructorException("Null argument to assignment operator"); - } - else if(&rhs!=this) - { this->SBase::operator =(rhs); this->mSymbol = rhs.mSymbol; - delete mMath; if (rhs.mMath != NULL) { @@ -229,14 +217,10 @@ int InitialAssignment::setSymbol (const std::string& sid) { - if (&(sid) == NULL) + if (!(SyntaxChecker::isValidInternalSId(sid))) { return LIBSBML_INVALID_ATTRIBUTE_VALUE; } - else if (!(SyntaxChecker::isValidInternalSId(sid))) - { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } else { mSymbol = sid; @@ -883,16 +867,10 @@ { vector<SBase*>::const_iterator result; - if (&(sid) == NULL) - { - return NULL; - } - else - { - result = find_if( mItems.begin(), mItems.end(), IdEqIA(sid) ); - return (result == mItems.end()) ? NULL : - static_cast <InitialAssignment*> (*result); - } + result = find_if( mItems.begin(), mItems.end(), IdEqIA(sid) ); + return (result == mItems.end()) ? NULL : + static_cast <InitialAssignment*> (*result); + } @@ -911,15 +889,12 @@ SBase* item = NULL; vector<SBase*>::iterator result; - if (&(sid) != NULL) + result = find_if( mItems.begin(), mItems.end(), IdEqIA(sid) ); + + if (result != mItems.end()) { - result = find_if( mItems.begin(), mItems.end(), IdEqIA(sid) ); - - if (result != mItems.end()) - { - item = *result; - mItems.erase(result); - } + item = *result; + mItems.erase(result); } return static_cast <InitialAssignment*> (item); Modified: trunk/libsbml/src/sbml/KineticLaw.cpp =================================================================== --- trunk/libsbml/src/sbml/KineticLaw.cpp 2015-05-20 10:21:59 UTC (rev 22269) +++ trunk/libsbml/src/sbml/KineticLaw.cpp 2015-05-28 08:08:59 UTC (rev 22270) @@ -109,28 +109,22 @@ * Copy constructor. Creates a copy of this KineticLaw. */ KineticLaw::KineticLaw (const KineticLaw& orig) : - SBase ( orig ) - , mMath ( NULL ) - , mParameters ( orig.mParameters ) - , mLocalParameters ( orig.mLocalParameters ) + SBase ( orig ) + , mFormula ( orig.mFormula ) + , mMath ( NULL ) + , mParameters ( orig.mParameters ) + , mLocalParameters ( orig.mLocalParameters ) + , mTimeUnits ( orig.mTimeUnits ) + , mSubstanceUnits ( orig.mSubstanceUnits ) + , mInternalId ( orig.mInternalId ) { - if (&orig == NULL) + + if (orig.mMath != NULL) { - throw SBMLConstructorException("Null argument to copy constructor"); + mMath = orig.mMath->deepCopy(); + mMath->setParentSBMLObject(this); } - else - { - mFormula = orig.mFormula; - mTimeUnits = orig.mTimeUnits; - mSubstanceUnits = orig.mSubstanceUnits; - mInternalId = orig.mInternalId; - - if (orig.mMath != NULL) - { - mMath = orig.mMath->deepCopy(); - mMath->setParentSBMLObject(this); - } - } + connectToChild(); } @@ -140,12 +134,8 @@ */ KineticLaw& KineticLaw::operator=(const KineticLaw& rhs) { - if (&rhs == NULL) + if(&rhs!=this) { - throw SBMLConstructorException("Null argument to assignment operator"); - } - else if(&rhs!=this) - { this->SBase::operator =(rhs); mFormula = rhs.mFormula ; mTimeUnits = rhs.mTimeUnits ; @@ -360,38 +350,32 @@ int KineticLaw::setFormula (const std::string& formula) { - if (&(formula) == NULL) + if (formula == "") { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; + mFormula.erase(); + delete mMath; + mMath = NULL; + return LIBSBML_OPERATION_SUCCESS; } + ASTNode * math = SBML_parseFormula(formula.c_str()); + if (math == NULL || !(math->isWellFormedASTNode())) + { + delete math; + return LIBSBML_INVALID_OBJECT; + } else { - if (formula == "") + mFormula = formula; + + if (mMath != NULL) { - mFormula.erase(); delete mMath; mMath = NULL; - return LIBSBML_OPERATION_SUCCESS; } - ASTNode * math = SBML_parseFormula(formula.c_str()); - if (math == NULL || !(math->isWellFormedASTNode())) - { - delete math; - return LIBSBML_INVALID_OBJECT; - } - else - { - mFormula = formula; - - if (mMath != NULL) - { - delete mMath; - mMath = NULL; - } - delete math; - return LIBSBML_OPERATION_SUCCESS; - } + delete math; + return LIBSBML_OPERATION_SUCCESS; } + } @@ -434,11 +418,7 @@ KineticLaw::setTimeUnits (const std::string& sid) { /* only in L1 and L2V1 */ - if (&(sid) == NULL) - { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } - else if ((getLevel() == 2 && getVersion() > 1) + if ((getLevel() == 2 && getVersion() > 1) || getLevel() > 2) { return LIBSBML_UNEXPECTED_ATTRIBUTE; @@ -462,11 +442,7 @@ KineticLaw::setSubstanceUnits (const std::string& sid) { /* only in L1 and L2V1 */ - if (&(sid) == NULL) - { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } - else if ((getLevel() == 2 && getVersion() > 1) + if ((getLevel() == 2 && getVersion() > 1) || getLevel() > 2) { return LIBSBML_UNEXPECTED_ATTRIBUTE; @@ -1031,7 +1007,7 @@ Parameter* KineticLaw::removeParameter (const std::string& sid) { - return (&sid != NULL) ? mParameters.remove(sid) : NULL; + return mParameters.remove(sid); } @@ -1042,7 +1018,7 @@ LocalParameter* KineticLaw::removeLocalParameter (const std::string& sid) { - return (&sid != NULL) ? mLocalParameters.remove(sid) : NULL; + return mLocalParameters.remove(sid); } Modified: trunk/libsbml/src/sbml/LocalParameter.cpp =================================================================== --- trunk/libsbml/src/sbml/LocalParameter.cpp 2015-05-20 10:21:59 UTC (rev 22269) +++ trunk/libsbml/src/sbml/LocalParameter.cpp 2015-05-28 08:08:59 UTC (rev 22270) @@ -100,10 +100,6 @@ LocalParameter::LocalParameter(const LocalParameter& orig) : Parameter ( orig ) { - if (&orig == NULL) - { - throw SBMLConstructorException("Null argument to copy constructor"); - } } @@ -112,23 +108,15 @@ */ LocalParameter::LocalParameter(const Parameter& orig) : Parameter ( orig ) -{ - if (&orig == NULL) - { - throw SBMLConstructorException("Null argument to copy constructor"); - } +{ } /* * Assignment operator. */ LocalParameter& LocalParameter::operator=(const LocalParameter& rhs) { - if (&rhs == NULL) + if(&rhs!=this) { - throw SBMLConstructorException("Null argument to assignment operator"); - } - else if(&rhs!=this) - { this->Parameter::operator =(rhs); } @@ -415,16 +403,10 @@ { vector<SBase*>::const_iterator result; - if (&(sid) == NULL) - { - return NULL; - } - else - { - result = find_if( mItems.begin(), mItems.end(), IdEqP(sid) ); - return (result == mItems.end()) ? NULL : - static_cast <LocalParameter*> (*result); - } + result = find_if( mItems.begin(), mItems.end(), IdEqP(sid) ); + return (result == mItems.end()) ? NULL : + static_cast <LocalParameter*> (*result); + } @@ -457,15 +439,12 @@ SBase* item = NULL; vector<SBase*>::iterator result; - if (&(sid) != NULL) + result = find_if( mItems.begin(), mItems.end(), IdEqP(sid) ); + + if (result != mItems.end()) { - result = find_if( mItems.begin(), mItems.end(), IdEqP(sid) ); - - if (result != mItems.end()) - { - item = *result; - mItems.erase(result); - } + item = *result; + mItems.erase(result); } return static_cast <LocalParameter*> (item); Modified: trunk/libsbml/src/sbml/Model.cpp =================================================================== --- trunk/libsbml/src/sbml/Model.cpp 2015-05-20 10:21:59 UTC (rev 22269) +++ trunk/libsbml/src/sbml/Model.cpp 2015-05-28 08:08:59 UTC (rev 22270) @@ -157,53 +157,44 @@ /* * Copy constructor. */ -Model::Model(const Model& orig) : - SBase (orig ) - , mFunctionDefinitions (orig.mFunctionDefinitions) - , mUnitDefinitions (orig.mUnitDefinitions) - , mCompartmentTypes (orig.mCompartmentTypes) - , mSpeciesTypes (orig.mSpeciesTypes) - , mCompartments (orig.mCompartments) - , mSpecies (orig.mSpecies) - , mParameters (orig.mParameters) - , mInitialAssignments (orig.mInitialAssignments) - , mRules (orig.mRules) - , mConstraints (orig.mConstraints) - , mReactions (orig.mReactions) - , mEvents (orig.mEvents) +Model::Model(const Model& orig) + : SBase (orig) + , mId (orig.mId) + , mName (orig.mName) + , mSubstanceUnits (orig.mSubstanceUnits) + , mTimeUnits (orig.mTimeUnits) + , mVolumeUnits (orig.mVolumeUnits) + , mAreaUnits (orig.mAreaUnits) + , mLengthUnits (orig.mLengthUnits) + , mExtentUnits (orig.mExtentUnits) + , mConversionFactor (orig.mConversionFactor) + , mFunctionDefinitions (orig.mFunctionDefinitions) + , mUnitDefinitions (orig.mUnitDefinitions) + , mCompartmentTypes (orig.mCompartmentTypes) + , mSpeciesTypes (orig.mSpeciesTypes) + , mCompartments (orig.mCompartments) + , mSpecies (orig.mSpecies) + , mParameters (orig.mParameters) + , mInitialAssignments (orig.mInitialAssignments) + , mRules (orig.mRules) + , mConstraints (orig.mConstraints) + , mReactions (orig.mReactions) + , mEvents (orig.mEvents) + , mFormulaUnitsData (NULL) { - if (&orig == NULL) + + if(orig.mFormulaUnitsData != NULL) { - throw SBMLConstructorException("Null argument to copy constructor"); - } - else - { - mId = orig.mId; - mName = orig.mName; - mSubstanceUnits = orig.mSubstanceUnits ; - mTimeUnits = orig.mTimeUnits ; - mVolumeUnits = orig.mVolumeUnits ; - mAreaUnits = orig.mAreaUnits ; - mLengthUnits = orig.mLengthUnits ; - mExtentUnits = orig.mExtentUnits ; - mConversionFactor = orig.mConversionFactor ; - - if(orig.mFormulaUnitsData != NULL) + this->mFormulaUnitsData = new List(); + unsigned int i,iMax = orig.mFormulaUnitsData->getSize(); + for(i = 0; i < iMax; ++i) { - this->mFormulaUnitsData = new List(); - unsigned int i,iMax = orig.mFormulaUnitsData->getSize(); - for(i = 0; i < iMax; ++i) - { - this->mFormulaUnitsData - ->add(static_cast<FormulaUnitsData*> - (orig.mFormulaUnitsData->get(i))->clone()); - } + this->mFormulaUnitsData + ->add(static_cast<FormulaUnitsData*> + (orig.mFormulaUnitsData->get(i))->clone()); } - else - { - this->mFormulaUnitsData = NULL; - } } + connectToChild(); } @@ -213,12 +204,8 @@ */ Model& Model::operator=(const Model& rhs) { - if (&rhs == NULL) + if(&rhs!=this) { - throw SBMLConstructorException("Null argument to assignment operator"); - } - else if(&rhs!=this) - { this->SBase::operator = (rhs); mId = rhs.mId; mName = rhs.mName; @@ -715,14 +702,10 @@ return LIBSBML_UNEXPECTED_ATTRIBUTE; } */ - if (&(sid) == NULL) + if (!(SyntaxChecker::isValidInternalSId(sid))) { return LIBSBML_INVALID_ATTRIBUTE_VALUE; } - else if (!(SyntaxChecker::isValidInternalSId(sid))) - { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } else { mId = sid; @@ -740,12 +723,8 @@ /* if this is setting an L2 name the type is string * whereas if it is setting an L1 name its type is SId */ - if (&(name) == NULL) + if (getLevel() == 1) { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } - else if (getLevel() == 1) - { if (!(SyntaxChecker::isValidInternalSId(name))) { return LIBSBML_INVALID_ATTRIBUTE_VALUE; @@ -770,12 +749,8 @@ int Model::setSubstanceUnits (const std::string& units) { - if (&(units) == NULL) + if (getLevel() < 3) { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } - else if (getLevel() < 3) - { return LIBSBML_UNEXPECTED_ATTRIBUTE; } else if (!(SyntaxChecker::isValidInternalUnitSId(units))) @@ -796,12 +771,8 @@ int Model::setTimeUnits (const std::string& units) { - if (&(units) == NULL) + if (getLevel() < 3) { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } - else if (getLevel() < 3) - { return LIBSBML_UNEXPECTED_ATTRIBUTE; } else if (!(SyntaxChecker::isValidInternalUnitSId(units))) @@ -822,12 +793,8 @@ int Model::setVolumeUnits (const std::string& units) { - if (&(units) == NULL) + if (getLevel() < 3) { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } - else if (getLevel() < 3) - { return LIBSBML_UNEXPECTED_ATTRIBUTE; } else if (!(SyntaxChecker::isValidInternalUnitSId(units))) @@ -848,12 +815,8 @@ int Model::setAreaUnits (const std::string& units) { - if (&(units) == NULL) + if (getLevel() < 3) { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } - else if (getLevel() < 3) - { return LIBSBML_UNEXPECTED_ATTRIBUTE; } else if (!(SyntaxChecker::isValidInternalUnitSId(units))) @@ -874,12 +837,8 @@ int Model::setLengthUnits (const std::string& units) { - if (&(units) == NULL) + if (getLevel() < 3) { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } - else if (getLevel() < 3) - { return LIBSBML_UNEXPECTED_ATTRIBUTE; } else if (!(SyntaxChecker::isValidInternalUnitSId(units))) @@ -900,12 +859,8 @@ int Model::setExtentUnits (const std::string& units) { - if (&(units) == NULL) + if (getLevel() < 3) { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } - else if (getLevel() < 3) - { return LIBSBML_UNEXPECTED_ATTRIBUTE; } else if (!(SyntaxChecker::isValidInternalUnitSId(units))) @@ -926,12 +881,8 @@ int Model::setConversionFactor (const std::string& id) { - if (&(id) == NULL) + if (getLevel() < 3) { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } - else if (getLevel() < 3) - { return LIBSBML_UNEXPECTED_ATTRIBUTE; } else if (!(SyntaxChecker::isValidInternalSId(id))) Modified: trunk/libsbml/src/sbml/Parameter.cpp =================================================================== --- trunk/libsbml/src/sbml/Parameter.cpp 2015-05-20 10:21:59 UTC (rev 22269) +++ trunk/libsbml/src/sbml/Parameter.cpp 2015-05-28 08:08:59 UTC (rev 22270) @@ -149,25 +149,19 @@ /* * Copy constructor. Creates a copy of this Parameter. */ -Parameter::Parameter(const Parameter& orig) : - SBase ( orig ) +Parameter::Parameter(const Parameter& orig) + : SBase ( orig ) + , mId (orig.mId) + , mName (orig.mName) + , mValue (orig.mValue) + , mUnits (orig.mUnits) + , mConstant (orig.mConstant) + , mIsSetValue (orig.mIsSetValue) + , mIsSetConstant (orig.mIsSetConstant) + , mExplicitlySetConstant (orig.mExplicitlySetConstant) + , mCalculatingUnits (false) // only set by units converter + { - if (&orig == NULL) - { - throw SBMLConstructorException("Null argument to copy constructor"); - } - else - { - mValue = orig.mValue ; - mUnits = orig.mUnits ; - mConstant = orig.mConstant ; - mIsSetValue = orig.mIsSetValue; - mId = orig.mId; - mName = orig.mName; - mIsSetConstant = orig.mIsSetConstant; - mExplicitlySetConstant = orig.mExplicitlySetConstant; - mCalculatingUnits = false; // only set by units converter - } } @@ -176,12 +170,8 @@ */ Parameter& Parameter::operator=(const Parameter& rhs) { - if (&rhs == NULL) + if(&rhs!=this) { - throw SBMLConstructorException("Null argument to assignment operator"); - } - else if(&rhs!=this) - { this->SBase::operator =(rhs); mValue = rhs.mValue ; mUnits = rhs.mUnits ; @@ -361,14 +351,10 @@ return LIBSBML_UNEXPECTED_ATTRIBUTE; } */ - if (&(sid) == NULL) + if (!(SyntaxChecker::isValidInternalSId(sid))) { return LIBSBML_INVALID_ATTRIBUTE_VALUE; } - else if (!(SyntaxChecker::isValidInternalSId(sid))) - { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } else { mId = sid; @@ -386,12 +372,8 @@ /* if this is setting an L2 name the type is string * whereas if it is setting an L1 name its type is SId */ - if (&(name) == NULL) + if (getLevel() == 1) { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } - else if (getLevel() == 1) - { if (!(SyntaxChecker::isValidInternalSId(name))) { return LIBSBML_INVALID_ATTRIBUTE_VALUE; @@ -428,14 +410,10 @@ int Parameter::setUnits (const std::string& units) { - if (&(units) == NULL) + if (!(SyntaxChecker::isValidInternalUnitSId(units))) { return LIBSBML_INVALID_ATTRIBUTE_VALUE; } - else if (!(SyntaxChecker::isValidInternalUnitSId(units))) - { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } else { mUnits = units; @@ -1578,15 +1556,8 @@ { vector<SBase*>::const_iterator result; - if (&(sid) == NULL) - { - return NULL; - } - else - { - result = find_if( mItems.begin(), mItems.end(), IdEqP(sid) ); - return (result == mItems.end()) ? NULL : static_cast <Parameter*> (*result); - } + result = find_if( mItems.begin(), mItems.end(), IdEqP(sid) ); + return (result == mItems.end()) ? NULL : static_cast <Parameter*> (*result); } @@ -1605,15 +1576,12 @@ SBase* item = NULL; vector<SBase*>::iterator result; - if (&(sid) != NULL) + result = find_if( mItems.begin(), mItems.end(), IdEqP(sid) ); + + if (result != mItems.end()) { - result = find_if( mItems.begin(), mItems.end(), IdEqP(sid) ); - - if (result != mItems.end()) - { - item = *result; - mItems.erase(result); - } + item = *result; + mItems.erase(result); } return static_cast <Parameter*> (item); Modified: trunk/libsbml/src/sbml/Priority.cpp =================================================================== --- trunk/libsbml/src/sbml/Priority.cpp 2015-05-20 10:21:59 UTC (rev 22269) +++ trunk/libsbml/src/sbml/Priority.cpp 2015-05-28 08:08:59 UTC (rev 22270) @@ -94,23 +94,15 @@ * Copy constructor. Creates a copy of this Priority. */ Priority::Priority (const Priority& orig) : - SBase ( orig ) - , mMath ( NULL ) + SBase ( orig ) + , mMath ( NULL ) + , mInternalId ( orig.mInternalId ) { - if (&orig == NULL) + if (orig.mMath != NULL) { - throw SBMLConstructorException("Null argument to copy constructor"); + mMath = orig.mMath->deepCopy(); + mMath->setParentSBMLObject(this); } - else - { - mInternalId = orig.mInternalId; - - if (orig.mMath != NULL) - { - mMath = orig.mMath->deepCopy(); - mMath->setParentSBMLObject(this); - } - } } @@ -119,12 +111,8 @@ */ Priority& Priority::operator=(const Priority& rhs) { - if (&rhs == NULL) + if(&rhs!=this) { - throw SBMLConstructorException("Null argument to assignment operator"); - } - else if(&rhs!=this) - { this->SBase::operator =(rhs); this->mInternalId = rhs.mInternalId; Modified: trunk/libsbml/src/sbml/Reaction.cpp =================================================================== --- trunk/libsbml/src/sbml/Reaction.cpp 2015-05-20 10:21:59 UTC (rev 22269) +++ trunk/libsbml/src/sbml/Reaction.cpp 2015-05-28 08:08:59 UTC (rev 22270) @@ -175,34 +175,26 @@ /* * Copy constructor. Creates a copy of this Reaction. */ -Reaction::Reaction (const Reaction& orig) : - SBase ( orig ) +Reaction::Reaction (const Reaction& orig) + : SBase ( orig ) + , mId ( orig.mId ) + , mName ( orig.mName ) , mReactants ( orig.mReactants ) , mProducts ( orig.mProducts ) , mModifiers ( orig.mModifiers ) , mKineticLaw( NULL ) -{ - if (&orig == NULL) + , mReversible( orig.mReversible ) + , mFast ( orig.mFast ) + , mIsSetFast ( orig.mIsSetFast ) + , mCompartment ( orig.mCompartment ) + , mIsSetReversible ( orig.mIsSetReversible ) + , mExplicitlySetReversible ( orig.mExplicitlySetReversible ) + , mExplicitlySetFast ( orig.mExplicitlySetFast ) +{ + if (orig.mKineticLaw != NULL) { - throw SBMLConstructorException("Null argument to copy constructor"); + mKineticLaw = static_cast<KineticLaw*>( orig.mKineticLaw->clone() ); } - else - { - mReversible = orig.mReversible ; - mFast = orig.mFast ; - mIsSetFast = orig.mIsSetFast ; - mId = orig.mId; - mName = orig.mName; - mCompartment = orig.mCompartment; - mIsSetReversible = orig.mIsSetReversible; - mExplicitlySetReversible = orig.mExplicitlySetReversible; - mExplicitlySetFast = orig.mExplicitlySetFast; - - if (orig.mKineticLaw != NULL) - { - mKineticLaw = static_cast<KineticLaw*>( orig.mKineticLaw->clone() ); - } - } connectToChild(); } @@ -212,12 +204,8 @@ */ Reaction& Reaction::operator=(const Reaction& rhs) { - if (&rhs == NULL) + if(&rhs!=this) { - throw SBMLConstructorException("Null argument to assignment operator"); - } - else if(&rhs!=this) - { this->SBase::operator =(rhs); mReversible = rhs.mReversible ; mFast = rhs.mFast ; @@ -546,14 +534,10 @@ return LIBSBML_UNEXPECTED_ATTRIBUTE; } */ - if (&(sid) == NULL) + if (!(SyntaxChecker::isValidInternalSId(sid))) { return LIBSBML_INVALID_ATTRIBUTE_VALUE; } - else if (!(SyntaxChecker::isValidInternalSId(sid))) - { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } else { mId = sid; @@ -571,12 +555,8 @@ /* if this is setting an L2 name the type is string * whereas if it is setting an L1 name its type is SId */ - if (&(name) == NULL) + if (getLevel() == 1) { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } - else if (getLevel() == 1) - { if (!(SyntaxChecker::isValidInternalSId(name))) { return LIBSBML_INVALID_ATTRIBUTE_VALUE; @@ -662,12 +642,8 @@ int Reaction::setCompartment (const std::string& sid) { - if (&(sid) == NULL) + if (getLevel() < 3) { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } - else if (getLevel() < 3) - { return LIBSBML_UNEXPECTED_ATTRIBUTE; } @@ -1930,15 +1906,8 @@ { vector<SBase*>::const_iterator result; - if (&(sid) == NULL) - { - return NULL; - } - else - { - result = find_if( mItems.begin(), mItems.end(), IdEq<Reaction>(sid) ); - return (result == mItems.end()) ? NULL : static_cast <Reaction*> (*result); - } + result = find_if( mItems.begin(), mItems.end(), IdEq<Reaction>(sid) ); + return (result == mItems.end()) ? NULL : static_cast <Reaction*> (*result); } @@ -1957,17 +1926,15 @@ SBase* item = NULL; vector<SBase*>::iterator result; - if (&(sid) != NULL) + result = find_if( mItems.begin(), mItems.end(), IdEq<Reaction>(sid) ); + + if (result != mItems.end()) { - result = find_if( mItems.begin(), mItems.end(), IdEq<Reaction>(sid) ); - - if (result != mItems.end()) - { - item = *result; - mItems.erase(result); - } + item = *result; + mItems.erase(result); } + return static_cast <Reaction*> (item); } Modified: trunk/libsbml/src/sbml/Rule.cpp =================================================================== --- trunk/libsbml/src/sbml/Rule.cpp 2015-05-20 10:21:59 UTC (rev 22269) +++ trunk/libsbml/src/sbml/Rule.cpp 2015-05-28 08:08:59 UTC (rev 22270) @@ -103,29 +103,21 @@ /* * Copy constructor. Creates a copy of this Rule. */ -Rule::Rule (const Rule& orig) : - SBase ( orig ) - , mMath ( NULL ) +Rule::Rule (const Rule& orig) + : SBase ( orig ) + , mVariable ( orig.mVariable ) + , mFormula ( orig.mFormula ) + , mMath ( NULL ) + , mUnits ( orig.mUnits ) + , mType ( orig.mType ) + , mL1Type ( orig.mL1Type ) + , mInternalId ( orig.mInternalId ) { - if (&orig == NULL) + if (orig.mMath != NULL) { - throw SBMLConstructorException("Null argument to copy constructor"); + mMath = orig.mMath->deepCopy(); + mMath->setParentSBMLObject(this); } - else - { - mVariable = orig.mVariable; - mFormula = orig.mFormula ; - mUnits = orig.mUnits ; - mType = orig.mType ; - mL1Type = orig.mL1Type ; - mInternalId = orig.mInternalId; - - if (orig.mMath != NULL) - { - mMath = orig.mMath->deepCopy(); - mMath->setParentSBMLObject(this); - } - } } @@ -134,12 +126,8 @@ */ Rule& Rule::operator=(const Rule& rhs) { - if (&rhs == NULL) + if(&rhs!=this) { - throw SBMLConstructorException("Null argument to assignment operator"); - } - else if(&rhs!=this) - { this->SBase::operator =(rhs); mVariable = rhs.mVariable; mFormula = rhs.mFormula ; @@ -323,38 +311,34 @@ int Rule::setFormula (const std::string& formula) { - if (&(formula) == NULL) + + + if (formula == "") { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; + mFormula.erase(); + delete mMath; + mMath = NULL; + return LIBSBML_OPERATION_SUCCESS; } - else + ASTNode * math = SBML_parseFormula(formula.c_str()); + if (math == NULL || !(math->isWellFormedASTNode())) { - if (formula == "") + delete math; + return LIBSBML_INVALID_OBJECT; + } + else + { + delete math; + mFormula = formula; + + if (mMath != NULL) { - mFormula.erase(); delete mMath; mMath = NULL; - return LIBSBML_OPERATION_SUCCESS; } - ASTNode * math = SBML_parseFormula(formula.c_str()); - if (math == NULL || !(math->isWellFormedASTNode())) - { - delete math; - return LIBSBML_INVALID_OBJECT; - } - else - { - delete math; - mFormula = formula; - - if (mMath != NULL) - { - delete mMath; - mMath = NULL; - } - return LIBSBML_OPERATION_SUCCESS; - } + return LIBSBML_OPERATION_SUCCESS; } + } @@ -396,12 +380,8 @@ int Rule::setVariable (const std::string& sid) { - if (&(sid) == NULL) + if (isAlgebraic()) { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } - else if (isAlgebraic()) - { return LIBSBML_UNEXPECTED_ATTRIBUTE; } else if (!(SyntaxChecker::isValidInternalSId(sid))) @@ -424,12 +404,8 @@ Rule::setUnits (const std::string& sname) { /* only in L1 ParameterRule */ - if (&(sname) == NULL) + if (getLevel() > 1) { - return LIBSBML_INVALID_ATTRIBUTE_VALUE; - } - else if (getLevel() > 1) - { return LIBSBML_UNEXPECTED_ATTRIBUTE; } else if ( !isParameter()) @@ -1478,15 +1454,8 @@ { vector<SBase*>::const_iterator result; - if (&(sid) == NULL) - { - return NULL; - } - else - { - result = find_if( mItems.begin(), mItems.end(), IdEqRule(sid) ); - return (result == mItems.end()) ? NULL : static_cast <Rule*> (*result); - } + result = find_if( mItems.begin(), mItems.end(), IdEqRule(sid) ); + return (result == mItems.end()) ? NULL : static_cast <Rule*> (*result); } @@ -1519,15 +1488,12 @@ SBase* item = NULL; vector<SBase*>::iterator result; - if (&(sid) != NULL) + result = find_if( mItems.begin(), mItems.end(), IdEqRule(sid) ); + + if (result != mItems.end()) { - result = find_if( mItems.begin(), mItems.end(), IdEqRule(sid) ); - - if (result != mItems.end()) - { - item = *result; - mItems.erase(result); - } + item = *result; + mItems.erase(result); } return static_cast <Rule*> (item); Modified: trunk/libsbml/src/sbml/SBMLDocument.cpp =================================================================== --- trunk/libsbml/src/sbml/SBMLDocument.cpp 2015-05-20 10:21:59 UTC (rev 22269) +++ trunk/libsbml/src/sbml/SBMLDocument.cpp 2015-05-28 08:08:59 UTC (rev 22270) @@ -251,37 +251,33 @@ /* * Creates a copy of this SBMLDocument. */ -SBMLDocument::SBMLDocument (const SBMLDocument& orig) : - SBase ( orig ) +SBMLDocument::SBMLDocument (const SBMLDocument& orig) + : SBase ( orig ) + , mLevel ( orig.mLevel ) + , mVersion ( orig.mVersion ) , mModel ( NULL ) , mLocationURI (orig.mLocationURI ) + , mErrorLog() + , mValidators () + , mInternalValidator(new SBMLInternalValidator()) + , mRequiredAttrOfUnknownPkg(orig.mRequiredAttrOfUnknownPkg) + , mRequiredAttrOfUnknownDisabledPkg(orig.mRequiredAttrOfUnknownDisabledPkg) + , mPkgUseDefaultNSMap() { - if (&orig == NULL) + + + setSBMLDocument(this); + + mInternalValidator->setDocument(this); + mInternalValidator->setApplicableValidators(orig.getApplicableValidators()); + mInternalValidator->setConversionValidators(orig.getConversionValidators()); + + if (orig.mModel != NULL) { - throw SBMLConstructorException("Null argument to copy constructor"); + mModel = static_cast<Model*>( orig.mModel->clone() ); + mModel->setSBMLDocument(this); } - else - { - mLevel = orig.mLevel; - mVersion = orig.mVersion; - - setSBMLDocument(this); - - mInternalValidator = new SBMLInternalValidator(); - mInternalValidator->setDocument(this); - mInternalValidator->setApplicableValidators(orig.getApplicableValidators()); - mInternalValidator->setConversionValidators(orig.getConversionValidators()); - mRequiredAttrOfUnknownPkg = orig.mRequiredAttrOfUnknownPkg; - mRequiredAttrOfUnknownDisabledPkg = orig.mRequiredAttrOfUnknownDisabledPkg; - - if (orig.mModel != NULL) - { - mModel = static_cast<Model*>( orig.mModel->clone() ); - mModel->setSBMLDocument(this); - } - - } - + connectToChild(); //if(orig.mNamespaces) // this->mNamespaces = @@ -297,12 +293,8 @@ */ SBMLDocument& SBMLDocument::operator=(const SBMLDocument& rhs) { - if (&rhs == NULL) + if(&rhs!=this) { - throw SBMLConstructorException("Null argument to assignment operator"); - } - else if(&rhs!=this) - { this->SBase::operator =(rhs); setSBMLDocument(this); Modified: trunk/libsbml/src/sbml/SBMLNamespaces.cpp =================================================================== --- trunk/libsbml/src/sbml/SBMLNamespaces.cpp 2015-05-20 10:21:59 UTC (rev 22269) +++ trunk/libsbml/src/sbml/SBMLNamespaces.cpp 2015-05-28 08:08:59 UTC (rev 22270) @@ -174,22 +174,13 @@ * Copy constructor; creates a copy of a SBMLNamespaces. */ SBMLNamespaces::SBMLNamespaces(const SBMLNamespaces& orig) + : mLevel(orig.mLevel) + , mVersion... [truncated message content] |