CGEM BOSS 6.6.5.f
BESIII Offline Software System
Loading...
Searching...
No Matches
Event/ers/ers-00-00-03/ers/IssueFactory.h
Go to the documentation of this file.
1/*
2 * IssueFactory.h
3 * ers
4 *
5 * Created by Matthias Wiesmann on 30.11.04.
6 * Copyright 2004 CERN. All rights reserved.
7 *
8 */
9
10#ifndef ERS_ISSUE_FACTORY
11#define ERS_ISSUE_FACTORY
12
13#include <string>
14#include <map>
15#include "ers/Core.h"
16
17namespace ers {
18
19class Issue ;
20
21 /** This class implements the factory pattern for Issues.
22 * The main responsability of this class is to keep track of the existing types of Issues
23 * Each issue should register one factory method for instances of this class.
24 * This is needed for deserializing of Issues.
25 *
26 * \author Matthias Wiesmann
27 * \version 1.0
28 * \brief Factory for all Issues
29 */
30
32public:
33 typedef Issue* (*CreateIssueCallback)();
34 typedef std::map<std::string,CreateIssueCallback> CallbackMap ;
35protected:
36 IssueFactory();
39
40public:
41 static IssueFactory *instance() ; /**< \brief method to access singleton */
42 static void print_registered(); /**< \brief prints all registered issue types */
43 bool register_issue(const std::string &name, CreateIssueCallback creator) ; /**< \brief register an issue factory */
44 Issue *build(const std::string &name) const ; /**< \brief build an empty issue out of a name */
45 Issue *build(const std::string &name, const string_map_type *values) const ; /**< \brief build a issue out of name and set values */
46 Issue *build(const Issue *original); /**< \brief build a clone of an issue */
47 void write_to(std::ostream& stream) const ; /**< \brief writes description to stream */
48 } ; // IssueFactory
49
50 std::ostream& operator<<(std::ostream&, const IssueFactory& factory); /**< \brief streaming operator */
51
52} // ers
53
54#endif
55
efhlt::Interface * factory(void)
Definition: factory.cxx:17
bool register_issue(const std::string &name, CreateIssueCallback creator)
register an issue factory
void write_to(std::ostream &stream) const
writes description to stream
static void print_registered()
prints all registered issue types
std::map< std::string, CreateIssueCallback > CallbackMap
static IssueFactory * instance()
method to access singleton
Issue * build(const std::string &name) const
build an empty issue out of a name
std::ostream & operator<<(std::ostream &, const Issue &)
std::map< std::string, std::string > string_map_type