Esempio n. 1
0
void RtDataStore::setAvailableData(RtDataID dataID) {

  // remove timepoint if one is set
  if(dataID.getTimePoint() != DATAID_NUM_UNSET_VALUE) {
    dataID.setTimePoint(DATAID_NUM_WILDCARD_VALUE);
  }

  // put data id into available data (insert will only add a unique value)
  // TODO will a position iterator add any efficiency here?
  availableData.insert(dataID);

}
Esempio n. 2
0
// process a single acquisition
int RtDataViewer::process(ACE_Message_Block *mb) {
  ACE_TRACE(("RtDataViewer::process"));

  RtStreamMessage *msg = (RtStreamMessage*) mb->rd_ptr();

  // get the current time
  unsigned int time = msg->getCurrentData()->getDataID().getTimePoint();

  // debug
  getDataStore().getAvailableData();

  RtDataID id;
  // find all data requested
  for(vector<string>::iterator i = dataIds.begin(); i != dataIds.end(); i++) {
    id.setFromString(*i);

    if(id.getTimePoint() != DATAID_NUM_UNSET_VALUE
       && id.getTimePoint() != DATAID_NUM_WILDCARD_VALUE) {
      id.setTimePoint(time);
    }

    cout << "RtDataViewer::process: searching for " << id
         << " from " << *i << endl;

    // find the data with the right ID
    RtData *dat = getDataStore().getData(id);

    if(dat == NULL) {
      cout << "RtDataViewer::process: could not find " << id << endl;
      if(logOutput) {
        stringstream logs("");
        logs << "RtDataViewer::process: could not find " << id << endl;
        log(logs);
      }
    }
    else {
      cout << "RtDataViewer::process: found " << dat->getDataID() << endl;
      if(logOutput) {
        stringstream logs("");
        logs << "RtDataViewer::process: found "
             << dat->getDataID() << endl;
        log(logs);
      }
    }
  }

  return 0;
}
Esempio n. 3
0
// get data by id
//
// NOTE: this function is much more efficient if the requested data is
// specified fully, i.e. there are no wildcards in the dataID (see RtDataID.h)
// avoid using wildcards if possible
RtData *RtDataStore::getData(RtDataID dataID) {

  // fill in wildcards (search through available data makes this inefficient)
  if(dataID.hasWildcards()) {
    // find corresponding full id by an exhaustive search through available
    // data
    for(set<RtDataID>::const_iterator id = availableData.begin();
        id != availableData.end(); id++) {
      RtDataID avail = (*id);

      // handle potential timepoint-less data
      unsigned int tp = avail.getTimePoint();
      if(dataID.getTimePoint() != DATAID_NUM_UNSET_VALUE) {
        avail.setTimePoint(DATAID_NUM_WILDCARD_VALUE);
      }
      else {
        avail.setTimePoint(DATAID_NUM_UNSET_VALUE);

      }

      if (avail == dataID) { // == respects wildcards
        // copy, preserving timepoint if not a timepointless datum
        unsigned int origTp = dataID.getTimePoint();
        dataID = avail;

        if(tp != DATAID_NUM_UNSET_VALUE) {
          dataID.setTimePoint(origTp);
        }
        else {
          dataID.setTimePoint(tp);
        }

        break;
      }
    }

    // finally, handle wildcard in timepoint field by using the latest timepoint
    if (dataID.getTimePoint() == DATAID_NUM_WILDCARD_VALUE) {
      dataID.setTimePoint(latestTR);
    }

    if(dataID.hasWildcards()) {
      cerr << "filling in wildcards failed. no match found." << endl;
      return NULL;
    }
  }

  // iterator for map
  map<RtDataID,RtData*,RtDataIDCompare>::const_iterator it;

  mut.acquire();
  it = store.find(dataID);

  // if not found
  if(it == store.end()) {
    mut.release();
    return NULL;
  }
  mut.release();

  return (*it).second;
}