// file: $isip/class/pr/ProductionRule/prdrl_06.cc
// version: $Id: prdrl_06.cc 10497 2006-03-15 21:40:16Z may $

// ISIP include files
//
#include "ProductionRule.h"

// method: length
//
long ProductionRule::length() const {
  return rule_d.length();
}

// method: removeCurr
//
boolean ProductionRule::removeCurr() {
  return rule_d.remove();
}

// method: gotoFirst
//
boolean ProductionRule::gotoFirst() {
  return rule_d.gotoFirst();
}

// method: gotoNext
//
boolean ProductionRule::gotoNext() {
  return rule_d.gotoNext();
}

// method: gotoPrev
//
boolean ProductionRule::gotoPrev() {
  return rule_d.gotoPrev();
}

// method: gotoPrev
//
boolean ProductionRule::gotoPosition(long position_a) {
  return rule_d.gotoPosition(position_a);
}

// method: setType
//
boolean ProductionRule::setType(ProductionRuleTokenType type_a) {
  if (rule_d.getCurr() != NULL) {
    return rule_d.getCurr()->first().assign(type_a);
  }
  return false;
}

// method: getType
//
ProductionRuleTokenType::TYPE ProductionRule::getType() {

  if (rule_d.getCurr() != NULL) {
    return rule_d.getCurr()->first().getType();
  }
  
  return ProductionRuleTokenType::NONE;
}

// method: getValue
//
String ProductionRule::getValue() {

  if (rule_d.getCurr() != NULL) {
    return rule_d.getCurr()->second();
  }
  
  return L"";
}

// method: setValue
//
boolean ProductionRule::setValue(String value_a) {

  if (rule_d.getCurr() != NULL) {
    return rule_d.getCurr()->second().assign(value_a);
  }
  
  return false;
}

// method: getWeight
//
Float ProductionRule::getWeight() {

  if (rule_d.getCurr() != NULL) {
    return rule_d.getCurr()->third();
  }
  
  return 0;  
}

// method: setWeight
//
boolean ProductionRule::setWeight(Float weight_a) {

  if (rule_d.getCurr() != NULL) {
    return rule_d.getCurr()->third().assign(weight_a);
  }
  
  return false;  
}

// method: insert
//
boolean ProductionRule::insert(const ProductionRuleTokenType::TYPE& type_a,
			       const String& value_a,
			       Float weight_a) {
  Triple<ProductionRuleTokenType, String, Float> temp;
  temp.first().setType(type_a);
  temp.second().assign(value_a);
  temp.third().assign(weight_a);
  return rule_d.insert(&temp);
}

// method: append
//
boolean ProductionRule::append(const ProductionRuleTokenType::TYPE& type_a,
			       const String& value_a,
			       Float weight_a) {
  Triple<ProductionRuleTokenType, String, Float> temp;
  temp.first().setType(type_a);
  temp.second().assign(value_a);
  temp.third().assign(weight_a);
  return rule_d.insertLast(&temp);
}

boolean ProductionRule::append(const ProductionRuleTokenType::TYPE& type_a,
			       const String& value_a) {
  Triple<ProductionRuleTokenType, String, Float> temp;
  temp.first().setType(type_a);
  temp.second().assign(value_a);
  temp.third().assign((float)0);
  return rule_d.insertLast(&temp);
}



