Skip to content

Commit

Permalink
Merge pull request #62 from skieffer/misc-dev-assist
Browse files Browse the repository at this point in the history
Misc improvements for development
  • Loading branch information
skieffer authored Aug 5, 2023
2 parents 481b56c + 7277b6e commit a48c7bf
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 15 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.DS_Store
.vscode
.idea

5 changes: 4 additions & 1 deletion cola/autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mkdir -p m4

autoreconf --install --verbose

# The following sequence is are the manual steps if autoreconf isn't available.
# The following sequence gives the manual steps if autoreconf isn't available.
#
#aclocal $ACLOCAL_FLAGS
#glibtoolize
Expand All @@ -27,6 +27,9 @@ autoreconf --install --verbose
# Instead, use this line if building for SWIG Python:
# ./configure CXXFLAGS="-O3 -DNDEBUG -arch x86_64 -arch i386" LDFLAGS="-arch x86_64 -arch i386"

# Instead, use this line for development and for debugging the tests:
#./configure --disable-shared CXXFLAGS="-g -O0"

make

# The following builds examples and tests for each of the libraries.
Expand Down
8 changes: 6 additions & 2 deletions cola/libdialect/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ using namespace dialect;
using std::string;
using std::vector;

Logger::Logger(std::string outputDir, std::string prefix, bool verbose)
: outputDir(outputDir), prefix(prefix), verbose(verbose)
Logger::Logger(std::string outputDir, std::string prefix, bool verbose, bool addSVG)
: outputDir(outputDir), prefix(prefix), verbose(verbose), addSVG(addSVG)
{
if (outputDir.size() > 0) hasOutputDir = true;
if (prefix.size() > 0) {
Expand Down Expand Up @@ -67,6 +67,10 @@ void Logger::log(std::string content, std::string name) {
void Logger::log(Graph &G, std::string name) {
string tglf = G.writeTglf();
log(tglf, name+".tglf");
if (addSVG) {
string svg = G.writeSvg();
log(svg, name+".svg");
}
}

string Logger::writeFullPathForFilename(std::string name) {
Expand Down
9 changes: 7 additions & 2 deletions cola/libdialect/logging.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ struct Logger {
std::vector<std::string> names;
bool hasOutputDir = false;
bool hasPrefix = false;
//! Controls whether the logger writes to stdout the name of each file recorded.
//! Control whether the logger writes to stdout the name of each file recorded:
bool verbose = false;
//! If true, then when logging TGLF for a graph, also log SVG:
bool addSVG = false;

//! Sometimes it is useful to be able to record a number that should be used in a
//! prefix by various processes. Helps when separate processes are being logged.
Expand All @@ -51,10 +53,13 @@ struct Logger {
//! @param[in] outputDir Optional name of output directory in which files should be written.
//! @param[in] prefix Optional prefix to put at start of all file names.
//! @param[in] verbose Set true if you want the logger to write each recorded name to stdout.
//! @param[in] addSVG Set true if you want the logger to also write an SVG file, each time it
//! writes a TGLF file.
//!
//! @note If no outputDir is given, then strings are only saved in this object.
//! @note If a prefix is given, an underscore will be automatically appended to it.
Logger(std::string outputDir = "", std::string prefix = "", bool verbose = false);
Logger(std::string outputDir = "", std::string prefix = "",
bool verbose = false, bool addSVG = false);

//! @brief Record a string, optionally to a named file in the output dir.
//! @param[in] content The string to be recorded.
Expand Down
4 changes: 2 additions & 2 deletions cola/libdialect/tests/hola_arpa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ using namespace dialect;
int main(void) {
Graph_SP graph = buildGraphFromTglfFile("graphs/" "special/Arpanet19728_input.tglf");
HolaOpts opts;
bool debug = true;
if (debug) doHOLA(*graph, opts, new Logger("output/", "hola_arpa_", true));
bool debug = false;
if (debug) doHOLA(*graph, opts, new Logger("output/", "hola_arpa_", true, true));
else doHOLA(*graph, opts);
writeStringToFile(graph->writeTglf(), "output/" "hola_arpa_" "layout.tglf");
writeStringToFile(graph->writeSvg(), "output/" "svg/" "hola_arpa_" "layout.svg");
Expand Down
4 changes: 2 additions & 2 deletions cola/libdialect/tests/hola_slovakia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ int main(void) {
Graph_SP graph = buildGraphFromTglfFile("graphs/" "special/GtsSlovakia_input.tglf");
HolaOpts opts;
std::string prefix = "hola_slovakia_";
bool debug = true;
if (debug) doHOLA(*graph, opts, new Logger("output/", prefix, true));
bool debug = false;
if (debug) doHOLA(*graph, opts, new Logger("output/", prefix, true, true));
else doHOLA(*graph, opts);
writeStringToFile(graph->writeTglf(), "output/" + prefix + "layout.tglf");
writeStringToFile(graph->writeSvg(), "output/" "svg/" + prefix + "layout.svg");
Expand Down
2 changes: 1 addition & 1 deletion cola/libdialect/tests/holalonenode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ int main(void) {
Graph_SP graph = buildGraphFromTglfFile("graphs/" "special/lone_node.tglf");
HolaOpts opts;
bool debug = false;
if (debug) doHOLA(*graph, opts, new Logger("output/", "holalonenode_", true));
if (debug) doHOLA(*graph, opts, new Logger("output/", "holalonenode_", true, true));
else doHOLA(*graph, opts);
writeStringToFile(graph->writeTglf(), "output/" "holalonenode_" "layout.tglf");

Expand Down
2 changes: 1 addition & 1 deletion cola/libdialect/tests/holametro01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int main(void) {
Graph_SP graph = buildGraphFromTglfFile("graphs/" "metro/sydney.tglf");
HolaOpts opts;
bool debug = false;
if (debug) doHOLA(*graph, opts, new Logger("output/", "holametro01_", true));
if (debug) doHOLA(*graph, opts, new Logger("output/", "holametro01_", true, true));
else doHOLA(*graph, opts);
writeStringToFile(graph->writeTglf(), "output/" "holametro01_" "layout.tglf");
writeStringToFile(graph->writeSvg(), "output/" "svg/" "holametro01_" "layout.svg");
Expand Down
2 changes: 1 addition & 1 deletion cola/libdialect/tests/holasbgn01.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int main(void) {
Graph_SP graph = buildGraphFromTglfFile("graphs/" "sbgn/glyco.tglf");
HolaOpts opts;
bool debug = false;
if (debug) doHOLA(*graph, opts, new Logger("output/", "holasbgn01_", true));
if (debug) doHOLA(*graph, opts, new Logger("output/", "holasbgn01_", true, true));
else doHOLA(*graph, opts);
writeStringToFile(graph->writeTglf(), "output/" "holasbgn01_" "layout.tglf");
writeStringToFile(graph->writeSvg(), "output/" "svg/" "holasbgn01_" "layout.svg");
Expand Down
2 changes: 1 addition & 1 deletion cola/libdialect/tests/holasbgn02.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int main(void) {
Graph_SP graph = buildGraphFromTglfFile("graphs/" "sbgn/calvin.tglf");
HolaOpts opts;
bool debug = false;
if (debug) doHOLA(*graph, opts, new Logger("output/", "holasbgn02_", true));
if (debug) doHOLA(*graph, opts, new Logger("output/", "holasbgn02_", true, true));
else doHOLA(*graph, opts);
writeStringToFile(graph->writeTglf(), "output/" "holasbgn02_" "layout.tglf");
writeStringToFile(graph->writeSvg(), "output/" "svg/" "holasbgn02_" "layout.svg");
Expand Down
2 changes: 1 addition & 1 deletion cola/libdialect/tests/holasbgn03.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int main(void) {
Graph_SP graph = buildGraphFromTglfFile("graphs/" "sbgn/urea1.tglf");
HolaOpts opts;
bool debug = false;
if (debug) doHOLA(*graph, opts, new Logger("output/", "holasbgn03_", true));
if (debug) doHOLA(*graph, opts, new Logger("output/", "holasbgn03_", true, true));
else doHOLA(*graph, opts);
writeStringToFile(graph->writeTglf(), "output/" "holasbgn03_" "layout.tglf");
writeStringToFile(graph->writeSvg(), "output/" "svg/" "holasbgn03_" "layout.svg");
Expand Down
2 changes: 1 addition & 1 deletion cola/libdialect/tests/holasbgn04.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ int main(void) {
Graph_SP graph = buildGraphFromTglfFile("graphs/" "sbgn/keratan.tglf");
HolaOpts opts;
bool debug = false;
if (debug) doHOLA(*graph, opts, new Logger("output/", "holasbgn04_", true));
if (debug) doHOLA(*graph, opts, new Logger("output/", "holasbgn04_", true, true));
else doHOLA(*graph, opts);
writeStringToFile(graph->writeTglf(), "output/" "holasbgn04_" "layout.tglf");
writeStringToFile(graph->writeSvg(), "output/" "svg/" "holasbgn04_" "layout.svg");
Expand Down

0 comments on commit a48c7bf

Please sign in to comment.