예제 #1
0
IfElseBlock::IfElseBlock(InputSource& input,
                         ErrorHandler& errorHandler,
                         Symbols& symbols,
                         Option& option,
                         State& state) :
  ifCondition(0), ifStatement(0), elseStatement(0)
{

  // if case
  XABSL_DEBUG_INIT(errorHandler.message("creating if statement"));

  ifCondition = BooleanExpression::create(input, errorHandler, symbols, option, state);
  if(errorHandler.errorsOccurred)
  {
    errorHandler.error("XabslIfElseBlock::IfElseBlock(): could not create if condition");
    return;
  }

  ifStatement = Statement::createStatement(input, errorHandler, symbols, option, state);
  if(errorHandler.errorsOccurred)
  {
    errorHandler.error("XabslIfElseBlock::IfElseBlock(): could not create if statement");
    return;
  }

  // else case
  XABSL_DEBUG_INIT(errorHandler.message("creating else statement"));

  elseStatement = Statement::createStatement(input, errorHandler, symbols, option, state);
  if(errorHandler.errorsOccurred)
    errorHandler.error("XabslIfElseBlock::IfElseBlock(): could not create else statement");

}
예제 #2
0
void Parameters::registerEnumerated(const char* name, const char* enumName, int& parameter)
{
  XABSL_DEBUG_INIT(errorHandler.message("registering enumerated parameter \"%s\"",name));
  
  if (pEnumerations == 0)
  {
    errorHandler.error("XabslParameters::registerEnumerated(): call Parameters::registerEnumerations first");
    return;
  }
  if (enumerated.exists(name))
  {
    errorHandler.error("XabslParameters::registerEnumerated(): enumerated parameter \"%s\" was already registered",name);
    return;
  }
  if (!pEnumerations->exists(enumName))
  {
    errorHandler.error("XabslParameters::registerEnumerated(): enumeration \"%s\" was not registered",enumName);
    return;
  }
  const Enumeration* enumeration = (*pEnumerations)[enumName];
  if (enumeration->enumElements.getSize() == 0)
  {
    errorHandler.error("XabslParameters::registerEnumerated(): no enumeration elements for \"%s\" were registered",enumName);
    return;
  }

  enumerations.append(name, enumeration);
  enumerated.append(name,&parameter);

  parameter = enumeration->enumElements[0]->v;
}
SubsequentOptionReachedTargetStateCondition::SubsequentOptionReachedTargetStateCondition(
                                                   ErrorHandler& XABSL_DEBUG_INIT(errorHandler),
                                                   State& state)
                                                   : state(state)
{
  XABSL_DEBUG_INIT(errorHandler.message("creating a \"subsequent-option-reached-target-state\" element"));
}
DecimalInputSymbolRef::DecimalInputSymbolRef(InputSource& input, 
                                                               Array<Action*>& actions,
                                                               ErrorHandler& errorHandler,
                                                               OptionParameters& optionParameters,
                                                               Symbols& symbols,
                                                               unsigned long& timeOfOptionExecution,
                                                               unsigned long& timeOfStateExecution) :
  symbol(0), parameters(0)
{
  char buf[100];
  input.readString(buf,99);
  
  XABSL_DEBUG_INIT(errorHandler.message("creating a reference to decimal input symbol \"%s\"",buf));
  
  if (!symbols.decimalInputSymbols.exists(buf))
  {
    errorHandler.error("XabslDecimalInputSymbolRef::DecimalInputSymbolRef(): decimal input symbol \"%s\" was not registered",buf);
    return;
  }
  
  symbol = symbols.decimalInputSymbols[buf];

  parameters = new ParameterAssignment(&symbol->parameters, errorHandler);

  parameters->create(input, optionParameters, symbols, timeOfOptionExecution, timeOfStateExecution, actions);
}
DecimalValue::DecimalValue(InputSource& input, 
                                       ErrorHandler& errorHandler)
{
  value = input.readValue();
  
  XABSL_DEBUG_INIT(errorHandler.message("created decimal value: \"%.2f\"",value));
}
ConflictCondition::ConflictCondition(
                                   ErrorHandler& XABSL_DEBUG_INIT(errorHandler),
                                   State& state)
                                   : state(state)
{
  XABSL_DEBUG_INIT(errorHandler.message("creating a \"conflict\" element"));
}
EnumeratedInputSymbolRef::EnumeratedInputSymbolRef(const Enumeration* enumeration,
    InputSource& input,
    ErrorHandler& errorHandler,
    Symbols& symbols,
    Option& option,
    State& state) :
  symbol(0), parameters(0)
{
  char buf[100];
  input.readString(buf, 99);

  XABSL_DEBUG_INIT(errorHandler.message("creating reference to enumerated input symbol \"%s\"", buf));

  if(!symbols.enumeratedInputSymbols.exists(buf))
  {
    errorHandler.error("XabslEnumeratedInputSymbolRef::XabslEnumeratedInputSymbolRef(): enumerated input symbol \"%s\" was not registered at the engine", buf);
    return;
  }

  symbol = symbols.enumeratedInputSymbols[buf];
  this->enumeration = symbol->enumeration;

  if(enumeration != NULL && enumeration != this->enumeration)
  {
    errorHandler.error("XabslEnumeratedInputSymbolRef::XabslEnumeratedInputSymbolRef(): enumeration input symbol \"%s\" does not match enumeration type \"%s\"", buf, enumeration->n);
  }

  parameters = new ParameterAssignment(&symbol->parameters, errorHandler);

  parameters->create(input, symbols, option, state);
}
BooleanValue::BooleanValue(InputSource& input, 
                                       ErrorHandler& XABSL_DEBUG_INIT(errorHandler))
{
  char buf[6];
  input.readString(buf,5);

  value = (strcmp("true",buf) == 0);
  
  XABSL_DEBUG_INIT(errorHandler.message("created boolean value: \"%s\"",value?"true":"false"));
}
예제 #9
0
TransitionToState::TransitionToState(InputSource& input,    
                                                 ErrorHandler& errorHandler,
                                                 Array<State*>& states)
{
  char buf[100];
  input.readString(buf,99);
  
  nextState = states[buf];
  
  XABSL_DEBUG_INIT(errorHandler.message("creating a transition to state \"%s\"",nextState->n));
}
예제 #10
0
void State::create(InputSource& input,
                         Array<Option*>& options,
                         Array<BasicBehavior*>& basicBehaviors,
                         Array<State*>& states,
                         OptionParameters& parameters,
                         Symbols& symbols,
                         unsigned& timeOfOptionExecution)
{ 
  XABSL_DEBUG_INIT(errorHandler.message("creating state \"%s\"",n));

  char c[100]; 
  int i;
  
  // target state or not
  input.readString(c,1);
  if (*c == '1') 
  {
    targetState = true;
  }
  
  // subsequent option, basic behaviors and output symbol assignments
  int numberOfActions = (int)input.readValue();
  
  subsequentOption = 0;
  for(i = 0; i< numberOfActions; i++)
  {
    Action* action = 
      Action::create(input, 
                      options, 
                      basicBehaviors, 
                      parameters, 
                      symbols, 
                      timeOfOptionExecution, 
                      timeOfStateExecution,
                      actions,
                      errorHandler,
                      pTimeFunction);
    if (errorHandler.errorsOccurred)
    {
      errorHandler.error("XabslState::create(): could not create action for state \"%s\"",n);
      return;
    }
    if (subsequentOption == 0)
      if (ActionOption* actionOption = dynamic_cast<ActionOption*>(action)) 
        subsequentOption = actionOption->option;
    actions.append("", action);
  }
  
  // transition to state or if / else block
  decisionTree = Statement::createStatement(input,actions,errorHandler,
    states,parameters, symbols, timeOfOptionExecution,timeOfStateExecution);
  if (errorHandler.errorsOccurred)
    errorHandler.error("XabslState::create(): could not create decision tree for state \"%s\"",n);
}
예제 #11
0
void Symbols::registerBooleanOutputSymbol(const char* name, bool* pVariable)
{
  XABSL_DEBUG_INIT(errorHandler.message("registering boolean output symbol \"%s\"",name));
  
  if (booleanOutputSymbols.exists(name))
  {
    errorHandler.error("registerBooleanOutputSymbol(): symbol \"%s\" was already registered",name);
    return;
  }
  booleanOutputSymbols.append(name,new BooleanOutputSymbol(name, pVariable));
}
예제 #12
0
void Symbols::registerDecimalInputSymbol(const char* name, const double* pVariable)
{
  XABSL_DEBUG_INIT(errorHandler.message("registering decimal input symbol \"%s\"",name));
  
  if (decimalInputSymbols.exists(name))
  {
    errorHandler.error("registerDecimalInputSymbol(): symbol \"%s\" was already registered",name);
    return;
  }
  decimalInputSymbols.append(name,new DecimalInputSymbol(name, pVariable, errorHandler));
}
예제 #13
0
void Symbols::registerBooleanInputSymbol(const char* name, FunctionProvider* pInstance,
                                               bool (FunctionProvider::*pFunction)())
{
  XABSL_DEBUG_INIT(errorHandler.message("registering boolean input symbol \"%s\"",name));
  
  if (booleanInputSymbols.exists(name))
  {
    errorHandler.error("registerBooleanInputSymbol(): symbol \"%s\" was already registered",name);
    return;
  }
  booleanInputSymbols.append(name,new BooleanInputSymbol(name, pInstance, pFunction, errorHandler));
}
예제 #14
0
void Parameters::registerDecimal(const char* name, double& parameter)
{
  XABSL_DEBUG_INIT(errorHandler.message("registering decimal parameter \"%s\"",name));
  
  if (decimal.exists(name))
  {
    errorHandler.error("registerDecimalParameter(): decimal parameter \"%s\" was already registered",name);
    return;
  }
  decimal.append(name,&parameter);
  parameter = 0;
}
예제 #15
0
void Parameters::registerBoolean(const char* name, bool& parameter)
{
  XABSL_DEBUG_INIT(errorHandler.message("registering boolean parameter \"%s\"",name));
  
  if (boolean.exists(name))
  {
    errorHandler.error("registerBooleanParameter(): boolean parameter \"%s\" was already registered",name);
    return;
  }
  boolean.append(name,&parameter);
  parameter = false;
}
예제 #16
0
void Symbols::registerDecimalInputSymbolParametersChanged(const char* name,
    void (*pFunction)())
{
  XABSL_DEBUG_INIT(errorHandler.message("registering parameter change notification for decimal input symbol\"%s\"",name));

  if (!decimalInputSymbols.exists(name))
  {
    errorHandler.error("registerDecimalInputSymbolParametersChanged(): symbol \"%s\" was not registered",name);
    return;
  }

  decimalInputSymbols[name]->pParametersChanged = pFunction;
}
예제 #17
0
void Symbols::registerDecimalInputSymbol
(const char* name,
 double (*pFunction)())
{
  XABSL_DEBUG_INIT(errorHandler.message("registering decimal input symbol \"%s\"",name));
  
  if (decimalInputSymbols.exists(name))
  {
    errorHandler.error("registerDecimalInputSymbol(): symbol \"%s\" was already registered",name);
    return;
  }
  decimalInputSymbols.append(name,new DecimalInputSymbol(name, pFunction, errorHandler, decimalInputSymbols.getSize()));
}
예제 #18
0
IfElseBlock::IfElseBlock(InputSource& input,    
                                     Array<Action*>& actions,
                                     ErrorHandler& errorHandler,
                                     Array<State*>& states,
                                     OptionParameters& parameters,
                                     Symbols& symbols,    
                                     unsigned long& timeOfOptionExecution,
                                     unsigned long& timeOfStateExecution) :
