Main Page Namespace List Class Hierarchy Compound List File List Namespace Members Compound Members File Members Related Pages
Here we go. DGD::channel
makes no physical output, but makes formatting. To get the actual output we need to associate the channel with a physical stream e.g std::cout, sort of std::ofstream or any other object which is derived from std::ostream. There are three assoc()
functions for making the association: void assoc( std::ostream* s, channel& channel );
void assoc( std::ostream& s, channel& channel );
void assoc( std::ostream* s, const std::string& name );
All functions make the same job, but the later one assumes existence of the DGD::Debug factory and queries the channel object from the factory by the given name.
The only remaining tricky question about associations is: what if I make more then one association of the same channel, or more then one with the same physical stream? In fact DGD makes no restrictions on what do you associate, how and when. So, for example, it is legal to associate the same channel with std::cout and std::cerr, the channel will replicate its output into both streams. It is legal to register the same channel twice with the same stream, its output will be duplicated in this stream.
There are two additional association schemes worth to be mentioned here.
It is possible to associate two different channels with the same physical stream. But in this case DGD makes no garanties on validity of the resulting stream formatting. Surely, there is other simple way to avoid the problem and allow output from multiple channels into single physical buffer.
To avoid the problem mentioned above lets remind that assoc() functions accept any std::ostream as a physical stream and DGD::chnnel itself derives from std::ostream. So, it is possible to associate DGD::channel with another DGD::channel. Te problem could be solved by associating a single channel with a physical stream and then associating multiple other channels with that first channel. The example below demonstrates the soulution. Generated on Thu Aug 10 16:48:29 2006 for DGD Library by 1.3
|