Exemple #1
0
// Dispatches the given context to the given table, if it exists.
// Accepts a variadic list of fields needed to construct a key to
// match against the table.
void
fp_goto_table(fp::Context* cxt, fp::Table* tbl, int n, ...)
{
  va_list args;
  va_start(args, n);
  fp::Key key = fp_gather(cxt, tbl->key_size(), n, args);
  va_end(args);

  // std::cout << "KEY: ";
  // for (int i = 0; i < tbl->key_size(); ++i)
  //   std::cout << std::hex << (int) key.data[i];
  // std::cout << '\n';

  fp::Flow flow = tbl->search(key);
  // execute the flow function
  flow.instr_(&flow, tbl, cxt);

  // testing find times
  // static fp::Byte b[fp::key_size];
  // static fp::Key key(b, 8);
  // fp::Flow const& flow = tbl->search(key);
  // execute the flow function
  // flow.instr_(tbl, cxt);

  // static fp::Flow const& flow = dynamic_cast<fp::Hash_table*>(tbl)->begin()->second;
  // flow.instr_(tbl, cxt);
}
Exemple #2
0
// Dispatches the given context to the given table, if it exists.
// Accepts a variadic list of fields needed to construct a key to
// match against the table.
void
fp_goto_table(fp::Context* cxt, fp::Table* tbl, int n, ...)
{
  va_list args;
  va_start(args, n);
  fp::Key key = fp_gather(cxt, tbl->key_size(), n, args);
  va_end(args);
  // find the flow
  fp::Flow const& flow = tbl->find(key);
  // execute the flow function
  flow.instr_(tbl, cxt);
}