void 
AcdkOrbIdl::writeForwardDeclarations(StringBuffer& sb)
{
  writeBaseArrayDeclarations(sb);
  qsort((void*)_interfaceTypeDefs.begin(), _interfaceTypeDefs.end() - _interfaceTypeDefs.begin(), sizeof(_interfaceTypeDefs.begin()), compare);
  const ClazzInfo* lastUnitCi = 0;
  StringBuffer indent;
  for (int i = 0; i < _interfaceTypeDefs.size(); ++i)
  {
    const ClazzInfo* ci = _interfaceTypeDefs[i];
    if (_onlyKnownClasses == true && isKnown(ci) == false)
      continue;
    if (isException(ci) == true)
      continue;
    if (ci == String::clazzInfo())
      continue;

    if (lastUnitCi == 0 || strcmp(lastUnitCi->ns, ci->ns) != 0)
    {
      if (lastUnitCi != 0)
      {
        RStringArray nsa = acdk::util::StringTokenizer(lastUnitCi->ns, "/").allToken();
        for (int j = 0; j < nsa->length(); ++j)
        {
          indent.set(indent.toString()->substr(2));
          sb << indent.toString() << "}; // module " << nsa[j] << "\n";
        }
      }
      
      RStringArray nsa = acdk::util::StringTokenizer(ci->ns, "/").allToken();
      for (int j = 0; j < nsa->length(); ++j)
      {
        sb << indent.toString() << "module " << nsa[j] << "{\n";
        indent << "  ";
      }
      lastUnitCi = ci;
    }
    sb << indent.toString() << "interface " << objectName(ci) << ";\n";
    RString guard = getNsIdentifier(lastUnitCi) + "_" + objectName(ci);
    sb << "#ifndef " << guard << "\n"
      << "#define " << guard << "\n";
    sb << indent.toString() << "typedef sequence<" << objectName(ci) << "> " 
      << objectName(ci) << "Array;\n";
    sb << indent.toString() << "typedef sequence<" << objectName(ci) << "Array> " 
      << objectName(ci) << "ArrayArray;\n";
    sb << "#endif // " << guard << "\n";
    
  }
  if (lastUnitCi != 0)
  {
    RStringArray nsa = acdk::util::StringTokenizer(lastUnitCi->ns, "/").allToken();
    for (int j = 0; j < nsa->length(); ++j)
    {
      sb << "}; // module " << nsa[j] << "\n";
    }
  }
}
int CCmd::dealCmd(int cmdid)
{
	if(cmdid>CMD_COUNT){
		_cmd[cmdid].exception=CMDID_OVERFLOW;
		return EOF;
	}	
	if(isException(cmdid)) return EOF;
	if(dealSpecialCmd(cmdid)) return NULL;
	pCmdCallback[cmdid]->dealCmd(&_cmd[cmdid]);
	return NULL;
}
Beispiel #3
0
void UmlPinParameter::html(Q3CString pfix, unsigned int rank, unsigned int level) {
  if (isUnique()) {
    if (isException())
      fw.write("<p>Unique, exception</p>");
    else
      fw.write("<p>Read only</p>");
  }
  else if (isException())
    fw.write("<p>Exception</p>");

  fw.write("<p>Direction : ");
  write(direction());
  fw.write("</p>");

  if (effect() != noEffect) {
    fw.write("<p>Effect : ");
    write(effect());
    fw.write("</p>");
  }

  html_internal(pfix, rank, level);

}
bool
AcdkOrbIdl::writeField(StringBuffer& sb, const ClazzInfo* ci, const ClazzFieldInfo* fi, int flags)
{
  if (_noFields == true)
    return false;
  if ((fi->flags & MiPublic) == false)
    return false;
  if ((flags & MiStatic) && ((fi->flags & MiStatic) == false))
    return false;
  if (((flags & MiStatic) == false) && (fi->flags & MiStatic))
    return false;
  if (isException(fi->type) == true)
    return false;
  sb << "  attribute " << getReturnType(fi->type) << " " << paramName(fi->name) << ";\n";
  return true;
}
Beispiel #5
0
void AsyncFile::pollEvents(THREAD_CONTEXT threadContext)
{

	LockClass lock(&pollerMutex);
	pollerRunning=1;


	while (pollerRunning)
	{
		if (isException(threadContext))
		{
			return;
		}
		int result = io_getevents(this->aioContext, 1, maxIO, events, 0);


#ifdef DEBUG
		fprintf (stderr, "poll, pollerRunning=%d\n", pollerRunning); fflush(stderr);
#endif

		if (result > 0)
		{

#ifdef DEBUG
			fprintf (stdout, "Received %d events\n", result);
			fflush(stdout);
#endif
		}

		for (int i=0; i<result; i++)
		{

			struct iocb * iocbp = events[i].obj;

			if (iocbp->data == (void *) -1)
			{
				pollerRunning = 0;
#ifdef DEBUG
				controller->log(threadContext, 2, "Received poller request to stop");
#endif
			}
			else
			{
				CallbackAdapter * adapter = (CallbackAdapter *) iocbp->data;

				long result = events[i].res;
				if (result < 0)
				{
					std::string strerror = io_error(result);
					adapter->onError(threadContext, result, strerror);
				}
				else
				{
					adapter->done(threadContext);
				}
			}

			delete iocbp;
		}
	}
#ifdef DEBUG
	controller->log(threadContext, 2, "Poller finished execution");
#endif
}
Beispiel #6
0
std::pair<double, double> ReducedModel::trial(
    mlsolvers::Solver & solver, WrapperProblem* wrapperProblem)
{
    assert(wrapperProblem->problem() == this);

    double cost = 0.0;
    double totalPlanningTime = 0.0;
    ReducedState* currentState =
        static_cast<ReducedState*>(this->initialState());
    if (currentState->deadEnd())
        return std::make_pair(mdplib::dead_end_cost, 0.0);
    if (this->goal(currentState))
        return std::make_pair(0.0, 0.0);

    // This state will be used to simulate the full transition function by
    // making it a copy of the current state and adjusting the exception counter
    // accordingly.
    ReducedState* auxState = new ReducedState(*currentState);

                                                                                mlcore::State* foo = currentState->originalState();

    bool resetExceptionCounter = false;
    while (true) {
        Action* bestAction = currentState->bestAction();
        cost += this->cost(currentState, bestAction);
        int exceptionCount = currentState->exceptionCount();

        if (cost >= mdplib::dead_end_cost)
            break;

        // Simulating the action execution using the full model.
        // Since we want to use the full transition function for this,
        // we set the exception counter of the current state to -1
        // so that it's guaranteed to be lower than the
        // exception bound k, thus forcing the reduced model to use the full
        // transition. We don't use reducedModel->useFullTransition(true)
        // because we still want to know if the outcome was an exception or not.
        // TODO: Make a method in ReducedModel that does this because this
        // approach will make reducedModel store the copies with j=-1.
        auxState->originalState(currentState->originalState());
        auxState->exceptionCount(-1);
        ReducedState* nextState = static_cast<ReducedState*>(
            mlsolvers::randomSuccessor(this, auxState, bestAction));
        auxState->originalState(nextState->originalState());
        auxState->exceptionCount(nextState->exceptionCount());
                                                                                mlcore::State* bar = nextState->originalState();
                                                                                isException(foo, bar, bestAction);

        // Adjusting the result to the current exception count.
        if (resetExceptionCounter) {
            // We reset the exception counter after pro-active re-planning.
            auxState->exceptionCount(0);
            resetExceptionCounter = false;
        } else {
            if (auxState->exceptionCount() == -1)    // no exception happened.
                auxState->exceptionCount(exceptionCount);
            else
                auxState->exceptionCount(exceptionCount + 1);
        }
        nextState =
            static_cast<ReducedState*>(this->getState(auxState));

        if ((nextState != nullptr && nextState->deadEnd()) ||
                cost >= mdplib::dead_end_cost) {
            cost = mdplib::dead_end_cost;
            break;
        }

        if (nextState != nullptr && this->goal(nextState)) {
            break;
        }

        // Re-planning
        // Checking if the state has already been considered during planning.

        if (nextState == nullptr || nextState->bestAction() == nullptr) {
            // State wasn't considered before.
            assert(this->k_ == 0);  // Only determinization should reach here.
            auxState->exceptionCount(0);
            nextState = static_cast<ReducedState*>(
                this->addState(new ReducedState(*auxState)));
            totalPlanningTime +=
                triggerReplan(solver, nextState, false, wrapperProblem);
            assert(nextState != nullptr);
        } else if (!this->useFullTransition_) {
            if (nextState->exceptionCount() == this->k_) {
                totalPlanningTime +=
                    triggerReplan(solver, nextState, true, wrapperProblem);
                resetExceptionCounter = true;
            }
        }
        currentState = nextState;
    }
    if (auxState != nullptr)
        delete auxState;
    return std::make_pair(cost, totalPlanningTime);
}