Tulip  4.4.0
Better Visualization Through Research
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Groups Pages
TlpTools.h
1 /*
2  *
3  * This file is part of Tulip (www.tulip-software.org)
4  *
5  * Authors: David Auber and the Tulip development Team
6  * from LaBRI, University of Bordeaux 1 and Inria Bordeaux - Sud Ouest
7  *
8  * Tulip is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License
10  * as published by the Free Software Foundation, either version 3
11  * of the License, or (at your option) any later version.
12  *
13  * Tulip is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  * See the GNU General Public License for more details.
17  *
18  */
19 
20 #ifndef _TLPTOOLS_H
21 #define _TLPTOOLS_H
22 
23 #include <iostream>
24 #include <tulip/tulipconf.h>
25 
26 namespace tlp {
27 extern TLP_SCOPE const char PATH_DELIMITER;
28 extern TLP_SCOPE std::string TulipLibDir;
29 extern TLP_SCOPE std::string TulipPluginsPath;
30 extern TLP_SCOPE std::string TulipBitmapDir;
31 extern TLP_SCOPE std::string TulipShareDir;
32 
33 /**
34  * @ingroup Plugins
35  *
36  * @brief Initializes the Tulip library.
37  * Looks for the Tulip plug-ins directory.
38  * The plug-ins directory can be defined in different ways, given by order of prevalence :
39  * 1. the TLP_DIR environment variable, if it has a value
40  * 2. the appDirPath parameter, if it is not NULL
41  * 3. at that point, the Tulip paths will be retrieved from the path of the loaded Tulip shared library
42  * (you must dispose of a standard Tulip installation for that feature to work).
43  * 4. a fallback value of 'C:/Tulip/lib/' on windows, or '/usr/local/lib/' on Unix.
44  */
45 extern TLP_SCOPE void initTulipLib(const char* appDirPath = NULL);
46 
47 #ifndef EMSCRIPTEN
48 /**
49  * @ingroup Plugins
50  *
51  * @brief Demangles the name of a C++ class
52  * @param className The mangled name of a class
53  * @param hideTlp a flag to indicate if the 'tlp::' prefix
54  * @return string The demangled name of a Tulip C++ class.
55  */
56 TLP_SCOPE std::string demangleClassName(const char *className,
57  bool hideTlp = false);
58 
59 /**
60  * @ingroup Plugins
61  *
62  * @brief Demangles the name of a C++ class defined in the tlp namespace.
63  * @param className The mangled name of a class
64  * @return string The demangled name of a Tulip C++ class
65  * without the tlp:: prefix
66  */
67 inline std::string demangleTlpClassName(const char *className) {
68  return demangleClassName(className, true);
69 }
70 #endif // EMSCRIPTEN
71 
72 /**
73  * @brief Returns an istream to read from a gzipped file (uses gzstream lib).
74  * The stream has to be deleted after use.
75  * @param name The name of the file to read from.
76  * @param open_mode The mode to open the file with. Defaults to std::ios::in.
77  * @return istream gzipped input stream from a file.
78  */
79 TLP_SCOPE std::istream *getIgzstream(const char *name, int open_mode = std::ios::in);
80 
81 /**
82  * @brief Returns an ostream to write to a gzipped file (uses gzstream lib).
83  * The stream has to be deleted after use.
84  * @warning Don't forget to check the stream with ios::bad()!
85  * @param name The name of the file to write to.
86  * @param open_mode The mode to open the file with. Defaults to std::ios::out.
87  * @return ostream gzipped output stream to a file.
88  */
89 TLP_SCOPE std::ostream *getOgzstream(const char *name, int open_mode = std::ios::out);
90 
91 }
92 
93 #endif