ifCondition(0), ifStatement(0), elseStatement(0)
{
  
  // if case
  XABSL_DEBUG_INIT(errorHandler.message("creating if statement"));
  
  ifCondition = BooleanExpression::create(input, actions, errorHandler, 
    parameters, symbols, timeOfOptionExecution, timeOfStateExecution);
  if (errorHandler.errorsOccurred)
  {
    errorHandler.error("XabslIfElseBlock::IfElseBlock(): could not create if condition");
    return;
  }
  
  ifStatement = Statement::createStatement(input,actions, errorHandler,
    states,parameters, symbols, timeOfOptionExecution, timeOfStateExecution);
  if (errorHandler.errorsOccurred)
  {
    errorHandler.error("XabslIfElseBlock::IfElseBlock(): could not create if statement");
    return;
  }
    
  // else case
  XABSL_DEBUG_INIT(errorHandler.message("creating else statement"));
  
  elseStatement = Statement::createStatement(input, actions,
    errorHandler, states, parameters, symbols, timeOfOptionExecution, timeOfStateExecution);
  if (errorHandler.errorsOccurred)
    errorHandler.error("XabslIfElseBlock::IfElseBlock(): could not create else statement");
  
}
예제 #19
0
void Symbols::registerDecimalOutputSymbol(const char* name, FunctionProvider* pInstance,
  void (FunctionProvider::*pSetFunction)(double),
  double (FunctionProvider::*pGetFunction)()
)
{
  XABSL_DEBUG_INIT(errorHandler.message("registering decimal output symbol \"%s\"",name));
  
  if (decimalOutputSymbols.exists(name))
  {
    errorHandler.error("registerDecimalOutputSymbol(): symbol \"%s\" was already registered",name);
    return;
  }
  decimalOutputSymbols.append(name,new DecimalOutputSymbol(name, pInstance, pSetFunction, pGetFunction));
}
예제 #20
0
void Symbols::registerBooleanOutputSymbol(const char* name,
  void (*pSetFunction)(bool),
  bool (*pGetFunction)()
)
{
  XABSL_DEBUG_INIT(errorHandler.message("registering boolean output symbol \"%s\"",name));
  
  if (booleanOutputSymbols.exists(name))
  {
    errorHandler.error("registerBooleanOutputSymbol(): symbol \"%s\" was already registered",name);
    return;
  }
  booleanOutputSymbols.append(name,new BooleanOutputSymbol(name, pSetFunction, pGetFunction, booleanOutputSymbols.getSize()));
}
예제 #21
0
void Symbols::registerEnumeratedOutputSymbol(const char* name, const char* enumName, int* pVariable)
{
  XABSL_DEBUG_INIT(errorHandler.message("registering enumerated output symbol \"%s\"",name));
  
  if (enumeratedOutputSymbols.exists(name))
  {
    errorHandler.error("registerEnumeratedOutputSymbol(): symbol \"%s\" was already registered",name);
    return;
  }
  if (!enumerations.exists(enumName))
  {
    enumerations.append(enumName, new Enumeration(enumName));
  }
  enumeratedOutputSymbols.append(name,new EnumeratedOutputSymbol(name, enumerations[enumName], pVariable));
}
예제 #22
0
void Symbols::registerEnumElement(const char* symbolName, const char* name, int value)
{
  XABSL_DEBUG_INIT(errorHandler.message("registering enum element \"%s\" for enumeration \"%s\"",name, symbolName));

  if (!enumerations.exists(symbolName))
  {
    enumerations.append(symbolName, new Enumeration(symbolName));
  }
  if (enumerations[symbolName]->enumElements.exists(name))
  {
    errorHandler.error("registerEnumElement(): enum element \"%s\" for enumeration \"%s\" was already registered.", name, symbolName);
    return;
  }
  enumerations[symbolName]->enumElements.append(name, new EnumElement(name,value));
}
예제 #23
0
void Engine::registerBasicBehavior(BasicBehavior& basicBehavior)
{
  XABSL_DEBUG_INIT(errorHandler.message("registering basic behavior \"%s\"",basicBehavior.n));

  if (basicBehaviors.exists(basicBehavior.n))
  {
    errorHandler.error("registerBasicBehavior(): basic behavior \"%s\" was already registered",basicBehavior.n);
    return;
  }

  basicBehavior.parameters->registerEnumerations(enumerations);
  basicBehavior.registerParameters();

  basicBehavior.index = basicBehaviors.getSize();
  basicBehaviors.append(basicBehavior.n,&basicBehavior);
}
예제 #24
0
void Symbols::registerEnumeratedInputSymbol(const char* name, const char* enumName, FunctionProvider* pInstance,
    int (FunctionProvider::*pFunction)())
{
  XABSL_DEBUG_INIT(errorHandler.message("registering enumerated input symbol \"%s\"",name));
  
  if (enumeratedInputSymbols.exists(name))
  {
    errorHandler.error("registerEnumeratedInputSymbol(): symbol \"%s\" was already registered",name);
    return;
  }
  if (!enumerations.exists(enumName))
  {
    enumerations.append(enumName, new Enumeration(enumName));
  }
  enumeratedInputSymbols.append(name,new EnumeratedInputSymbol(name, enumerations[enumName], pInstance, pFunction, errorHandler));
}
BooleanOutputSymbolRef::BooleanOutputSymbolRef(InputSource& input, 
                                                               ErrorHandler& errorHandler,
                                                               Symbols& symbols)
{
  char buf[100];
  input.readString(buf,99);
  
  XABSL_DEBUG_INIT(errorHandler.message("creating a reference to a boolean output symbol \"%s\"",buf));
  
  if (!symbols.booleanOutputSymbols.exists(buf))
  {
    errorHandler.error("XabslBooleanOutputSymbolRef::BooleanOutputSymbolRef(): boolean output symbol \"%s\" was not registered",buf);
    return;
  }
  
  symbol = symbols.booleanOutputSymbols[buf];
}
BooleanOptionParameterRef::BooleanOptionParameterRef(InputSource& input, 
                                                   ErrorHandler& errorHandler,
                                                   Option& option)
{
  char buf[100];
  input.readString(buf,99);
  
  XABSL_DEBUG_INIT(errorHandler.message("creating a reference to boolean option parameter \"%s\"",buf));
  
  if (!option.parameters->boolean.exists(buf))
  {
    errorHandler.error("XabslBooleanOptionParameterRef::BooleanOptionParameterRef(): boolean option parameter \"%s\" does not exist",buf);
    return;
  }
  
  parameter = option.parameters->boolean.getPElement(buf)->e;
}
예제 #27
0
DecimalOptionParameterRef::DecimalOptionParameterRef(InputSource& input, 
                                                   ErrorHandler& errorHandler,
                                                   OptionParameters& parameters)
{
  char buf[100];
  input.readString(buf,99);
  
  XABSL_DEBUG_INIT(errorHandler.message("creating a reference to decimal option parameter \"%s\"",buf));
  
  if (!parameters.decimal.exists(buf))
  {
    errorHandler.error("XabslDecimalOptionParameterRef::DecimalOptionParameterRef(): decimal option parameter \"%s\" does not exist",buf);
    return;
  }
  
  parameter = parameters.decimal.getPElement(buf)->e;
}
예제 #28
0
void Symbols::registerEnumeratedOutputSymbol(const char* name, const char* enumName,
  void (*pSetFunction)(int),
  int (*pGetFunction)()
)
{
  XABSL_DEBUG_INIT(errorHandler.message("registering enumerated output symbol \"%s\"",name));
  
  if (enumeratedOutputSymbols.exists(name))
  {
    errorHandler.error("registerEnumeratedOutputSymbol(): symbol \"%s\" was already registered",name);
    return;
  }
  if (!enumerations.exists(enumName))
  {
    enumerations.append(enumName, new Enumeration(enumName, enumerations.getSize()));
  }
  enumeratedOutputSymbols.append(name,new EnumeratedOutputSymbol(name, enumerations[enumName], pSetFunction, pGetFunction, enumeratedOutputSymbols.getSize()));
}
예제 #29
0
void Symbols::registerEnumeratedInputSymbolDecimalParameter(const char* symbolName, 
    const char* name, double& param)
{
  XABSL_DEBUG_INIT(errorHandler.message("registering decimal parameter \"%s\" for enumerated input symbol\"%s\"",name, symbolName));

  if (!enumeratedInputSymbols.exists(symbolName))
  {
    errorHandler.error("registerEnumeratedInputSymbolDecimalParameter(): symbol \"%s\" was not registered",symbolName);
    return;
  }
  if (enumeratedInputSymbols[symbolName]->parameters.decimal.exists(name))
  {
    errorHandler.error("registerEnumeratedInputSymbolDecimalParameter(): parameter \"%s\" was already registered",name);
    return;
  }

  enumeratedInputSymbols[symbolName]->parameters.decimal.append(name,&param);
}
예제 #30
0
void Symbols::registerDecimalInputSymbolBooleanParameter(const char* symbolName, 
    const char* name, bool& param)
{
  XABSL_DEBUG_INIT(errorHandler.message("registering boolean parameter \"%s\" for decimal input symbol\"%s\"",name, symbolName));

  if (!decimalInputSymbols.exists(symbolName))
  {
    errorHandler.error("registerDecimalInputSymbolBooleanParameter(): symbol \"%s\" was not registered",symbolName);
    return;
  }
  if (decimalInputSymbols[symbolName]->parameters.boolean.exists(name))
  {
    errorHandler.error("registerDecimalInputSymbolBooleanParameter(): parameter \"%s\" was already registered",name);
    return;
  }

  decimalInputSymbols[symbolName]->parameters.boolean.append(name,&param);
}