Skip to content

Commit

Permalink
do not write so casually to std::cerr, use cout instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Ylannl committed Jul 7, 2020
1 parent 1bb0f43 commit 88b6826
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 18 deletions.
12 changes: 6 additions & 6 deletions src/DLLoader/Unix/DLLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ namespace dlloader
bool DLOpenLib() override
{
if (!(_handle = dlopen(_pathToLib.c_str(), RTLD_LAZY | RTLD_GLOBAL))) {
std::cerr << dlerror() << std::endl;
std::cout << dlerror() << std::endl;
return false;
}

Expand All @@ -45,14 +45,14 @@ namespace dlloader
auto headerHashFunc = reinterpret_cast<getHeaderHash>(
dlsym(_handle, _getHeaderHashSymbol.c_str()));
if(!headerHashFunc) {
std::cerr << dlerror() << std::endl;
std::cout << dlerror() << std::endl;
DLCloseLib();
return false;
} else {
char plugin_hash[33];
headerHashFunc(plugin_hash);
if(strcmp(plugin_hash, GF_SHARED_HEADERS_HASH)!=0) {
std::cerr << "Plugin header hash incompatible!\n";
std::cout << "Plugin header hash incompatible!\n";
DLCloseLib();
return false;
}
Expand All @@ -69,11 +69,11 @@ namespace dlloader
auto allocFunc = reinterpret_cast<allocClass>(
dlsym(_handle, _allocClassSymbol.c_str()));
if(!allocFunc)
std::cerr << dlerror() << std::endl;
std::cout << dlerror() << std::endl;
auto deleteFunc = reinterpret_cast<deleteClass>(
dlsym(_handle, _deleteClassSymbol.c_str()));
if(!deleteFunc)
std::cerr << dlerror() << std::endl;
std::cout << dlerror() << std::endl;

if (!allocFunc || !deleteFunc) {
DLCloseLib();
Expand All @@ -87,7 +87,7 @@ namespace dlloader
void DLCloseLib() override
{
if (dlclose(_handle) != 0) {
std::cerr << dlerror() << std::endl;
std::cout << dlerror() << std::endl;
}
}

Expand Down
14 changes: 7 additions & 7 deletions src/DLLoader/Windows/DLLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ namespace dlloader
bool DLOpenLib() override
{
if (!(_handle = LoadLibrary(_pathToLib.c_str()))) {
std::cerr << "Can't open and load " << _pathToLib << std::endl;
std::cerr << "ERROR: " << GetLastErrorAsString() << std::endl;
std::cout << "Can't open and load " << _pathToLib << std::endl;
std::cout << "ERROR: " << GetLastErrorAsString() << std::endl;
return false;
}

Expand All @@ -63,15 +63,15 @@ namespace dlloader
auto headerHashFunc = reinterpret_cast<getHeaderHash>(
GetProcAddress(_handle, _getHeaderHashSymbol.c_str()));
if(!headerHashFunc) {
std::cerr << "Can't find _getHeaderHashSymbol symbol in " << _pathToLib << std::endl;
std::cout << "Can't find _getHeaderHashSymbol symbol in " << _pathToLib << std::endl;
DLCloseLib();
return false;
} else {
char plugin_hash[33];
headerHashFunc(plugin_hash);
if(strcmp(plugin_hash, GF_SHARED_HEADERS_HASH)!=0) {
std::cerr << plugin_hash << ", geof: " << GF_SHARED_HEADERS_HASH << "\n";
std::cerr << "Plugin header hash incompatible!\n";
std::cout << plugin_hash << ", geof: " << GF_SHARED_HEADERS_HASH << "\n";
std::cout << "Plugin header hash incompatible!\n";
DLCloseLib();
return false;
}
Expand All @@ -91,7 +91,7 @@ namespace dlloader

if (!allocFunc || !deleteFunc) {
DLCloseLib();
std::cerr << "Can't find allocator or deleter symbol in " << _pathToLib << std::endl;
std::cout << "Can't find allocator or deleter symbol in " << _pathToLib << std::endl;
}

return std::shared_ptr<T>(
Expand All @@ -102,7 +102,7 @@ namespace dlloader
void DLCloseLib() override
{
if (FreeLibrary(_handle) == 0) {
std::cerr << "Can't close " << _pathToLib << std::endl;
std::cout << "Can't close " << _pathToLib << std::endl;
}
}

Expand Down
1 change: 0 additions & 1 deletion src/geoflow/common.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ class LineString : public vec3f, public Geometry
size_t vertex_count() const;
float *get_data_ptr();
};

template <typename geom_def>
class GeometryCollection : public Geometry, public std::vector<geom_def>
{
Expand Down
6 changes: 3 additions & 3 deletions src/geoflow/geoflow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ size_t NodeManager::run(Node &node, bool notify_children) {
node_queue.pop();
n->status_ = GF_NODE_PROCESSING;
// n->preprocess();
std::cerr << "P " << n->get_name() << "...";
std::cout << "P " << n->get_name() << "..." << std::flush;
std::clock_t c_start = std::clock(); // CPU time
// copy parameter values from master if a master is set
for (auto& [name, param] : n->parameters) {
Expand All @@ -455,11 +455,11 @@ size_t NodeManager::run(Node &node, bool notify_children) {
++run_count;
n->propagate_outputs();
} catch (const gfException& e) {
std::cerr << "ERROR: gfException -- " << e.what() << "\n";
std::cout << "ERROR: gfException -- " << e.what() << "\n" << std::flush;
n->status_ = GF_NODE_READY;
}
std::clock_t c_end = std::clock(); // CPU time
std::cerr << 1000.0 * (c_end-c_start) / CLOCKS_PER_SEC << "ms\n";
std::cout << 1000.0 * (c_end-c_start) / CLOCKS_PER_SEC << "ms\n";
}
}
return run_count;
Expand Down
4 changes: 4 additions & 0 deletions src/geoflow/gui/gfImNodes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ class gfImNodes : public RenderObject {
void init_node_draw_list() {
node_draw_list_.clear();
for (auto& [name, node] : node_manager_.get_nodes()) {
if(node.get() == nullptr) {
std::cout << "Failed to load node " << name << "\n";
continue;
}
node_draw_list_.push_back(std::make_tuple(
node,
ImVec2(node->position[0], node->position[1]),
Expand Down
2 changes: 1 addition & 1 deletion src/geoflow/plugin_manager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ namespace geoflow {
}
} else {
dloaders_.erase(path);
std::cerr << "... failed :(\n";
std::cout << "... failed :(\n";
}
}
}
Expand Down

0 comments on commit 88b6826

Please sign in to comment.