resonance 1.0.1
Loading...
Searching...
No Matches
spewtable.h
Go to the documentation of this file.
1#pragma once
2
3#include <iostream>
4#include <vector>
5
6#include "os/hxstr.h"
7
19class SpewTable {
20public:
22 struct Channel {
29 Channel(const HxStr &name, std::ostream *pStream) : mName(name), mStream(pStream) {
30 }
31
33 std::ostream *mStream;
34 };
35
37 struct Connection {
45 Connection(const HxStr &file, std::ostream **ppStream, Channel *pChannel)
46 : mFile(file), mppStream(ppStream), mpChannel(pChannel) {
47 }
48
50 std::ostream **mppStream;
52 };
53
61
69
80 static SpewTable &shared() {
81 static SpewTable instance;
82 return instance;
83 }
84
96 void Register(std::ostream **ppStream, const char *pszFile);
97
110 void Connect(const HxStr &file, const HxStr &channel);
111
119 void PrintConnections(std::ostream &stream);
120
121private:
131 Channel *NewChannel(const HxStr &name);
132
141 void CloseChannels();
142
143 std::vector<Channel *> mChannels; // +0x00
144 std::vector<Connection> mConnections; // +0x0c
145};
Heap-allocated NUL-terminated string.
Definition hxstr.h:41
static SpewTable & shared()
Report the one registry, constructing it on first use.
Definition spewtable.h:80
void Connect(const HxStr &file, const HxStr &channel)
Point the registered streams of a source file at a channel.
void Register(std::ostream **ppStream, const char *pszFile)
Register a source file's stream pointer.
void PrintConnections(std::ostream &stream)
Write every registration and its channel name, one per line.
SpewTable()
Construct an empty registry.
~SpewTable()
Close every channel and release both lists.
Output channel, 0xc bytes, created by Connect() and destroyed by the destructor.
Definition spewtable.h:22
HxStr mName
Definition spewtable.h:32
Channel(const HxStr &name, std::ostream *pStream)
Construct a channel.
Definition spewtable.h:29
std::ostream * mStream
Definition spewtable.h:33
Channel * mpChannel
Definition spewtable.h:51
HxStr mFile
Definition spewtable.h:49
Connection(const HxStr &file, std::ostream **ppStream, Channel *pChannel)
Construct a registration.
Definition spewtable.h:45
std::ostream ** mppStream
Definition spewtable.h:50