Tulip  4.3.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 TulipDocProfile;
31 extern TLP_SCOPE std::string TulipUserHandBookIndex;
32 extern TLP_SCOPE std::string TulipBitmapDir;
33 extern TLP_SCOPE std::string TulipShareDir;
34 
35 /**
36  * @ingroup Plugins
37  *
38  * @brief Initializes the Tulip library.
39  * Looks for the Tulip plug-ins directory, and loads the plug-ins from it.
40  * The plug-ins directory can be defined in different ways, given by order of prevalence :
41  * 1. the TLP_DIR environment variable, if it has a value
42  * 2. the appDirPath parameter, if it is not NULL
43  * 3. at that point, the Tulip paths will be retrieved from the path of the loaded Tulip shared library
44  * (you must dispose of a standard Tulip installation for that feature to work).
45  * 4. a fallback value of 'C:/Tulip/lib/' on windows, or '/usr/local/lib/' on Unix.
46  */
47 extern TLP_SCOPE void initTulipLib(const char* appDirPath = NULL);
48 
49 #ifndef EMSCRIPTEN
50 /**
51  * @ingroup Plugins
52  *
53  * @brief Demangles the name of a C++ class
54  * @param className The mangled name of a class
55  * @param hideTlp a flag to indicate if the 'tlp::' prefix
56  * @return string The demangled name of a Tulip C++ class.
57  */
58 TLP_SCOPE std::string demangleClassName(const char *className,
59  bool hideTlp = false);
60 
61 /**
62  * @ingroup Plugins
63  *
64  * @brief Demangles the name of a C++ class defined in the tlp namespace.
65  * @param className The mangled name of a class
66  * @return string The demangled name of a Tulip C++ class
67  * without the tlp:: prefix
68  */
69 inline std::string demangleTlpClassName(const char *className) {
70  return demangleClassName(className, true);
71 }
72 #endif // EMSCRIPTEN
73 
74 /**
75  * @brief Returns an istream to read from a gzipped file (uses gzstream lib).
76  * The stream has to be deleted after use.
77  * @param name The name of the file to read from.
78  * @param open_mode The mode to open the file with. Defaults to std::ios::in.
79  * @return istream gzipped input stream from a file.
80  */
81 TLP_SCOPE std::istream *getIgzstream(const char *name, int open_mode = std::ios::in);
82 
83 /**
84  * @brief Returns an ostream to write to a gzipped file (uses gzstream lib).
85  * The stream has to be deleted after use.
86  * @warning Don't forget to check the stream with ios::bad()!
87  * @param name The name of the file to write to.
88  * @param open_mode The mode to open the file with. Defaults to std::ios::out.
89  * @return ostream gzipped output stream to a file.
90  */
91 TLP_SCOPE std::ostream *getOgzstream(const char *name, int open_mode = std::ios::out);
92 
93 }
94 
95 #endif