85 #include "../r_code/utils.h"
93 inline View::View() : r_code::_View(), controller_(NULL) {
95 code_[VIEW_OID].atom_ = GetOID();
101 code_[VIEW_OID].atom_ = GetOID();
105 inline View::View(
const View *view,
bool new_OID) : r_code::_View(), controller_(NULL) {
107 object_ = view->object_;
108 memcpy(code_, view->code_, VIEW_CODE_MAX_SIZE *
sizeof(Atom) + 2 *
sizeof(
r_code::Code *));
110 code_[VIEW_OID].atom_ = GetOID();
115 inline View::View(SyncMode sync,
121 r_code::Code *
object) : r_code::_View(), controller_(NULL) {
123 code(VIEW_OPCODE) = Atom::SSet(Opcodes::View, VIEW_ARITY);
124 init(sync, ijt, sln, res, destination, origin,
object);
127 inline View::View(SyncMode sync,
134 float32 act) : r_code::_View(), controller_(NULL) {
136 code(VIEW_OPCODE) = Atom::SSet(Opcodes::PgmView, PGM_VIEW_ARITY);
137 init(sync, ijt, sln, res, destination, origin,
object);
138 code(VIEW_ACT) = Atom::Float(act);
141 inline void View::init(SyncMode sync,
149 code_[VIEW_OID].atom_ = GetOID();
152 code(VIEW_SYNC) = Atom::Float((float32)sync);
153 code(VIEW_IJT) = Atom::IPointer(code(VIEW_OPCODE).getAtomCount() + 1);
154 r_code::Utils::SetTimestamp<View>(
this, VIEW_IJT, ijt);
155 code(VIEW_SLN) = Atom::Float(sln);
156 code(VIEW_RES) = res < 0 ? Atom::PlusInfinity() : Atom::Float((float32)res);
157 code(VIEW_HOST) = Atom::RPointer(0);
158 code(VIEW_ORG) = origin ? Atom::RPointer(1) : Atom::Nil();
160 references_[0] = destination;
161 references_[1] = origin;
166 inline void View::reset() {
173 inline uint32 View::get_oid()
const {
175 return code_[VIEW_OID].atom_;
178 inline bool View::is_notification()
const {
183 inline Group *View::get_host() {
185 uint32 host_reference = code(VIEW_HOST).asIndex();
186 return (Group *)references_[host_reference];
189 inline View::SyncMode View::get_sync() {
191 return (SyncMode)(uint32)code(VIEW_SYNC).asFloat();
194 inline float32 View::get_res() {
196 return code(VIEW_RES).asFloat();
199 inline float32 View::get_sln() {
201 return code(VIEW_SLN).asFloat();
204 inline float32 View::get_act() {
206 return code(VIEW_ACT).asFloat();
209 inline float32 View::get_vis() {
211 return code(GRP_VIEW_VIS).asFloat();
214 inline bool View::get_cov() {
216 if (object_->code(0).getDescriptor() == Atom::GROUP)
217 return code(GRP_VIEW_COV).asBoolean();
221 inline void View::mod_res(float32 value) {
223 if (code(VIEW_RES) == Atom::PlusInfinity())
229 inline void View::set_res(float32 value) {
231 if (code(VIEW_RES) == Atom::PlusInfinity())
233 acc_res_ += value - get_res();
237 inline void View::mod_sln(float32 value) {
243 inline void View::set_sln(float32 value) {
245 acc_sln_ += value - get_sln();
249 inline void View::mod_act(float32 value) {
255 inline void View::set_act(float32 value) {
257 acc_act_ += value - get_act();
261 inline void View::mod_vis(float32 value) {
267 inline void View::set_vis(float32 value) {
269 acc_vis_ += value - get_vis();
273 inline float32 View::update_sln_delta() {
275 float32 delta = get_sln() - initial_sln_;
276 initial_sln_ = get_sln();
280 inline float32 View::update_act_delta() {
282 float32 act = get_act();
283 float32 delta = act - initial_act_;
288 inline void View::force_res(float32 value) {
290 code(VIEW_RES) = Atom::Float(value);
293 inline void View::mod(uint16 member_index, float32 value) {
295 switch (member_index) {
311 inline void View::set(uint16 member_index, float32 value) {
313 switch (member_index) {
331 inline bool NotificationView::is_notification()
const {