Update: UltraVNC 1.4.3.6 and UltraVNC SC 1.4.3.6: https://forum.uvnc.com/viewtopic.php?t=37885
Important: Please update to latest version before to create a reply, a topic or an issue: https://forum.uvnc.com/viewtopic.php?t=37864

Join us on social networks and share our announcements:
- Website: https://uvnc.com/
- GitHub: https://github.com/ultravnc
- Mastodon: https://mastodon.social/@ultravnc
- Facebook: https://www.facebook.com/ultravnc1
- X/Twitter: https://x.com/ultravnc1
- Reddit community: https://www.reddit.com/r/ultravnc
- OpenHub: https://openhub.net/p/ultravnc

Some rare usage in the source code

Post Reply
zonesowhat
8
8
Posts: 20
Joined: 2014-04-12 07:44

Some rare usage in the source code

Post by zonesowhat »

Firstly,the code:

Code: Select all

rfbUpdateTracker.h
...
class UpdateTracker {
	public:
		UpdateTracker() {};
		virtual ~UpdateTracker() {};

		virtual void add_changed(const Region2D &region) = 0;
	        ...		
	};

	class ClippedUpdateTracker : public UpdateTracker {
	public:
		...
		ClippedUpdateTracker(UpdateTracker &child_,
			const Region2D &cliprgn_) : child(child_), cliprgn(cliprgn_) {};
		virtual ~ClippedUpdateTracker() {};

		virtual void add_changed(const Region2D &region);
		...

	protected:
		UpdateTracker &child;
		Region2D cliprgn;
	};
...
rfbUpdateTracker.cpp
...
void ClippedUpdateTracker::add_changed(const Region2D &region) {
	child.add_changed(region.intersect(cliprgn));
...
}
Then,the problems:
1:There exists a reference of SuperClass in the subclass. I guess that it provides a convenient calling for using a reference of a instantiated subclass object as the function's variable.
2:How does the functions,such as add_changed, in subclass run?That is to say, what is the calling order .The function add_changed of subclass uses the reference of superclass to generate a callling to the same function of superclass,but the superclass is an abstract class to which the calling results a calling to the function implemented in subclass.
Is it a cyclic calling?
zonesowhat
8
8
Posts: 20
Joined: 2014-04-12 07:44

Re: Some rare usage in the source code

Post by zonesowhat »

Does it cause a calling to the corresponding function of the subclass SimpleUpdateTracker?

Code: Select all

rfbUpdateTracker.h
...
class SimpleUpdateTracker : public UpdateTracker {
	public:
		SimpleUpdateTracker(bool use_copyrect=false);
		virtual ~SimpleUpdateTracker();

		virtual void enable_copyrect(bool enable) {copy_enabled=enable;};

		virtual void add_changed(const Region2D &region);
		virtual void add_cached(const Region2D &region);
		virtual void add_copied(const Region2D &dest, const Point &delta);

		// Fill the supplied UpdateInfo structure with update information
		// Also removes the updates that are returned from the update tracker
		virtual void flush_update(UpdateInfo &info, const Region2D &cliprgn);
		virtual void flush_update(UpdateTracker &info, const Region2D &cliprgn);

		// Pass the current updates to the supplied tracker
		// Does not affect internal state of this tracker
		virtual void get_update(UpdateInfo &to) const;
		virtual void get_update(UpdateTracker &to) const;

		// Get the changed/copied regions
		virtual const Region2D& get_changed_region() const {return changed;};
		virtual const Region2D& get_cached_region() const {return cached;};
		virtual const Region2D& get_copied_region() const {return copied;};


		virtual bool is_empty() const {return changed.is_empty() && copied.is_empty() && cached.is_empty();};

		virtual void clear() {
			changed.clear();
			copied.clear();
			cached.clear();
		};
	protected:
		Region2D changed;
		Region2D cached;
		Region2D copied;
		Point copy_delta;
		bool copy_enabled;
	};
...
rfbUpdateTracker.cpp
...
void SimpleUpdateTracker::add_changed(const Region2D &region) {
	changed.assign_union(region);
}
...
zonesowhat
8
8
Posts: 20
Joined: 2014-04-12 07:44

Re: Some rare usage in the source code

Post by zonesowhat »

I have got the point.The problems has been solved by myself.
Post Reply