Skip to content

Commit

Permalink
Rename QFile -> SMFile to avoid possible conflict with QT
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Mendenhall committed Jul 10, 2015
1 parent 86f35ec commit 7ceb42f
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 29 deletions.
2 changes: 1 addition & 1 deletion GeneralUtils/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ CXXFLAGS = -std=c++11 -O3 -fPIC -pedantic -Wall -Wextra -I.
# things to build
#

objects = ColorSpec.o ControlMenu.o DynamicHistogram.o FloatErr.o PathUtils.o ProgressBar.o QFile.o \
objects = ColorSpec.o ControlMenu.o DynamicHistogram.o FloatErr.o PathUtils.o ProgressBar.o SMFile.o \
RollingWindow.o SMExcept.o StringManip.o Stringmap.o TagCounter.o

all: libMPMGeneralUtils.a
Expand Down
30 changes: 15 additions & 15 deletions GeneralUtils/QFile.cc → GeneralUtils/SMFile.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// \file QFile.cc
/// \file SMFile.cc
/*
* QFile.cc, part of the MPMUtils package.
* SMFile.cc, part of the MPMUtils package.
* Copyright (c) 2014 Michael P. Mendenhall
*
* This program is free software; you can redistribute it and/or modify
Expand All @@ -19,7 +19,7 @@
*
*/

#include "QFile.hh"
#include "SMFile.hh"

#include <iostream>
#include <sstream>
Expand All @@ -29,7 +29,7 @@
#include "PathUtils.hh"
#include "SMExcept.hh"

