Fledge
An open source edge computing platform for industrial users
utils.h
1 #ifndef _FLEDGE_UTILS_H
2 #define _FLEDGE_UTILS_H
3 /*
4  * Fledge general utilities
5  *
6  * Copyright (c) 2018 Dianomic Systems
7  *
8  * Released under the Apache 2.0 Licence
9  *
10  * Author: Massimiliano Pinto
11  */
12 
13 #include <string>
14 #include <algorithm>
15 
16 #define _FLEDGE_ROOT_PATH "/usr/local/fledge"
17 
18 using namespace std;
19 
28 static const string getRootDir()
29 {
30  const char* rootDir = getenv("FLEDGE_ROOT");
31  return (rootDir ? string(rootDir) : string(_FLEDGE_ROOT_PATH));
32 }
33 
42 static const string getDataDir()
43 {
44  const char* dataDir = getenv("FLEDGE_DATA");
45  return (dataDir ? string(dataDir) : string(getRootDir() + "/data"));
46 }
47 
53 static std::string getDebugTracePath()
54 {
55  return getDataDir() + "/logs/debug-trace";
56 }
57 
77 static bool stringToBool(const std::string& str)
78 {
79  std::string lowerStr = str;
80  std::transform(lowerStr.begin(), lowerStr.end(), lowerStr.begin(), ::tolower);
81  return (lowerStr == "true" || lowerStr == "1");
82 }
83 #endif
Definition: asset_tracking.h:108