slide 22 of 40


C++ RSM Templates

template<class actualT>
class shared {
public:
  actualT operator= (actualT rhs);
  actualT operator= (shared<actualT> rhs);
  operator actualT ();
protected:
  volatile actualT data_;
};

template<class actualT>
inline shared<actualT>::operator actualT () {
  s_poll();
  return data_;
}

template<class actualT>
actualT shared<actualT>::operator= (actualT rhs) {
  register actualT temp_data_ = rhs;
  if (temp_data_ != data_) {
    data_ = rhs;
    s_update(((void *) &data_), sizeof(data_));
  } else {
    s_poll();
  }
  return temp_data_;
}

template<class actualT>
actualT shared<actualT>::operator= (shared<actualT> rhs) {
  register actualT temp_data_ = rhs.data_;
  if (temp_data_ != data_) {
    data_ = rhs;
    s_update(((void *) &data_), sizeof(data_));
  } else {
    s_poll();
  }
  return temp_data_;
}

shared<your_favorite_type> variables...