コード例 #1
0
		Engine::BlockHandles Engine::getCurrentBlocks()
		{
			EngineImpl::BlockInstances const& currBlocks = m_EngineImpl.getCurrentBlockInstances();
			Engine::BlockHandles blocks;
			for ( EngineImpl::BlockInstanceConstIterator it = currBlocks.begin(); it != currBlocks.end(); ++it )
			{
				blocks.push_back( ( *it )->getHandle() );
			}

			return blocks;
		}
コード例 #2
0
		void Engine::getCurrentSystemState( SystemState &state )
		{
			EngineImpl::Bundles const& currBundles = m_EngineImpl.getCurrentBundles();
			Engine::BundleHandles bundles;
			for ( EngineImpl::BundleConstIterator it = currBundles.begin(); it != currBundles.end(); ++it )
				bundles.push_back( ( *it )->getHandle() );

			EngineImpl::BlockInstances &currBlocks = m_EngineImpl.getCurrentBlockInstances();
			Engine::BlockHandles blocks;
			for ( EngineImpl::BlockInstanceConstIterator it = currBlocks.begin(); it != currBlocks.end(); ++it )
				blocks.push_back( ( *it )->getHandle() );

			EngineImpl::Links &currLinks = m_EngineImpl.getCurrentLinks();
			Engine::Links links;
			for ( EngineImpl::LinkConstIterator it = currLinks.begin(); it != currLinks.end(); ++it )
				links.insert( Engine::Link( ( *it )->getInletIO().getHandle(), ( *it )->getOutletIO().getHandle() ) );

			//state.mBundles = bundles;

			// !!!!! might lead to a memory leak
			state.mVertices.clear();
			state.mEdges.clear();

			for ( BlockHandles::const_iterator bIt = blocks.begin(); bIt != blocks.end(); ++bIt )
			{
				BlockHandle const& handle = ( *bIt );
				state.mVertices.insert( std::make_pair( handle, new SystemState::Vertex( handle ) ) );
			}

			for ( Links::iterator lIt = links.begin(); lIt != links.end(); ++lIt )
			{
				InletHandle inlet = ( *lIt ).first;
				BlockHandle inletOwner = inlet.getOwningBlock();
				OutletHandle outlet = ( *lIt ).second;
				BlockHandle outletOwner = outlet.getOwningBlock();

				// both blockHandles are now for sure in the graph's vertices
				SystemState::Vertex *in = state.mVertices[ inletOwner ];
				SystemState::Vertex *out = state.mVertices[ outletOwner ];

				SystemState::Edge *edge = new SystemState::Edge( *lIt, *in, *out );
				state.mEdges.insert( edge );
			}
		};