FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
databasehandler.hpp
1 /*
2  * Copyright (C) 2014-2015, Siemens AG
3  *
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * version 2 as published by the Free Software Foundation.
7  *
8  * This program 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
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License along
14  * with this program; if not, write to the Free Software Foundation, Inc.,
15  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16  */
17 
18 #ifndef NINKA_AGENT_DATABASE_HANDLER_HPP
19 #define NINKA_AGENT_DATABASE_HANDLER_HPP
20 
21 #include <string>
22 #include <vector>
23 #include <unordered_map>
26 
28 {
29 public:
32  NinkaDatabaseHandler spawn() const;
33 
34  std::vector<unsigned long> queryFileIdsForUpload(int uploadId);
35  bool saveLicenseMatch(int agentId, long pFileId, long licenseId, unsigned percentMatch);
36 
37  void insertOrCacheLicenseIdForName(std::string const& rfShortName);
38  unsigned long getCachedLicenseIdForName(std::string const& rfShortName) const;
39 
40 private:
41  unsigned long selectOrInsertLicenseIdForName(std::string rfShortname);
42 
43  std::unordered_map<std::string,long> licenseRefCache;
44 };
45 
46 #endif // NINKA_AGENT_DATABASE_HANDLER_HPP
DB wrapper for agents.
DB wrapper for agents.
Database handler for agents.
DbManager dbManager
DbManager to use.
DB utility functions for agents.