BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Event/ers/include/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 "ers/Core.h"
14#include <map>
15#include <string>
16
17namespace ers {
18
19 class 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
32 public:
33 typedef Issue* ( *CreateIssueCallback )();
34 typedef std::map<std::string, CreateIssueCallback> CallbackMap;
35
36 protected:
40
41 public:
42 static IssueFactory* instance(); /**< \brief method to access singleton */
43 static void print_registered(); /**< \brief prints all registered issue types */
44 bool register_issue( const std::string& name,
45 CreateIssueCallback creator ); /**< \brief register an issue factory
46 */
47 Issue* build( const std::string& name ) const; /**< \brief build an empty issue out of a
48 name */
49 Issue* build( const std::string& name,
50 const string_map_type* values ) const; /**< \brief build a issue out of name
51 and set values */
52 Issue* build( const Issue* original ); /**< \brief build a clone of an issue */
53 void write_to( std::ostream& stream ) const; /**< \brief writes description to stream */
54 }; // IssueFactory
55
56 std::ostream& operator<<( std::ostream&,
57 const IssueFactory& factory ); /**< \brief streaming operator */
58
59} // namespace ers
60
61#endif
bool register_issue(const std::string &name, CreateIssueCallback creator)
register an issue factory
std::map< std::string, CreateIssueCallback > CallbackMap
void write_to(std::ostream &stream) const
writes description to stream
static void print_registered()
prints all registered issue types
static IssueFactory * instance()
method to access singleton
Issue * build(const std::string &name) const
build an empty issue out of a name
Root Issue class.
efhlt::Interface * factory(void)
Definition factory.cxx:15
std::ostream & operator<<(std::ostream &, const Issue &)
std::map< std::string, std::string > string_map_type