Ejemplo n.º 1
0
        TyErrorId EngineBase::initialize(AnalysisEngineDescription const& specifier) {
            try {
                util::Trace clTrace(util::enTraceDetailLow, UIMA_TRACE_ORIGIN, UIMA_TRACE_COMPID_ENGINE);

                if (!checkAndSetCallingSequenceInitialize()) {
                    return logError(clTrace, UIMA_ERR_ENGINE_INVALID_CALLING_SEQUENCE);
                }
                assert((&specifier) == (&iv_pAnnotatorContext->getTaeSpecifier()));
                // call implementation in subclass
                TyErrorId utErrorId = initializeImpl(specifier);
                if (utErrorId != UIMA_ERR_NONE) {
                    destroy();
                    return utErrorId;
                }

                utErrorId = initializeCompleteResultSpec();
                if (utErrorId != UIMA_ERR_NONE) {
                    destroy();
                    return utErrorId;
                }

                int numCasRequired = getCasInstancesRequiredImpl();
                if (numCasRequired > 0) {
                    utErrorId = iv_pAnnotatorContext->defineCASPool(numCasRequired);
                }

                return utErrorId;
            } catch (Exception& rclException) {
                getAnnotatorContext().getLogger().logError(rclException.getErrorInfo());
                return rclException.getErrorInfo().getErrorId();
            }

        }
