- return newStr;
- }
- //public function definiton
- /*
- @funct: TakeStep( thrd_t current, thrd_t whoseNext )
- @return: bool
- @Desc: this function takes a series of steps creating
- new tree elements and setting the current scope. This function returns true if the step just taken leads to the parent of
- an unexplored back tracking point...
- */
- void snapshotTree::AddThreadStep( ThreadStepMap_t & theMap, thrd_t which ){
- if( theMap.find( which ) != theMap.end() ){
- ++theMap[ which ];
- return;
- }
- theMap[ which ] = 1; //implicit thread creation....
- }
- bool snapshotTree::operator<( const snapshotTree & rhs ) const{
- return this->mTimeStamp < rhs.mTimeStamp;
- }
- bool snapshotTreeComp::operator()( const std::pair< const snapshotTree*, snapshot_id > & lhs, const std::pair< const snapshotTree*, snapshot_id > & rhs ){
- return *(lhs.first) < *(rhs.first);
- }
- std::pair< MyString, bool > snapshotTree::TakeStep( thrd_t which, thrd_t whoseNext ){
- assert( msCurrentScope == this );
- std::pair< MyString, bool > retVal;
- ThreadStepMap_t temp = mThreadStepsTaken;
- AddThreadStep( temp, which );
- MyString serialized = SerializeThreadSteps( mThreadStepsTaken ); //is it necessary to cache this with the class....?
- retVal.first = serialized;
- if( msSnapshotEdgesMap.find( serialized ) != msSnapshotEdgesMap.end() ){
- msCurrentScope = msSnapshotEdgesMap[ serialized ];
- }
- snapshotTree * newNode = new snapshotTree();
- newNode->mThreadStepsTaken = temp;
- newNode->mpParent = this;
- this->mChildren.push_back( newNode );
- newNode->mNextStepTaker = whoseNext; //dont know if this will be used yet....
- newNode->mTimeStamp = msTimeCounter++;
- msCurrentScope = newNode;
-
- //is it an actual backtracking parent....
- retVal.second = msRecordedParents.find( msCurrentScope ) != msRecordedParents.end();
- return retVal;