src/dependency_finder.cpp
/*!
 * \brief Add a dependency for an object.
 * \details This function is used to mark a single dependency, from aObjectName
 *          to aDependency.
 * \param aObjectName Name of the object which has a new dependency.
 * \param aDependency name of the item aObjectName is dependent on.
 * \return Whether the dependency was added to the matrix.
 */
\brief Add a dependency for an object.
\details This function is used to mark a single dependency, from aObjectName
to aDependency.
\param aObjectName Name of the object which has a new dependency.
\param aDependency name of the item aObjectName is dependent on.
\return Whether the dependency was added to the matrix.
\ brief Add a dependency for an object . \ details This function is used to mark a single dependency from aObjectName to aDependency . \ param aObjectName Name of the object which has a new dependency . \ param aDependency name of the item aObjectName is dependent on . \ return Whether the dependency was added to the matrix .
bool DependencyFinder::addDependency( const string& aObjectName,
                                     const string& aDependency ){
    ObjectIndexMap::iterator objectLocation = mObjectIndices.find( aObjectName );
    if( objectLocation == mObjectIndices.end() ){
        objectLocation = addTrackedItem( aObjectName );
    }
    ObjectIndexMap::iterator dependencyLocation = mObjectIndices.find( aDependency );
    if( dependencyLocation == mObjectIndices.end() ){
        dependencyLocation = addTrackedItem( aDependency );
    }
    H_ASSERT( mDependencyMatrix.size() > objectLocation->second, "addDependency failure" );
    H_ASSERT( mDependencyMatrix[ objectLocation->second ].size() > dependencyLocation->second, "addDependency failure" );
    if( mDependencyMatrix[ objectLocation->second ][ dependencyLocation->second ] ){
        return false;
    }
    mDependencyMatrix[ objectLocation->second ][ dependencyLocation->second ] = true;
    return true;
}
bool DependencyFinder :: addDependency ( const string & aObjectName , const string & aDependency ) { ObjectIndexMap :: iterator objectLocation = mObjectIndices . find ( aObjectName ) ; if ( objectLocation == mObjectIndices . end ( ) ) { objectLocation = addTrackedItem ( aObjectName ) ; } ObjectIndexMap :: iterator dependencyLocation = mObjectIndices . find ( aDependency ) ; if ( dependencyLocation == mObjectIndices . end ( ) ) { dependencyLocation = addTrackedItem ( aDependency ) ; } H_ASSERT ( mDependencyMatrix . size ( ) > objectLocation -> second , " " ) ; H_ASSERT ( mDependencyMatrix [ objectLocation -> second ] . size ( ) > dependencyLocation -> second , " " ) ; if ( mDependencyMatrix [ objectLocation -> second ] [ dependencyLocation -> second ] ) { return false ; } mDependencyMatrix [ objectLocation -> second ] [ dependencyLocation -> second ] = true ; return true ; }
\brief Add a dependency for an object.
\ brief Add a dependency for an object .
// Check if the object is already in the mapping of object name to matrix index. // Update the object location iterator after the item is added. // Check if the dependency is already in the mapping. // Update the dependency location iterator after the item is added. // The matrix is now set up correctly, add the dependency. // Check if the dependency already exists. // Add the dependency and return that it was a new dependency.