Ejemplo n.º 2
0
void TpetraVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::constInitialize(
  const RCP<const TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraVectorSpace,
  const RCP<const Tpetra::Vector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraVector
  )
{
  initializeImpl(tpetraVectorSpace, tpetraVector);
}
TEST_F(TestConcurrentCompositeStateNoArgs,BasicConcurrentCompositeStateInteractions4)
{
    typedef TestConcurrentCompositeStateNoArgsMock
            < TestStateMachineNoEventArgsMock
            > ConcurrentCompositeStateMockType;
    ::testing::NiceMock<TestStateMachineNoEventArgsMock> stateMachine;
    ::testing::NiceMock
        < ConcurrentCompositeStateMockType
        > compositeState(&stateMachine);
    ::testing::NiceMock
        < TestRegionNoArgsMock<ConcurrentCompositeStateMockType>
        > region(&compositeState);

    stateMachine.autoFinalize(false);
    compositeState.setRegion(0,&region);
    stateMachine.initialState(&compositeState);

    // Setup mock call expectations
    //----------------------------------------------------------------------------
    EXPECT_CALL(compositeState,entryImpl(&stateMachine))
        .Times(1);
    EXPECT_CALL(compositeState,startDoImpl(&stateMachine))
        .Times(1);
    EXPECT_CALL(compositeState,endDoImpl(&stateMachine))
        .Times(1);
    EXPECT_CALL(compositeState,exitImpl(&stateMachine))
        .Times(1);

    // Check region calls
    EXPECT_CALL(region,enterRegionImpl(&compositeState))
        .Times(1);
    EXPECT_CALL(region,startingRegionThread())
        .Times(1);
    EXPECT_CALL(region,initializeImpl(_))
        .Times(2);
    // TODO: Eliminate (superflous?) 3rd call of finalize(Impl)
    EXPECT_CALL(region,finalizeImpl(_))
        .Times(3);
    EXPECT_CALL(region,endingRegionThread())
        .Times(1);
    EXPECT_CALL(region,exitRegionImpl(&compositeState))
        .Times(1);

    // Run the state machine
    //----------------------------------------------------------------------------

//    STTCL_TEST_LOG_ALL();

//    compositeState.enableLogging(true);
//    innerState.enableLogging(true);

    stateMachine.initialize(true);
    // Give the region thread(s) a chance to run
    sttcl::internal::SttclThread<>::sleep(sttcl::TimeDuration<>(0,0,0,100));
    stateMachine.finalize(true);

    EXPECT_TRUE(region.waitForDoActionExited(sttcl::TimeDuration<>(0,0,0,100),10));

//    STTCL_TEST_LOG_END();
}
Ejemplo n.º 4
0
TEST_F(TestRegionNoArgs,BasicRegion_ShallowHistory_Interactions2)
{
    typedef TestConcurrentCompositeStateNoArgsMock
            < TestStateMachineNoEventArgsMock
            > ConcurrentCompositeStateMockType;
    typedef TestRegionNoArgsMock
            < ConcurrentCompositeStateMockType
            , sttcl::CompositeStateHistoryType::Shallow
            > RegionMockType;
    ::testing::NiceMock<TestStateMachineNoEventArgsMock> stateMachine;
    ::testing::NiceMock
        < ConcurrentCompositeStateMockType
        > compositeState(&stateMachine);
    ::testing::NiceMock
        < RegionMockType
        > region(&compositeState);
    ::testing::NiceMock
        < TestRegionInnerStateNoArgsMock<ConcurrentCompositeStateMockType,RegionMockType>
        > innerState;

    stateMachine.autoFinalize(false);
    compositeState.setRegion(0,&region);
    region.initialState(&innerState);
    stateMachine.initialState(&compositeState);

    // Setup mock call expectations
    //----------------------------------------------------------------------------
    // Check region calls
    EXPECT_CALL(region,enterRegionImpl(&compositeState))
        .Times(1);
    EXPECT_CALL(region,startingRegionThread())
        .Times(1);
    EXPECT_CALL(region,initializeImpl(_))
        .Times(1);
    EXPECT_CALL(region,finalizeImpl(_))
        .Times(1);
    EXPECT_CALL(region,endingRegionThread())
        .Times(1);
    EXPECT_CALL(region,exitRegionImpl(&compositeState))
        .Times(1);

    EXPECT_CALL(innerState,entryImpl(&region))
        .Times(1);
    EXPECT_CALL(innerState,startDoImpl(&region))
        .Times(1);
    EXPECT_CALL(innerState,initSubStateMachinesImpl(_))
        .Times(1);
    EXPECT_CALL(innerState,endDoImpl(&region))
        .Times(1);
    EXPECT_CALL(innerState,exitImpl(&region))
        .Times(1);

    // Run the state machine
    //----------------------------------------------------------------------------
    stateMachine.initialize();
    // Give the region thread(s) a chance to run
    sttcl::internal::SttclThread<>::sleep(sttcl::TimeDuration<>(0,0,0,100));
    stateMachine.finalize(true);
}
void TpetraMultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node>::constInitialize(
  const RCP<const TpetraVectorSpace<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraVectorSpace,
  const RCP<const ScalarProdVectorSpaceBase<Scalar> > &domainSpace,
  const RCP<const Tpetra::MultiVector<Scalar,LocalOrdinal,GlobalOrdinal,Node> > &tpetraMultiVector
  )
{
  initializeImpl(tpetraVectorSpace, domainSpace, tpetraMultiVector);
}
Ejemplo n.º 6
0
 void CommandList::initialize(const std::shared_ptr<CommandAllocator>& allocator, const std::shared_ptr<PipelineState>& pipeline)
 {
     initializeImpl(allocator, pipeline);
     if (pipeline)
     {
         list_->SetGraphicsRootSignature(getOwnerDevice()->getD3DRootSignature(*pipeline));
         pipeline->applyParameters(list_.get());
     }
 }
Ejemplo n.º 7
0
void Node::enable()
{
	if( ! mInitialized )
		initializeImpl();

	if( mEnabled )
		return;

	mEnabled = true;
	enableProcessing();
}
Ejemplo n.º 8
0
	void FirstPersonViewCli::initialize()
	{
		if (m_initialized)
		{
			Q_EMIT warning("Warning : already initialized");
			return;
		}

		initializeImpl();

		m_initialized = true;
	}
