jubatus_core  0.1.2
Jubatus: Online machine learning framework for distributed environment
unlearner_factory.cpp
Go to the documentation of this file.
1 // Jubatus: Online machine learning framework for distributed environment
2 // Copyright (C) 2013 Preferred Networks and Nippon Telegraph and Telephone Corporation.
3 //
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License version 2.1 as published by the Free Software Foundation.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 
17 #include "unlearner_factory.hpp"
18 
19 #include <string>
20 #include "jubatus/util/lang/shared_ptr.h"
21 #include "../common/exception.hpp"
22 #include "lru_unlearner.hpp"
23 #include "random_unlearner.hpp"
24 
25 using jubatus::util::lang::shared_ptr;
26 
27 namespace jubatus {
28 namespace core {
29 namespace unlearner {
30 
31 shared_ptr<unlearner_base> create_unlearner(
32  const std::string& name,
33  const common::jsonconfig::config& config) {
34  if (name == "lru") {
35  return shared_ptr<unlearner_base>(
37  lru_unlearner::config>(config)));
38  } else if (name == "random") {
39  return shared_ptr<unlearner_base>(
41  random_unlearner::config>(config)));
42  } else {
44  "unlearner(" + name + ')'));
45  }
46 }
47 
48 } // namespace unlearner
49 } // namespace core
50 } // namepsace jubatus
T config_cast_check(const config &c)
Definition: cast.hpp:311
shared_ptr< unlearner_base > create_unlearner(const std::string &name, const common::jsonconfig::config &config)
#define JUBATUS_EXCEPTION(e)
Definition: exception.hpp:79
jubatus::util::data::optional< std::string > unlearner