w11 - cpp 0.794
Backend server for Rlink and w11
Loading...
Searching...
No Matches
RlogFileCatalog.cpp
Go to the documentation of this file.
1// $Id: RlogFileCatalog.cpp 1186 2019-07-12 17:49:59Z mueller $
2// SPDX-License-Identifier: GPL-3.0-or-later
3// Copyright 2013-2018 by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
4//
5// Revision History:
6// Date Rev Version Comment
7// 2018-12-07 1078 1.0.2 use std::shared_ptr instead of boost
8// 2018-11-09 1066 1.0.1 use auto; use make_pair,emplace
9// 2013-02-22 491 1.0 Initial version
10// ---------------------------------------------------------------------------
11
16#include <iostream>
17
18#include "RlogFileCatalog.hpp"
19
20using namespace std;
21
27// all method definitions in namespace Retro
28namespace Retro {
29
30//------------------------------------------+-----------------------------------
32
34{
35 static RlogFileCatalog obj; // lazy creation singleton
36 return obj;
37}
38
39//------------------------------------------+-----------------------------------
41
42const std::shared_ptr<RlogFile>&
43 RlogFileCatalog::FindOrCreate(const std::string& name)
44{
45 auto it = fMap.find(name);
46 if (it != fMap.end()) return it->second;
47
48 std::shared_ptr<RlogFile> sptr(new RlogFile());
49 auto pitb = fMap.emplace(make_pair(name, sptr));
50
51 return pitb.first->second;
52}
53
54//------------------------------------------+-----------------------------------
56
57void RlogFileCatalog::Delete(const std::string& name)
58{
59 fMap.erase(name);
60 return;
61}
62
63//------------------------------------------+-----------------------------------
65
67{
68 FindOrCreate("cout")->UseStream(&cout);
69 FindOrCreate("cerr")->UseStream(&cerr);
70}
71
72//------------------------------------------+-----------------------------------
74
76{}
77
78} // end namespace Retro
map_t fMap
name->rlogfile map
void Delete(const std::string &name)
FIXME_docs.
RlogFileCatalog()
Default constructor.
const std::shared_ptr< RlogFile > & FindOrCreate(const std::string &name)
FIXME_docs.
static RlogFileCatalog & Obj()
FIXME_docs.
FIXME_docs.
Definition: RlogFile.hpp:34
Declaration of class ReventLoop.
Definition: ReventLoop.cpp:47