Reformat code.

This commit is contained in:
2017-10-07 20:16:48 +02:00
parent ff94a1d3da
commit dbcb4ead51
5 changed files with 97 additions and 108 deletions

View File

@@ -1,15 +1,13 @@
#include <algorithm> #include <algorithm>
#include <cstdio> #include <cstdio>
#include <iostream> #include <iostream>
#include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include "Options.hpp" #include "Options.hpp"
using namespace fmri; using namespace fmri;
using namespace std; using namespace std;
static void show_help(const char* progname, int exitcode) static void show_help(const char *progname, int exitcode) {
{
cerr << "Usage: " << progname << " -m MODEL -w WEIGHTS INPUTS..." << endl cerr << "Usage: " << progname << " -m MODEL -w WEIGHTS INPUTS..." << endl
<< endl << endl
<< R"END( << R"END(
@@ -24,16 +22,14 @@ Options:
exit(exitcode); exit(exitcode);
} }
static void check_file(const char * filename) static void check_file(const char *filename) {
{
if (access(filename, R_OK) != 0) { if (access(filename, R_OK) != 0) {
perror(filename); perror(filename);
exit(1); exit(1);
} }
} }
Options Options::parse(const int argc, char * const argv[]) Options Options::parse(const int argc, char *const argv[]) {
{
string model; string model;
string weights; string weights;
@@ -88,21 +84,17 @@ Options Options::parse(const int argc, char * const argv[])
Options::Options(string &&model, string &&weights, vector<string> &&inputs) noexcept: Options::Options(string &&model, string &&weights, vector<string> &&inputs) noexcept:
modelPath(move(model)), modelPath(move(model)),
weightsPath(move(weights)), weightsPath(move(weights)),
inputPaths(move(inputs)) inputPaths(move(inputs)) {
{
} }
const string& Options::model() const const string &Options::model() const {
{
return modelPath; return modelPath;
} }
const string& Options::weights() const const string &Options::weights() const {
{
return weightsPath; return weightsPath;
} }
const vector<string>& Options::inputs() const const vector<string> &Options::inputs() const {
{
return inputPaths; return inputPaths;
} }

View File

@@ -8,13 +8,14 @@ namespace fmri {
using std::vector; using std::vector;
using std::string; using std::string;
class Options class Options {
{
public: public:
static Options parse(const int argc, char *const argv[]); static Options parse(const int argc, char *const argv[]);
const string &model() const; const string &model() const;
const string &weights() const; const string &weights() const;
const vector<string> &inputs() const; const vector<string> &inputs() const;
private: private:

View File

@@ -1,5 +1,4 @@
#include <iostream> #include <iostream>
#include <string>
#include "Simulator.hpp" #include "Simulator.hpp"
using namespace caffe; using namespace caffe;
@@ -7,12 +6,10 @@ using namespace std;
using namespace fmri; using namespace fmri;
Simulator::Simulator(const string &model_file, const string &weights_file) : Simulator::Simulator(const string &model_file, const string &weights_file) :
net(model_file, TEST) net(model_file, TEST) {
{
net.CopyTrainedLayersFrom(weights_file); net.CopyTrainedLayersFrom(weights_file);
} }
void Simulator::simulate(const string& image_file) void Simulator::simulate(const string &image_file) {
{
cerr << "This is not implemented yet." << endl; cerr << "This is not implemented yet." << endl;
} }

View File

@@ -5,8 +5,7 @@
using namespace std; using namespace std;
using namespace fmri; using namespace fmri;
int main(int argc, char * const argv[]) int main(int argc, char *const argv[]) {
{
::google::InitGoogleLogging(argv[0]); ::google::InitGoogleLogging(argv[0]);
Options options = Options::parse(argc, argv); Options options = Options::parse(argc, argv);