blob: 4c85d8c9fef6ab2770018e39a081cd1a17813b67 [file] [log] [blame]
Alison Craig2a4d5282015-04-10 12:00:02 -06001/** NDN-Atmos: Cataloging Service for distributed data originally developed
2 * for atmospheric science data
3 * Copyright (C) 2015 Colorado State University
Chengyu Faneb0422c2015-03-04 16:34:14 -07004 *
Alison Craig2a4d5282015-04-10 12:00:02 -06005 * NDN-Atmos is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
Chengyu Faneb0422c2015-03-04 16:34:14 -07009 *
Alison Craig2a4d5282015-04-10 12:00:02 -060010 * NDN-Atmos is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Chengyu Faneb0422c2015-03-04 16:34:14 -070014 *
Alison Craig2a4d5282015-04-10 12:00:02 -060015 * You should have received a copy of the GNU General Public License
16 * along with NDN-Atmos. If not, see <http://www.gnu.org/licenses/>.
Chengyu Fanb25835b2015-04-28 17:09:35 -060017 **/
Alison Craig2a4d5282015-04-10 12:00:02 -060018
Chengyu Fanb25835b2015-04-28 17:09:35 -060019#include "config.hpp"
Alison Craig2a4d5282015-04-10 12:00:02 -060020#include "catalog/catalog.hpp"
Chengyu Fanb25835b2015-04-28 17:09:35 -060021#include "query/query-adapter.hpp"
22#include "publish/publish-adapter.hpp"
Alison Craig2a4d5282015-04-10 12:00:02 -060023
24#include <memory>
Chengyu Fanb25835b2015-04-28 17:09:35 -060025#include <getopt.h>
26#include <ndn-cxx/face.hpp>
Chengyu Faneb0422c2015-03-04 16:34:14 -070027
Chengyu Fanb25835b2015-04-28 17:09:35 -060028
29void
30usage()
Chengyu Faneb0422c2015-03-04 16:34:14 -070031{
Chengyu Fanb25835b2015-04-28 17:09:35 -060032 std::cout << "\n Usage:\n atmos-catalog "
33 "[-h] [-f config file] "
34 " [-f config file] - set the configuration file\n"
35 " [-h] - print help and exit\n"
36 "\n";
37}
38
39int
40main(int argc, char** argv)
41{
42 int option;
43 std::string configFile(DEFAULT_CONFIG_FILE);
44
45 while ((option = getopt(argc, argv, "f:h")) != -1) {
46 switch (option) {
47 case 'f':
48 configFile.assign(optarg);
49 break;
50 case 'h':
51 default:
52 usage();
53 return 0;
54 }
55 }
56
57 argc -= optind;
58 argv += optind;
59 if (argc != 0) {
60 usage();
61 return 1;
62 }
63
Alison Craig2a4d5282015-04-10 12:00:02 -060064 std::shared_ptr<ndn::Face> face(new ndn::Face());
65 std::shared_ptr<ndn::KeyChain> keyChain(new ndn::KeyChain());
Chengyu Fan8b92f122015-03-09 22:13:36 -060066
Chengyu Fanb25835b2015-04-28 17:09:35 -060067 std::unique_ptr<atmos::util::CatalogAdapter>
68 queryAdapter(new atmos::query::QueryAdapter<MYSQL>(face, keyChain));
69 std::unique_ptr<atmos::util::CatalogAdapter>
70 publishAdapter(new atmos::publish::PublishAdapter<MYSQL>(face, keyChain));
Alison Craig2a4d5282015-04-10 12:00:02 -060071
Chengyu Fanb25835b2015-04-28 17:09:35 -060072 atmos::catalog::Catalog catalogInstance(face, keyChain, configFile);
73 catalogInstance.addAdapter(queryAdapter);
74 catalogInstance.addAdapter(publishAdapter);
Alison Craig2a4d5282015-04-10 12:00:02 -060075
Chengyu Fanb25835b2015-04-28 17:09:35 -060076 catalogInstance.initialize();
Alison Craig2a4d5282015-04-10 12:00:02 -060077 face->processEvents();
Chengyu Fan8b92f122015-03-09 22:13:36 -060078
Chengyu Faneb0422c2015-03-04 16:34:14 -070079 return 0;
80}