Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
src
TriggeringEventEvaluatorFactory.cpp
Go to the documentation of this file.
1
/*
2
* Copyright 2002, Log4cpp Project. All rights reserved.
3
*
4
* See the COPYING file for the terms of usage and distribution.
5
*/
6
7
#include <
log4cpp/TriggeringEventEvaluatorFactory.hh
>
8
#include <stdexcept>
9
10
namespace
log4cpp
11
{
12
static
TriggeringEventEvaluatorFactory
*
evaluators_factory_
= 0;
13
std::auto_ptr<TriggeringEventEvaluator>
create_level_evaluator
(
const
FactoryParams
& params);
14
15
TriggeringEventEvaluatorFactory
&
TriggeringEventEvaluatorFactory::getInstance
()
16
{
17
if
(!evaluators_factory_)
18
{
19
std::auto_ptr<TriggeringEventEvaluatorFactory> af(
new
TriggeringEventEvaluatorFactory
);
20
af->registerCreator(
"level"
, &
create_level_evaluator
);
21
evaluators_factory_ = af.release();
22
}
23
24
return
*
evaluators_factory_
;
25
}
26
27
void
TriggeringEventEvaluatorFactory::registerCreator
(
const
std::string& class_name,
create_function_t
create_function)
28
{
29
const_iterator
i =
creators_
.find(class_name);
30
if
(i !=
creators_
.end())
31
throw
std::invalid_argument(
"Creator for Triggering event evaluator with type name '"
+ class_name +
"' allready registered"
);
32
33
creators_
[class_name] = create_function;
34
}
35
36
std::auto_ptr<TriggeringEventEvaluator>
TriggeringEventEvaluatorFactory::create
(
const
std::string& class_name,
const
params_t
& params)
37
{
38
const_iterator
i =
creators_
.find(class_name);
39
if
(i ==
creators_
.end())
40
throw
std::invalid_argument(
"There is no triggering event evaluator with type name '"
+ class_name +
"'"
);
41
42
return
(*i->second)(params);
43
}
44
45
bool
TriggeringEventEvaluatorFactory::registered
(
const
std::string& class_name)
const
46
{
47
return
creators_
.end() !=
creators_
.find(class_name);
48
}
49
}
50
log4cpp::TriggeringEventEvaluatorFactory::create_function_t
std::auto_ptr< TriggeringEventEvaluator >(* create_function_t)(const params_t ¶ms)
Definition:
TriggeringEventEvaluatorFactory.hh:24
log4cpp::TriggeringEventEvaluatorFactory::registerCreator
void registerCreator(const std::string &class_name, create_function_t create_function)
Definition:
TriggeringEventEvaluatorFactory.cpp:27
log4cpp::TriggeringEventEvaluatorFactory::getInstance
static TriggeringEventEvaluatorFactory & getInstance()
Definition:
TriggeringEventEvaluatorFactory.cpp:15
log4cpp::TriggeringEventEvaluatorFactory::creators_
creators_t creators_
Definition:
TriggeringEventEvaluatorFactory.hh:37
log4cpp::TriggeringEventEvaluatorFactory
Definition:
TriggeringEventEvaluatorFactory.hh:20
log4cpp::TriggeringEventEvaluatorFactory::registered
bool registered(const std::string &class_name) const
Definition:
TriggeringEventEvaluatorFactory.cpp:45
log4cpp::TriggeringEventEvaluatorFactory::create
std::auto_ptr< TriggeringEventEvaluator > create(const std::string &class_name, const params_t ¶ms)
Definition:
TriggeringEventEvaluatorFactory.cpp:36
log4cpp::create_level_evaluator
std::auto_ptr< TriggeringEventEvaluator > create_level_evaluator(const FactoryParams ¶ms)
Definition:
LevelEvaluator.cpp:13
log4cpp::FactoryParams
Definition:
FactoryParams.hh:61
log4cpp
Definition:
AbortAppender.hh:16
TriggeringEventEvaluatorFactory.hh
log4cpp::evaluators_factory_
static TriggeringEventEvaluatorFactory * evaluators_factory_
Definition:
TriggeringEventEvaluatorFactory.cpp:12
log4cpp::TriggeringEventEvaluatorFactory::const_iterator
creators_t::const_iterator const_iterator
Definition:
TriggeringEventEvaluatorFactory.hh:35
log4cpp
Author(s): Stephen Roderick, Bastiaan Bakker, Cedric Le Goater, Steve Ostlind, Marcel Harkema, Walter Stroebel, Glenn Scott and Tony Cheung
autogenerated on Sun Jun 23 2019 19:10:00