forked from gaoxiang12/slambook
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
xiang.gao
committed
Sep 12, 2016
1 parent
a1d5cfe
commit b88ed28
Showing
4 changed files
with
97 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* <one line to give the program's name and a brief idea of what it does.> | ||
* Copyright (C) 2016 <copyright holder> <email> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http:https://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
#ifndef CONFIG_H | ||
#define CONFIG_H | ||
|
||
#include "myslam/common_include.h" | ||
|
||
namespace myslam | ||
{ | ||
class Config | ||
{ | ||
private: | ||
static std::shared_ptr<Config> config_; | ||
cv::FileStorage file_; | ||
|
||
Config () {} // private constructor makes a singleton | ||
public: | ||
~Config(); // close the file when deconstructing | ||
|
||
// set a new config file | ||
static void setParameterFile( const std::string& filename ); | ||
|
||
// access the parameter values | ||
template< typename T > | ||
static T get( const std::string& key ) | ||
{ | ||
return T( Config::config_->file_[key] ); | ||
} | ||
}; | ||
} | ||
|
||
#endif // CONFIG_H |
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* <one line to give the program's name and a brief idea of what it does.> | ||
* Copyright (C) 2016 <copyright holder> <email> | ||
* | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program. If not, see <http:https://www.gnu.org/licenses/>. | ||
* | ||
*/ | ||
|
||
#include "myslam/config.h" | ||
|
||
namespace myslam | ||
{ | ||
|
||
void Config::setParameterFile( const std::string& filename ) | ||
{ | ||
if ( config_ == nullptr ) | ||
config_ = shared_ptr<Config>(new Config); | ||
config_->file_ = cv::FileStorage( filename.c_str(), cv::FileStorage::READ ); | ||
if ( config_->file_.isOpened() == false ) | ||
{ | ||
std::cerr<<"parameter file "<<filename<<" does not exist."<<std::endl; | ||
config_->file_.release(); | ||
return; | ||
} | ||
} | ||
|
||
Config::~Config() | ||
{ | ||
if ( file_.isOpened() ) | ||
file_.release(); | ||
} | ||
|
||
shared_ptr<Config> Config::config_ = nullptr; | ||
|
||
} |