Ejemplo n.º 9
0
void System::initialize()
{
	if (mState == SYSTEM_STATE_INITIALIZED)
		return;

	mState = SYSTEM_STATE_INITIALIZING;

	if (Log::getInstance() != nullptr) Log::getInstance()->logMessage(mName, "Initializing");

	if (mSystemDriver != nullptr)
		mSystemDriver->initialize();

	registerDefaultFactories();
	initializeImpl();

	mState = SYSTEM_STATE_INITIALIZED;

	if (Log::getInstance() != nullptr) Log::getInstance()->logMessage(mName, "Initialized");
}
Ejemplo n.º 10
0
// TODO: Checking for DelayNode below is a kludge and will not work for other types that want to support feedback.
//		 With more investigation it might be possible to avoid this, or at least define some interface that
//       specifies whether this input needs to be summed.
void Node::configureConnections()
{
	CI_ASSERT( getContext() );

	mProcessInPlace = supportsProcessInPlace();

	if( getNumConnectedInputs() > 1 || getNumConnectedOutputs() > 1 )
		mProcessInPlace = false;

	bool isDelay = ( dynamic_cast<DelayNode *>( this ) != nullptr ); // see note above
	bool inputChannelsUnequal = inputChannelsAreUnequal();

	for( auto &input : mInputs ) {
		bool inputProcessInPlace = true;

		size_t inputNumChannels = input->getNumChannels();
		if( ! supportsInputNumChannels( inputNumChannels ) ) {
			if( mChannelMode == ChannelMode::MATCHES_INPUT )
				setNumChannels( getMaxNumInputChannels() );
			else if( input->getChannelMode() == ChannelMode::MATCHES_OUTPUT ) {
				input->setNumChannels( mNumChannels );
				input->configureConnections();
			}
			else {
				mProcessInPlace = false;
				inputProcessInPlace = false;
			}
		}

		// inputs with more than one output cannot process in-place, so make them sum
		if( input->getProcessesInPlace() && input->getNumConnectedOutputs() > 1 )
			inputProcessInPlace = false;

		// when there are multiple inputs and their channel counts don't match, they must be summed
		if( inputChannelsUnequal )
			inputProcessInPlace = false;

		// if we're unable to process in-place and we're a DelayNode, its possible that the input may be part of a feedback loop, in which case input must sum.
		if( ! mProcessInPlace && isDelay )
			inputProcessInPlace = false;

		if( ! inputProcessInPlace )
			input->setupProcessWithSumming();

		input->initializeImpl();
	}

	for( auto &out : mOutputs ) {
		NodeRef output = out.lock();
		if( ! output )
			continue;
		if( ! output->supportsInputNumChannels( mNumChannels ) ) {
			if( output->getChannelMode() == ChannelMode::MATCHES_INPUT ) {
				output->setNumChannels( mNumChannels );
				output->configureConnections();
			}
			else
				mProcessInPlace = false;
		}
	}

	if( ! mProcessInPlace )
		setupProcessWithSumming();

	initializeImpl();
}
Ejemplo n.º 11
0
TEST_F(TestRegionNoArgs,BasicRegion_ShallowHistory_Resume2)
{
    typedef TestConcurrentCompositeStateNoArgsMock
            < TestStateMachineNoEventArgsMock
            > ConcurrentCompositeStateMockType;
    typedef TestRegionNoArgsMock
            < ConcurrentCompositeStateMockType
            , sttcl::CompositeStateHistoryType::Shallow
            > RegionMockType;
    typedef TestRegionInnerStateNoArgsMock<ConcurrentCompositeStateMockType,RegionMockType> RegionInnerStateMockType;

    ::testing::NiceMock<TestStateMachineNoEventArgsMock> stateMachine("stateMachine");
    ::testing::NiceMock
        < ConcurrentCompositeStateMockType
        > compositeState(&stateMachine);
    ::testing::NiceMock
        < RegionMockType
        > region(&compositeState,"region");
    ::testing::NiceMock
        < RegionInnerStateMockType
        > innerState1("innerState1");
    ::testing::NiceMock
        < RegionInnerStateMockType
        > innerState2("innerState1");

    ::testing::NiceMock
        < TestSimpleStateNoArgsMock<TestStateMachineNoEventArgsMock>
        > outerState("outerState");

    stateMachine.autoFinalize(false);
    compositeState.setRegion(0,&region);
    region.initialState(&innerState1);
    stateMachine.initialState(&compositeState);

    // Setup mock call expectations
    //----------------------------------------------------------------------------
    EXPECT_CALL(compositeState,handleEvent1(&stateMachine))
        .Times(1);
    EXPECT_CALL(compositeState,handleEvent2(&stateMachine))
        .Times(1)
        .WillOnce( TRIGGER_STATE_CHANGE(ConcurrentCompositeStateMockType, handleEvent2, &compositeState, &outerState) );
    EXPECT_CALL(compositeState,endDoImpl(&stateMachine))
        .Times(2);
    EXPECT_CALL(compositeState,exitImpl(&stateMachine))
        .Times(2);

    // Check region calls
    EXPECT_CALL(region,enterRegionImpl(&compositeState))
        .Times(2);
    EXPECT_CALL(region,startingRegionThread())
        .Times(2);
    EXPECT_CALL(region,initializeImpl(_))
        .Times(2);
    // TODO: Eliminiate (superflous?) calls to finalize(Impl)
    EXPECT_CALL(region,finalizeImpl(_))
        .Times(3);
    EXPECT_CALL(region,endingRegionThread())
        .Times(2);
    EXPECT_CALL(region,exitRegionImpl(&compositeState))
        .Times(2);

    EXPECT_CALL(outerState,entryImpl(&stateMachine))
        .Times(1);
    EXPECT_CALL(outerState,startDoImpl(&stateMachine))
        .Times(1);
    EXPECT_CALL(outerState,handleEvent3(&stateMachine))
        .Times(1)
        .WillOnce( TRIGGER_STATE_CHANGE(TestSimpleStateNoArgsMock<TestStateMachineNoEventArgsMock>, handleEvent3, &outerState, &compositeState) );
    EXPECT_CALL(outerState,endDoImpl(&stateMachine))
        .Times(1);
    EXPECT_CALL(outerState,exitImpl(&stateMachine))
        .Times(1);

    EXPECT_CALL(innerState1,entryImpl(&region))
        .Times(1);
    EXPECT_CALL(innerState1,startDoImpl(&region))
        .Times(1);
    // TODO: Eliminiate (superflous?) calls to initSubStateMachinesImpl
    EXPECT_CALL(innerState1,initSubStateMachinesImpl(true))
        .Times(2);
//    EXPECT_CALL(innerState1,initSubStateMachinesImpl(true))
//        .Times(1);
    EXPECT_CALL(innerState1,handleEvent1(&compositeState,&region))
        .Times(1)
        .WillOnce( TRIGGER_STATE_CHANGE2(RegionInnerStateMockType, handleEvent1, &innerState1, &innerState2) );
    EXPECT_CALL(innerState1,endDoImpl(&region))
        .Times(1);
    EXPECT_CALL(innerState1,exitImpl(&region))
        .Times(1);

    EXPECT_CALL(innerState2,entryImpl(&region))
        .Times(1);
    EXPECT_CALL(innerState2,startDoImpl(&region))
        .Times(1);
//    EXPECT_CALL(innerState2,initSubStateMachinesImpl(true))
//        .Times(1);
    EXPECT_CALL(innerState2,endDoImpl(&region))
        .Times(2);
    EXPECT_CALL(innerState2,exitImpl(&region))
        .Times(2);

    // Run the state machine
    //----------------------------------------------------------------------------

//    STTCL_TEST_LOG_ALL();

    stateMachine.initialize(true);
    // Give the region thread(s) a chance to run
    sttcl::internal::SttclThread<>::sleep(sttcl::TimeDuration<>(0,0,0,100));

    stateMachine.triggerEvent1();
    // Give the region thread(s) a chance to run
    sttcl::internal::SttclThread<>::sleep(sttcl::TimeDuration<>(0,0,0,100));

    stateMachine.triggerEvent2();
    // Give the region thread(s) a chance to run
    sttcl::internal::SttclThread<>::sleep(sttcl::TimeDuration<>(0,0,0,100));

    stateMachine.triggerEvent3();
    // Give the region thread(s) a chance to run
    sttcl::internal::SttclThread<>::sleep(sttcl::TimeDuration<>(0,0,0,100));

    stateMachine.finalize(true);

//    STTCL_TEST_LOG_END();
}
TEST_F(TestConcurrentCompositeStateNoArgs,MultipleRegions)
{
    typedef TestConcurrentCompositeStateNoArgsMock
            < TestStateMachineNoEventArgsMock
            > ConcurrentCompositeStateMockType;
    ::testing::NiceMock<TestStateMachineNoEventArgsMock> stateMachine;
    ::testing::NiceMock
        < ConcurrentCompositeStateMockType
        > compositeState(&stateMachine);
    ::testing::NiceMock
        < TestRegionNoArgsMock<ConcurrentCompositeStateMockType>
        > region1(&compositeState);
    ::testing::NiceMock
        < TestRegionNoArgsMock<ConcurrentCompositeStateMockType>
        > region2(&compositeState);

    stateMachine.autoFinalize(false);
    compositeState.setRegion(0,&region1);
    compositeState.setRegion(1,&region2);
    stateMachine.initialState(&compositeState);

    // Setup mock call expectations
    //----------------------------------------------------------------------------
    EXPECT_CALL(compositeState,entryImpl(&stateMachine))
        .Times(1);
    EXPECT_CALL(compositeState,startDoImpl(&stateMachine))
        .Times(1);
    EXPECT_CALL(compositeState,endDoImpl(&stateMachine))
        .Times(1);
    EXPECT_CALL(compositeState,exitImpl(&stateMachine))
        .Times(1);

    // Check region calls
    EXPECT_CALL(region1,enterRegionImpl(&compositeState))
        .Times(1);
    EXPECT_CALL(region1,startingRegionThread())
        .Times(1);
    EXPECT_CALL(region1,initializeImpl(_))
        .Times(1);
    EXPECT_CALL(region1,handleEvent1(&compositeState,&region1))
        .Times(1);
    EXPECT_CALL(region1,handleEvent2(&compositeState,&region1))
        .Times(1);
    EXPECT_CALL(region1,handleEvent3(&compositeState,&region1))
        .Times(1);
    EXPECT_CALL(region1,handleEvent4(&compositeState,&region1))
        .Times(1);
    EXPECT_CALL(region1,finalizeImpl(_))
        .Times(1);
    EXPECT_CALL(region1,endingRegionThread())
        .Times(1);
    EXPECT_CALL(region1,exitRegionImpl(&compositeState))
        .Times(1);

    EXPECT_CALL(region2,enterRegionImpl(&compositeState))
        .Times(1);
    EXPECT_CALL(region2,startingRegionThread())
        .Times(1);
    EXPECT_CALL(region2,initializeImpl(_))
        .Times(1);
    EXPECT_CALL(region2,handleEvent1(&compositeState,&region2))
        .Times(1);
    EXPECT_CALL(region2,handleEvent2(&compositeState,&region2))
        .Times(1);
    EXPECT_CALL(region2,handleEvent3(&compositeState,&region2))
        .Times(1);
    EXPECT_CALL(region2,handleEvent4(&compositeState,&region2))
        .Times(1);
    EXPECT_CALL(region2,finalizeImpl(_))
        .Times(1);
    EXPECT_CALL(region2,endingRegionThread())
        .Times(1);
    EXPECT_CALL(region2,exitRegionImpl(&compositeState))
        .Times(1);

    // Run the state machine
    //----------------------------------------------------------------------------

//    STTCL_TEST_LOG_ALL();

//    compositeState.enableLogging(true);
//    innerState.enableLogging(true);

    stateMachine.initialize();
    // Give the region thread(s) a chance to run
    sttcl::internal::SttclThread<>::sleep(sttcl::TimeDuration<>(0,0,0,100));
    stateMachine.triggerEvent1();
    // Give the region thread(s) a chance to run
    sttcl::internal::SttclThread<>::sleep(sttcl::TimeDuration<>(0,0,0,100));
    stateMachine.triggerEvent2();
    // Give the region thread(s) a chance to run
    sttcl::internal::SttclThread<>::sleep(sttcl::TimeDuration<>(0,0,0,100));
    stateMachine.triggerEvent3();
    // Give the region thread(s) a chance to run
    sttcl::internal::SttclThread<>::sleep(sttcl::TimeDuration<>(0,0,0,100));
    stateMachine.triggerEvent4();
    // Give the region thread(s) a chance to run
    sttcl::internal::SttclThread<>::sleep(sttcl::TimeDuration<>(0,0,0,100));
    stateMachine.finalize();
    // Give the region thread(s) a chance to run
    sttcl::internal::SttclThread<>::sleep(sttcl::TimeDuration<>(0,0,0,100));

    EXPECT_TRUE(region1.waitForDoActionExited(sttcl::TimeDuration<>(0,0,0,100),10));

//    STTCL_TEST_LOG_END();
}