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 
8 #include <stdexcept>
9 
10 namespace log4cpp
11 {
13  std::auto_ptr<TriggeringEventEvaluator> create_level_evaluator(const FactoryParams& params);
14 
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 
std::auto_ptr< TriggeringEventEvaluator >(* create_function_t)(const params_t &params)
void registerCreator(const std::string &class_name, create_function_t create_function)
static TriggeringEventEvaluatorFactory & getInstance()
bool registered(const std::string &class_name) const
std::auto_ptr< TriggeringEventEvaluator > create(const std::string &class_name, const params_t &params)
std::auto_ptr< TriggeringEventEvaluator > create_level_evaluator(const FactoryParams &params)
static TriggeringEventEvaluatorFactory * evaluators_factory_


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:14:17