Exemplo n.º 1
0
		// Updates tag
		void GaTagManager::UpdateTag(int tagID,
			const GaTagUpdate& tagUpdate)
		{
			GaTagIndicesTable::iterator it = _tagIndices.find( tagID );
			GA_ARG_ASSERT( Exceptions::GaArgumentException, it != _tagIndices.end() , "tagID", "Tag does not exist.", "Data" );

			// perform update only if actual change has occured
			if( tagUpdate.IsRequired( *it->second.second ) )
			{
				// perform update on tag lifecycle policies
				tagUpdate( *it->second.second );

				// update tags in all buffers
				if( !_update.IsNull() )
					_update->UpdateTag( it->second.first, tagUpdate );
			}
		}
Exemplo n.º 2
0
		// Allows specified branch
		void GaBranchFilterInfo::SetBranchMask(int branchID)
		{
			GA_ARG_ASSERT( Exceptions::GaArgumentOutOfRangeException, branchID >= 0 && branchID < GetSize(), "branchID", "Branch ID is out of range.", "Workflows" );

			GaFilterEntry& entry = _filter[ branchID ];

			// is it already allowed?
			if( !entry._allowed )
			{
				// allow
				entry._allowed = true;
				_count++;

				// update raw to filtered ID converter
				for( int i = GetSize() - 1; i > branchID; i-- )
					_filter[ i ]._filteredID--;
			}
		}
Exemplo n.º 3
0
		// Detaches node from the tree
		void GaTreeBase::DetachNode(GaTreeNodeBase* node)
		{
			GA_ARG_ASSERT( Exceptions::GaNullArgumentException, node != NULL, "node", "Node that should be detached from the tree must be specified.", "Data" );

			if( node == _root )
			{
				// mark tree as empty
				_root = NULL;
				_count = 0;
				_modified = false;
			}
			else
			{
				// detach node from it's parent
				_modified = true;
				node->Detach();
			}
		}
Exemplo n.º 4
0
		// Returns pointer to data with specified ID at specified level
		GaDataEntryBase* GaDataStorage::GetData(GaDataStorageLevel level,
			int dataID)
		{ 
			GA_ARG_ASSERT( Exceptions::GaArgumentException, level <= _level, "storageLevel", "Trying to query data below level of this storage object.", "Workflows" );

			GA_LOCK_THIS_OBJECT( lock );

			// trying to get data from level which is equal to level of this object
			if( level == _level )
			{
				STLEXT::hash_map<int, GaDataEntryBase*>::iterator it = _data.find( dataID );
				if( it != _data.end() )
				{
					it->second->AddReference();
					return it->second;
				}
				
				return NULL;
			}

			// forward query to higher level object
			return _levelTable[ level ] ? _levelTable[ level ]->GetData( dataID ) : NULL;
		}
Exemplo n.º 5
0
		// Replaces tags
		int GaTagManager::ReplaceTag(int tagID,
			const GaTagLifecycle& tagLifecycle,
			bool shouldThrow/* = false*/)
		{
			GaTagIndicesTable::iterator it = _tagIndices.find( tagID );
			GA_ARG_ASSERT( Exceptions::GaArgumentException, it != _tagIndices.end() || !shouldThrow, "tagID", "Tag does not exist.", "Data" );

			// add tag if it does not exists
			if( it == _tagIndices.end() )
				return AddTag( tagID, tagLifecycle );

			int index = it->second.first;

			// free memory used by old lifecycle policies
			delete it->second.second;
			it->second.second = tagLifecycle.Clone();

			// insert tag to tag buffers
			if( !_update.IsNull() )
				_update->AddTag( index, tagLifecycle );

			return index;
		}
Exemplo n.º 6
0
	// Sets new size of array that stores chromosomes
	void GaChromosomeGroup::SetSize(int size)
	{
		if( size != _array.GetSize() )
		{
			GA_ASSERT( Common::Exceptions::GaInvalidOperationException, !_sizable, "This chromosome group manage its size automatically.", "Population" );
			GA_ARG_ASSERT( Common::Exceptions::GaArgumentOutOfRangeException, size >= 0, "size", "Group size cannot be negative value.", "Population" );

			// with new size of group cannot store chromosmes?
			if( !size )
				// removes all chromosomes from the group
				Clear();
			else
			{
				int limit = 0;
				if( !_array.IsEmpty() )
				{
					limit = _array.GetSize() < _count ? _array.GetSize() : _count;

					if( _recycleObjects && _population )
					{
						// recycle chromosome objects using provided pool
						for( int i = limit; i < _count; i++ )
							_population->ReleaseStorageObject( _chromosomes[ i ] );
					}
					else if( _membershipFlag )
					{
						// chromosome objects are not recycled - just clear mebership flags
						for( int i = limit; i < _count; i++ )
							_chromosomes[ i ]->GetFlags().SetFlags( _membershipFlag );
					}
				}

				_count = limit;
				ResizeArray( size );
			}
		}
	}
Exemplo n.º 7
0
	// Binds value to its evaluation dependency.
	void GaStatistics::BindValues(GaValueHistoryBase* value,
		int dependencyID)
	{
		GA_ARG_ASSERT( Common::Exceptions::GaNullArgumentException, value != NULL, "value", "Value for binding must be specified.", "Statistics" );
		value->AddDependency( &GetValue( dependencyID ) );
	}