⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 time_node.cpp

📁 彩信浏览器
💻 CPP
📖 第 1 页 / 共 5 页
字号:
		timestamp.as_time_value_down_to(this),		timestamp.second(), 		timestamp.as_doc_time_value());	on_add_instance(timestamp, tn_focusout_event, timestamp.second);}void time_node::raise_accesskey(std::pair<qtime_type, int> accesskey) {	qtime_type timestamp = accesskey.first;	int ch = accesskey.second;	timestamp.to_descendent(sync_node());	AM_DBG m_logger->debug("%s[%s].raise_activate_event() ST:%ld, PT:%ld, DT:%ld", m_attrs.get_tag().c_str(), 		m_attrs.get_id().c_str(), 		timestamp.as_time_value_down_to(this),		timestamp.second(), 		timestamp.as_doc_time_value());	on_add_instance(timestamp, accesskey_event, timestamp.second, ch);}void time_node::raise_update_event(qtime_type timestamp) {	m_update_event.first = true;	m_update_event.second = timestamp;}///////////////////////////////// Global operations// Called when the beginEvent or the repeat event// is raised by an ancestor time container.//// A reset operation sets this node to the same state this object had// when it was created except that, after a reset it may contain // in its begin or end lists some syncbased instances.//void time_node::reset(qtime_type timestamp, time_node *oproot) {	// 1. Reset children with resepect to oproot.	std::list<time_node*> children;	get_children(children);	std::list<time_node*>::iterator it;	qtime_type qt = timestamp.as_qtime_down_to(this);	for(it = children.begin(); it != children.end(); it++)		(*it)->reset(qt, oproot);		// 2. Reset state variables and enter the reset state	// The following call in effect calls:	// any_state::reset() => any_state::exit() + reset_state::enter()	// Deactivated nodes will raise an endEvent 	// This should should not update dependents within this branch (use oproot to impl this)	m_state->reset(timestamp, oproot);		if(m_timer) m_timer->stop();		// 3. Reset this instance times with resepect to oproot.	rule_list::iterator it2;	for(it2=m_begin_list.begin();it2!=m_begin_list.end();it2++)		(*it2)->reset(oproot);	for(it2=m_end_list.begin();it2!=m_end_list.end();it2++)		(*it2)->reset(oproot);}// Called when a node repeats or when its deactivated (restart or nomal end)void time_node::reset_children(qtime_type timestamp, time_node *oproot) {	std::list<time_node*> children;	get_children(children);	std::list<time_node*>::iterator it;	qtime_type qt = timestamp.as_qtime_down_to(this);	for(it = children.begin(); it != children.end(); it++)		(*it)->reset(qt, oproot);}void time_node::startup_children(qtime_type timestamp) {	std::list<time_node*> children;	get_children(children);	std::list<time_node*>::iterator it;	qtime_type qt = timestamp.as_qtime_down_to(this);	for(it = children.begin(); it != children.end(); it++)		(*it)->set_state(ts_proactive, qt, this);}void time_node::kill(qtime_type timestamp, time_node *oproot) {	// The following will deactivate this	// the active::exit() will propagate this opation to the children  	m_state->kill(timestamp, oproot);	}void time_node::kill_children(qtime_type timestamp, time_node *oproot) {	std::list<time_node*> children;	get_children(children);	std::list<time_node*>::iterator it;	qtime_type qt = timestamp.as_qtime_down_to(this);	for(it = children.begin(); it != children.end(); it++) {		if((*it)->is_link() && oproot == (*it)->up())			(*it)->set_state(ts_postactive, qt, oproot);		else			(*it)->kill(qt, oproot);	}}// Meta model reset// Brings this node to its initial state without propagating events// The function resets all the state variables of this class// To simplify verfication all variables defined by the class def are copied here.void time_node::reset() {	///////////////////////////	// 1. Reset visuals		if(m_needs_remove)		stop_playable();	///////////////////////////	// 2. Reset state variables		// Structure var	// context_type *m_context;		// The underlying DOM node	// Mimimize or eliminate usage after timegraph construction 	// Structure var	// const node *m_node;		// Attributes parser	// Structure var	// time_attrs m_attrs;		// The time type of this node	// Structure var	// time_container_type m_type;		// The intrinsic time type of this node 	// Always false for time containers	// Structure var	// bool m_discrete;				// The timer assigned to this node by the timegraph builder	// lib::timer *m_timer;	if(m_timer) m_timer->stop();		// The lifetime state of this node.	// Summarizes the state variables below.	// For each state the analytic state variables below 	// take particular values.	// time_state	*m_state;	m_state = m_time_states[ts_reset]; 		// Smil timing calculator	// Structure var	// time_calc *m_time_calc;		// The current interval associated with this time node.	// When this has not a current interval this is set to unresolved	// interval_type m_interval;	m_interval = interval_type::unresolved; 		// Past intervals	// Some intervals may have not "played" but they did	// affected the state of the model by propagating 	// time change notifications.	// Canceled intervals do not contribute.	// std::list<interval_type> m_history;	m_history.clear();		// std::list<interval_type> m_doc_history;	m_doc_history.clear();		// Flag set when this is active 	// e.g during the current interval	// bool m_active;	m_active = false;		// Flag set when this node has finished an interval,	// has called start against its peer playable but not stop yet.	// e.g there maybe display effects that should be removed	// == this has to call stop() against its peer playable.	// bool m_needs_remove;	m_needs_remove = false;		// The following 2 state variables are incemented when the node is active  	// and it repeats: 	// m_rad += m_last_cdur; m_precounter++;		// Accumulated repeat duration	// Incremented after the completion of a simple dur	// Last begin or repeat instance as measured by the AD timer of this node.	// time_type m_rad;	m_rad = 0;			// Number of completed repeat counts	// e.g. the current zero-based repeat index	// long m_precounter;	m_precounter = 0;		// EOM flag	// bool m_eom_flag;	m_eom_flag = false;		// The priority of this node	// Applicable for excl children.	// Structure var	// int m_priority;		// Paused flag	// bool m_paused;	m_paused = false;			// Accumulated pause duration	//time_type m_pad;	m_pad = 0;		// Register for storing pause time	// time_type m_paused_sync_time;	m_paused_sync_time = 0;		// Defered flag	// bool m_deferred;	m_deferred = false;		// Sync update event	//std::pair<bool, qtime_type> m_update_event;	m_update_event.first = false;		// Sync rules	// typedef std::list<sync_rule*> rule_list;		// The begin sync rules of this node.	// Structure var but the lists should be cleared	// rule_list m_begin_list;	rule_list::iterator it1;	for(it1=m_begin_list.begin();it1!=m_begin_list.end();it1++)		(*it1)->reset(0);		// The end sync rules of this node.	// Structure var but the lists should be cleared	// rule_list m_end_list;	for(it1=m_end_list.begin();it1!=m_end_list.end();it1++)		(*it1)->reset(0);		// On reset all event instances are cleared. 	// Keep a register for holding one such instance	// The one that will start the current interval	// time_type m_begin_event_inst;	m_begin_event_inst = time_type::unresolved;		// Special DOM calls sync rule of this node.	// sync_rule *m_domcall_rule;	if(m_domcall_rule) m_domcall_rule->reset(0);		// The dependents of this node.	// Use pointers to minimize the overhead when there are no dependents	//typedef std::map<sync_event, rule_list* > dependency_map;	// dependency_map m_dependents;			// preventing cycles flag	// bool m_locked;	m_locked = false;		// when set the associated renderer should notify for activate events	// Structure var	//  bool m_want_activate_events;		// when set the associated UI should notify for accesskey events	// Structure var	// bool m_want_accesskey;			// Cashed implicit duration of a continous media node (audio, video).	// time_type m_impldur;	m_impldur = time_type::unresolved;		// Last calc_dur() result	m_last_cdur = time_type::unresolved;		// Time states	// Structure var	// time_state* m_time_states[ts_dead+1];    	// Structure vars	// timing-tree bonds	// time_node *m_parent;	// time_node *m_next;	// time_node *m_child;	}///////////////////////////////// Timing measurements// Currently the timer:// Starts ticking at the active duration offset when the node is activated// Progress while this node is active and playing// Is paused when the the node or an ancestor is paused while active // Pauses or stops when the node is deactivated // Returns the simple time of this node.time_node::value_type time_node::get_simple_time() const {	if(!m_timer) return 0;		// The AD offset of this node	// Any pause intervals are not included (see accumulated pause dur: pad)	// The total time this node has been active is: ad_offset + m_pad	time_type ad_offset = m_timer->elapsed();		// The SD offset of this node	time_type sd_offset = ad_offset - m_rad;	return sd_offset();}// Returns the current interval end taking into account pausingtime_node::time_type time_node::get_interval_end() const {	if(m_time_calc->uses_dur())		return m_interval.end + m_pad;	return m_interval.end;}// Returns the time elapsed since the beginning of // the interval taking into account pausing.// The node should be active and playing.// When paused the value returned will not take into acount the paused periodtime_node::value_type time_node::get_time() const {	if(!m_timer) return 0;	return m_timer->elapsed() + m_pad();}/////////////////////////////////////////////////////// time_container overrides// The implicit duration of a par is controlled by endsync. // By default, the implicit duration of a par is defined by // the endsync="last" semantics. The implicit duration ends // with the last active end of the child elements. time_node::time_type time_container::get_implicit_dur() {	if(!down()) return 0;	endsync_rule esr = m_attrs.get_endsync_rule();	time_type idur = time_type::unresolved;	std::list<const time_node*> cl;	get_children(cl);	switch(esr) {		case esr_first:			idur = 	calc_implicit_dur_for_esr_first(cl);			break;		case esr_last:			idur = 	calc_implicit_dur_for_esr_last(cl);			break;		case esr_all:			idur = 	calc_implicit_dur_for_esr_all(cl);			break;		case esr_id:				idur = 	calc_implicit_dur_for_esr_id(cl);			break;			default:			idur = 	calc_implicit_dur_for_esr_last(cl);			break;	}	return idur;}// Returns the minimum of the children first intervals end// If no child has a valid interval returns "unresolved"// Played intervals count time_node::time_type time_container::calc_implicit_dur_for_esr_first(std::list<const time_node*>& cl) {	std::list<const time_node*>::const_iterator it;	time_type idur = time_type::unresolved;	for(it=cl.begin();it!=cl.end();it++) {		const time_node *c = *it;		const interval_type& i = c->get_first_interval();		if(i.is_valid())			idur = std::min(idur, c->get_interval_end());	}	AM_DBG m_logger->debug("%s[%s].calc_implicit_dur_for_esr_first(): %s", m_attrs.get_tag().c_str(), 		m_attrs.get_id().c_str(), ::repr(idur).c_str());			return idur;	}// Returns the interval end of the designated child// If the designated child has not a valid interval returns "unresolved"time_node::time_type time_container::calc_implicit_dur_for_esr_id(std::list<const time_node*>& cl) {	std::list<const time_node*>::const_iterator it;	time_type idur = time_type::unresolved;	std::string endsync_id = m_attrs.get_endsync_id();	for(it=cl.begin();it!=cl.end();it++) {		const time_node *c = *it;		if(endsync_id == c->get_time_attrs()->get_id()) {			const interval_type& i = c->get_first_interval();			if(i.is_valid()) idur = c->get_interval_end();			break;		}	}	AM_DBG m_logger->debug("%s[%s].calc_implicit_dur_for_esr_id(): %s", m_attrs.get_tag().c_str(), 		m_attrs.get_id().c_str(), ::repr(idur).c_str());			return idur;	}// Returns the maximum of the children interval ends// This maybe called before the children go live, consider this case// The current interval may not be the first [(*it)->played() maybe true]// This is the default for par, excl, media_cond// If the children are alive and there is

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -