Example #1
0
void ConsoleRoboCupCtrl::update()
{
  {
    SYNC;
    for(const std::string& textMessage : textMessages)
    {
      if(textMessage == "_cls")
        consoleView->clear();
      else if(newLine || &textMessage != &*textMessages.rend())
        consoleView->printLn(textMessage.c_str());
      else
        consoleView->print(textMessage.c_str());
    }
    textMessages.clear();
  }
  RoboCupCtrl::update();

  for(RemoteRobot* remoteRobot : remoteRobots)
    remoteRobot->update();

  Global::theStreamHandler = &streamHandler;

  {
    SYNC;
    application->setStatusMessage(statusText);
  }

  if(completion.empty())
    createCompletion();
}
ACSErr::Completion *ErrorComponent::completionFromCompletion(CORBA::Short depth) 
{
        ACS_TRACE("ErrorComponent::completionFromCompletion");
        CompletionImpl *comp;
        if(depth==1){
                ACSErrTypeCommon::GenericErrorCompletion *erg =
                        new ACSErrTypeCommon::GenericErrorCompletion(
                                        __FILE__, __LINE__,
                                        "ErrorComponent::completionFromCompletion");
                erg->setErrorDesc("Put an error trace in completionFromCompletion(depth 1, so not generated from another completion)");
                comp = erg;


        }
        else{
                comp = createCompletion(depth>0?depth-1:0);

                // if comp does not conatin error (=is error free) we return it 
                // otherwise we create a new completion which takes the error trace from a completion comp.
                if (!comp->isErrorFree())
                {
                        // comp is deleted inside the constructor
                        ACSErrTypeCommon::GenericErrorCompletion *erg = 
                                new ACSErrTypeCommon::GenericErrorCompletion(comp, 
                                                __FILE__, __LINE__, 
                                                "ErrorComponent::completionFromCompletion");
                        erg->setErrorDesc("Put an error trace in completionFromCompletion");
                        comp = erg;
                }//if
        }
        return comp->returnCompletion();
}//completionFromCompletion
/* ----------------------------------------------------------------*/
ACSErr::Completion *ErrorComponent::completionFromException(CORBA::Short depth) 
{
    ACS_TRACE("::ErrorComponent::completionFromException");
    // here we get LOCAL (C++) completion 
    CompletionImpl *er = createCompletion(depth);

    // returnCompletion() automatically deletes er
    //   NOTE: you can use returnCompletion() 
    //   just if completion is allocated on the heap. 
    //   If completion is allocated on the stack
    //   returnCompletion(false) has to be used. 
    return er->returnCompletion();
}//completionFromException
void  ErrorComponent::exceptionFromCompletion(CORBA::Short depth) 
{
        ACS_TRACE("ErrorComponent::exceptionFromCompletion");
        if(depth==1){
                ACSErrTypeCommon::GenericErrorExImpl ex2(
                                __FILE__, __LINE__,
                                "ErrorComponent::exceptionFromCompletion");
                ex2.setErrorDesc("Exception with trace of depth 1 (not generated from a completion)");
                throw ex2.getGenericErrorEx();
        }    


        CompletionImpl *comp = createCompletion(depth>0?depth-1:0);
        ACS_DEBUG("ErrorComponent::exceptionFromCompletion","first step");
        // if comp does not conatin error (=is error free) we just return 
        // otherwise we create a new exception which takes the error trace from a completion comp.     
        if (!comp->isErrorFree())
        {
               ACS_DEBUG("ErrorComponent::exceptionFromCompletion","second step");

                // The constructor takes care for the memory manamgent 
                // for the passed completion or exception.
                // If a completion or an exception is passed as pointer the constructor assumes that
                // completion was created on the heap and thus it deletes it afterwards,
                // so it MUST NOT be deleted by the user !
                // If a completion or an exception is passed as an object (or reference to it) 
                // the constructor assumes that the it was created on the stack 
                // and thus it does not delete it.
                //
                // NOTE: do not pass a pointer of a completion or an exception 
                // which was created on the stack !! In this case just send the completion object.
                ACSErrTypeCommon::GenericErrorExImpl ex2(comp, 
                                __FILE__, __LINE__, 
                                "ErrorComponent::exceptionFromCompletion");
                ex2.setErrorDesc("Exception generated by adding an error trace from a completion");
                throw ex2.getGenericErrorEx();
        }//if
}
        ACSErr::Completion *ErrorComponent::completionOnStack(CORBA::Short depth) 
{
    ACS_TRACE("::ErrorComponent::completionOnStack");

    // here we get LOCAL (C++) completion 
    CompletionImpl *comp = createCompletion(depth);
    

    // if comp does not contain error (=is error free) we return it 
    // otherwise we create a new completion which takes the error trace from a completion comp.
    if (comp->isErrorFree())
	{
	// memory for comp is released in the call 
	return comp->returnCompletion();
	}
    else
	{
	// The constructor takes care for the memory manamgent 
	// for the passed completion or exception.
	// If a completion or an exception is passed as pointer the constructor assumes that
        // completion was created on the heap and thus it deletes it afterwards,
	// so it MUST NOT be deleted by the user !
	// If a completion or an exception is passed as an object (or reference to it) 
	// the constructor assumes that the it was created on the stack 
	// and thus it does not delete it.
        //
        // NOTE: do not pass a pointer of a completion or an exception 
	// which was created on the stack !! In this case just send the completion object.
	ACSErrTypeCommon::GenericErrorCompletion erg(comp, 
						     __FILE__, __LINE__, 
						     "ErrorComponent::completionOnStack");
	erg.setErrorDesc("Put an error trace in completionOnStack");
	return erg.returnCompletion(false); 
        // With false flag we tell returnCompletion() 
	// not to delete its object
	// since it is automatically deleted when we go out of scope
	}//if
}//completionOnStack