-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[format] Run whitespace cleanup and clang-format
- Loading branch information
Showing
34 changed files
with
8,283 additions
and
8,785 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,94 +1,84 @@ | ||
#ifndef ConfigFlags_h | ||
#define ConfigFlags_h | ||
|
||
#include <string> | ||
#include <iostream> | ||
#include <exception> | ||
#include <iostream> | ||
#include <map> | ||
#include <string> | ||
|
||
namespace MarlinTrk { | ||
|
||
class ConfigFlags ; | ||
|
||
inline std::ostream& operator<<(std::ostream& os, const ConfigFlags& cf) ; | ||
|
||
class ConfigFlags{ | ||
|
||
friend std::ostream& operator<<(std::ostream& os, const ConfigFlags& flags) ; | ||
|
||
typedef std::pair<std::string, bool> Flag ; | ||
typedef std::map< unsigned, Flag > Map ; | ||
|
||
|
||
public: | ||
|
||
/** Helper class that holds a number of boolean properties for configuration. | ||
* The property keys (type: unsigned) have to be defined in the class using | ||
* this class. | ||
*/ | ||
ConfigFlags() {} | ||
|
||
~ConfigFlags(){} | ||
|
||
|
||
void registerOption( unsigned key, const std::string& name, bool defaultValue=false ){ | ||
|
||
_map[ key ] = std::make_pair( name , defaultValue ) ; | ||
} | ||
|
||
bool option(unsigned key) const { | ||
|
||
Map::const_iterator it = _map.find( key ) ; | ||
|
||
if( it == _map.end() ) | ||
return false ; | ||
|
||
return it->second.second ; | ||
} | ||
|
||
bool operator[](unsigned key) const { | ||
return option( key ) ; | ||
} | ||
|
||
void setOption(unsigned key , bool val) { | ||
|
||
Map::iterator it = _map.find( key ) ; | ||
|
||
if( it !=_map.end() ) | ||
it->second.second = val ; | ||
} | ||
|
||
|
||
std::string& optionName(unsigned key) { | ||
|
||
static std::string empty("UNKNOWN") ; | ||
|
||
Map::iterator it = _map.find( key ) ; | ||
|
||
if( it == _map.end() ) | ||
return empty ; | ||
|
||
return it->second.first ; | ||
} | ||
|
||
protected: | ||
Map _map{}; | ||
|
||
}; | ||
|
||
|
||
inline std::ostream& operator<<(std::ostream& os, const MarlinTrk::ConfigFlags& cf) { | ||
|
||
for( ConfigFlags::Map::const_iterator it = cf._map.begin(); it != cf._map.end() ; ++it){ | ||
|
||
os << " option: " << it->second.first << "\t: " << it->second.second << std::endl ; | ||
} | ||
|
||
return os ; | ||
} | ||
|
||
} // namespace | ||
|
||
class ConfigFlags; | ||
|
||
#endif | ||
inline std::ostream& operator<<(std::ostream& os, const ConfigFlags& cf); | ||
|
||
class ConfigFlags { | ||
|
||
friend std::ostream& operator<<(std::ostream& os, const ConfigFlags& flags); | ||
|
||
typedef std::pair<std::string, bool> Flag; | ||
typedef std::map<unsigned, Flag> Map; | ||
|
||
public: | ||
/** Helper class that holds a number of boolean properties for configuration. | ||
* The property keys (type: unsigned) have to be defined in the class using | ||
* this class. | ||
*/ | ||
ConfigFlags() {} | ||
|
||
~ConfigFlags() {} | ||
|
||
void registerOption(unsigned key, const std::string& name, bool defaultValue = false) { | ||
|
||
_map[key] = std::make_pair(name, defaultValue); | ||
} | ||
|
||
bool option(unsigned key) const { | ||
|
||
Map::const_iterator it = _map.find(key); | ||
|
||
if (it == _map.end()) | ||
return false; | ||
|
||
return it->second.second; | ||
} | ||
|
||
bool operator[](unsigned key) const { return option(key); } | ||
|
||
void setOption(unsigned key, bool val) { | ||
|
||
Map::iterator it = _map.find(key); | ||
|
||
if (it != _map.end()) | ||
it->second.second = val; | ||
} | ||
|
||
std::string& optionName(unsigned key) { | ||
|
||
static std::string empty("UNKNOWN"); | ||
|
||
Map::iterator it = _map.find(key); | ||
|
||
if (it == _map.end()) | ||
return empty; | ||
|
||
return it->second.first; | ||
} | ||
|
||
protected: | ||
Map _map{}; | ||
}; | ||
|
||
inline std::ostream& operator<<(std::ostream& os, const MarlinTrk::ConfigFlags& cf) { | ||
|
||
for (ConfigFlags::Map::const_iterator it = cf._map.begin(); it != cf._map.end(); ++it) { | ||
|
||
os << " option: " << it->second.first << "\t: " << it->second.second << std::endl; | ||
} | ||
|
||
return os; | ||
} | ||
|
||
} // namespace MarlinTrk | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.