FOSSology  3.2.0rc1
Open Source License Compliance by Open Source Software
copyrightState.cc
1 /*
2  * Copyright (C) 2014-2015, Siemens AG
3  * Author: Johannes Najjar, Daniele Fognini
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2
7  * as published by the Free Software Foundation.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12  * See the GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software Foundation,
16  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17  */
18 
19 #include "copyrightState.hpp"
20 #include "identity.hpp"
21 
27  cliOptions(cliOptions),
28  scanners(cliOptions.extractScanners())
29 {
30 }
31 
37 {
38  if (sc)
39  scanners.push_back(unptr::shared_ptr<scanner>(sc));
40 }
41 
46 const std::list<unptr::shared_ptr<scanner>>& CopyrightState::getScanners() const
47 {
48  return scanners;
49 }
50 
58 CliOptions::CliOptions(int verbosity, unsigned int type, bool json, bool ignoreFilesWithMimeType) :
59  verbosity(verbosity),
60  optType(type),
61  json(json),
62  ignoreFilesWithMimeType(ignoreFilesWithMimeType),
63  cliScanners()
64 {
65 }
66 
71  verbosity(0),
72  optType(ALL_TYPES),
74  cliScanners()
75 {
76 }
77 
82 unsigned int CliOptions::getOptType() const
83 {
84  return optType;
85 }
86 
92 {
93  return cliOptions;
94 }
95 
100 std::list<unptr::shared_ptr<scanner>> CliOptions::extractScanners()
101 {
102  return std::move(cliScanners);
103 }
104 
110 {
111  return verbosity >= 1;
112 }
113 
119 {
120  cliScanners.push_back(unptr::shared_ptr<scanner>(sc));
121 }
122 
128 {
129  return json;
130 }
131 
137 {
139 }
CopyrightState(CliOptions &&cliOptions)
Constructor to initialize state.
CliOptions()
Default constructor for CliOptions.
std::list< unptr::shared_ptr< scanner > > extractScanners()
Get scanner s set by CliOptions.
const std::list< unptr::shared_ptr< scanner > > & getScanners() const
Get available scanner s.
bool doignoreFilesWithMimeType() const
Check to ignore files with particular mimetype.
bool doJsonOutput() const
Check if JSON output is required.
std::list< unptr::shared_ptr< scanner > > scanners
Abstract class to provide interface to scanners.
Definition: scanners.hpp:62
unsigned int optType
void addScanner(scanner *regexDesc)
Add scanner to CliOptions.
void addScanner(scanner *scanner)
Add scanner to state.
bool isVerbosityDebug() const
Check if verbosity is set.
const CliOptions & getCliOptions() const
Get the CliOptions set by user.
std::list< unptr::shared_ptr< scanner > > cliScanners
bool ignoreFilesWithMimeType
Store the options sent through the CLI.
unsigned int getOptType() const
Get the opt type set by CliOptions.