المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Architectural problem



C++ Programming
04-05-2009, 09:01 PM
I've been trying to work out a design problem with one of my pet projects. Essentially, it works on the process of Streams. A program will write to a Stream; this is an abstract class which multiple classes inherit from. For example, a program will write to a Stream, and this could write to either a file or the system console

This all works rather well so far, but one of my additions has made things difficult. This is the daisy-chaining of Streams. A Stream can forward its data onto another Stream. The problem is that this is rather easy to take advantage of. Currently, there's nothing stopping a Stream from forwarding its data to itself, causing a recursive loop. I'm not using Windows in any way, so there's nothing to stop the loop from continuing until the stack overflows into the text segment, rewriting the kernel's code. Is there any way to stop this from happening?