On Friday 28 June 2002 1:19 pm, Andre Poenitz wrote:
> On Fri, Jun 28, 2002 at 12:48:49PM +0100, Angus Leeming wrote:
> > What we need to do is to gather together a number of snippets into
> > Andre's "run queue" and then fork this off as a separate process. Let's
> > treat this as a black box for now
> >     input: X latex snippets
> >     output: X bitmap image files that will be produced at different times.
>
> The interface should be similar to the one of the the current
> GraphicsLoader, just instead of writing a snippet to a file and ask to load
> it, hand over the snippet directly...
>
> Andre'

What do you think of this interface?
Angus

namespace grfx {

struct IDtag {
        IDtag() {
                static int counter = 0;
                id_ = ++counter;
        }
        friend bool operator==(IDtag const &, IDtag const &);
private:
        id_;
};
inline
bool operator==(IDtag const & lhs, IDtag const & rhs) {
        return lhs.id_ == rhs.id_;
}
inline
bool operator!=(IDtag const & lhs, IDtag const & rhs) {
        return !(lhs == rhs);
}

class RunQueue {
public:
        /** Returns a unique ID that the initiating process
         *  can use to identify its bitmap file.
         */
        IDtag addSnippet(string const & latex_snippet);
        /** We have accumulated several latex snippets. 
         *  Transform them into bitmap files.
         */
        void startProcessing();
        /** Emit this signal when the image file is ready to load.
         *  Passes the ID of the initiating process and the name of the
         *  image file to load.
         */
        signal2<void, IDtag, string const &> readyToLoad;
private:
        /// Use the Pimpl idiom to hide the internals.
        class Impl;
        /// The pointer never changes although *pimpl_'s contents may.
        boost::scoped_ptr<Impl> const pimpl_;
};

} // namespace grfx

Reply via email to