QFile::QFile(const string& fname, bool readit) {
SMFile::SMFile(const string& fname, bool readit) {
name = fname;
if(!readit || name=="")
return;
Expand Down Expand Up @@ -60,33 +60,33 @@ QFile::QFile(const string& fname, bool readit) {
fin.close();
}

void QFile::insert(const string& s, const Stringmap& v) {
void SMFile::insert(const string& s, const Stringmap& v) {
dat.insert(std::make_pair(s,v));
}

void QFile::erase(const string& s) { dat.erase(s); }
void SMFile::erase(const string& s) { dat.erase(s); }

vector<Stringmap> QFile::retrieve(const string& s) const {
vector<Stringmap> SMFile::retrieve(const string& s) const {
vector<Stringmap> v;
for(multimap<string,Stringmap>::const_iterator it = dat.lower_bound(s); it != dat.upper_bound(s); it++)
v.push_back(it->second);
return v;
}

void QFile::transfer(const QFile& Q, const string& k) {
void SMFile::transfer(const SMFile& Q, const string& k) {
vector<Stringmap> v = Q.retrieve(k);
for(vector<Stringmap>::iterator it = v.begin(); it != v.end(); it++)
insert(k,*it);
}

void QFile::display() const {
void SMFile::display() const {
for(multimap<string, Stringmap>::const_iterator it = dat.begin(); it != dat.end(); it++) {
std::cout << "--- " << it->first << " ---:\n";
it->second.display();
}
}

void QFile::commit(string outname) const {
void SMFile::commit(string outname) const {
if(outname=="")
outname = name;
makePath(outname,true);
Expand All @@ -102,7 +102,7 @@ void QFile::commit(string outname) const {
fout.close();
}

vector<string> QFile::retrieve(const string& k1, const string& k2) const {
vector<string> SMFile::retrieve(const string& k1, const string& k2) const {
vector<string> v1;
for(multimap<string,Stringmap>::const_iterator it = dat.lower_bound(k1); it != dat.upper_bound(k1); it++) {
vector<string> v2 = it->second.retrieve(k2);
Expand All @@ -112,7 +112,7 @@ vector<string> QFile::retrieve(const string& k1, const string& k2) const {
return v1;
}

vector<double> QFile::retrieveDouble(const string& k1, const string& k2) const {
vector<double> SMFile::retrieveDouble(const string& k1, const string& k2) const {
vector<double> v1;
for(multimap<string,Stringmap>::const_iterator it = dat.lower_bound(k1); it != dat.upper_bound(k1); it++) {
vector<double> v2 = it->second.retrieveDouble(k2);
Expand All @@ -122,7 +122,7 @@ vector<double> QFile::retrieveDouble(const string& k1, const string& k2) const {
return v1;
}

string QFile::getDefault(const string& k1, const string& k2, const string& d) const {
string SMFile::getDefault(const string& k1, const string& k2, const string& d) const {
for(multimap<string,Stringmap>::const_iterator it = dat.lower_bound(k1); it != dat.upper_bound(k1); it++) {
vector<string> v2 = it->second.retrieve(k2);
if(v2.size())
Expand All @@ -131,7 +131,7 @@ string QFile::getDefault(const string& k1, const string& k2, const string& d) co
return d;
}

double QFile::getDefault(const string& k1, const string& k2, double d) const {
double SMFile::getDefault(const string& k1, const string& k2, double d) const {
for(multimap<string,Stringmap>::const_iterator it = dat.lower_bound(k1); it != dat.upper_bound(k1); it++) {
vector<double> v2 = it->second.retrieveDouble(k2);
if(v2.size())
Expand All @@ -140,7 +140,7 @@ double QFile::getDefault(const string& k1, const string& k2, double d) const {
return d;
}

Stringmap QFile::getFirst(const string& s, const Stringmap& dflt) const {
Stringmap SMFile::getFirst(const string& s, const Stringmap& dflt) const {
multimap<string,Stringmap>::const_iterator it = dat.find(s);
if(it == dat.end())
return dflt;
Expand Down
16 changes: 8 additions & 8 deletions GeneralUtils/QFile.hh → GeneralUtils/SMFile.hh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// \file QFile.hh \brief simple text data format
/// \file SMFile.hh \brief simple text data format
/*
* QFile.hh, part of the MPMUtils package.
* SMFile.hh, part of the MPMUtils package.
* Copyright (c) 2014 Michael P. Mendenhall
*
* This program is free software; you can redistribute it and/or modify
Expand All @@ -19,17 +19,17 @@
*
*/

#ifndef QFILE_HH
#define QFILE_HH
#ifndef SMFile_HH
#define SMFile_HH

#include "Stringmap.hh"

/// wrapper for multimap<string,Stringmap> with useful functions
class QFile {
class SMFile {
public:

/// constructor given a string
QFile(const string& s = "", bool readit = true);
SMFile(const string& s = "", bool readit = true);

/// insert key/(string)value pair
void insert(const string& str, const Stringmap& v);
Expand All @@ -49,8 +49,8 @@ public:
vector<double> retrieveDouble(const string& k1, const string& k2) const;
/// return number of elements
unsigned int size() const { return dat.size(); }
/// transfer all data for given key from other QFile
void transfer(const QFile& Q, const string& k);
/// transfer all data for given key from other SMFile
void transfer(const SMFile& Q, const string& k);

/// set output file location
void setOutfile(string fnm) { name = fnm; }
Expand Down
2 changes: 1 addition & 1 deletion GeneralUtils/TagCounter.hh
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#include <iostream>
#include <istream>
#include <sstream>
#include "QFile.hh"
#include "SMFile.hh"
#include "StringManip.hh"

using std::map;
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ clean:
-cd GeneralUtils; make clean
-cd ROOTUtils; make clean
-cd Matrix; make clean
-rm -rf html/ latex/
8 changes: 4 additions & 4 deletions ROOTUtils/OutputManager.hh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#ifndef OUTPUTMANAGER_HH
#define OUTPUTMANAGER_HH

#include "QFile.hh"
#include "SMFile.hh"
#include <TObject.h>
#include <TCanvas.h>
#include <TH1.h>
Expand Down Expand Up @@ -64,7 +64,7 @@ enum WarningLevel {
FATAL_WARNING ///< data is corrupted and cannot be analyzed
};

/// manages output directory for grouping related information; manages a canvas, output QFile, output ROOT file, recursive subdirectories
/// manages output directory for grouping related information; manages a canvas, output SMFile, output ROOT file, recursive subdirectories
class OutputManager: public TObjCollector {
public:
/// constructor for top-level
Expand All @@ -90,14 +90,14 @@ public:
/// put a data quality warning in the parent output file
void warn(WarningLevel l, string descrip, Stringmap M = Stringmap());

/// write output QFile
/// write output SMFile
virtual void write(string outName = "");
/// open output ROOT file for writing (useful if output tree is being created and needs a home)
void openOutfile();
/// set whether to write ROOT output when destructed
void setWriteRoot(bool w) { writeRootOnDestruct = w; }

QFile qOut; ///< QFile output
SMFile qOut; ///< SMFile output
TFile* rootOut; ///< ROOT file output
TCanvas* defaultCanvas; ///< canvas for drawing plots
OutputManager* parent; ///< parent output manager
Expand Down

0 comments on commit 7ceb42f

Please sign in to comment.