~ubuntu-branches/ubuntu/utopic/tcm/utopic

« back to all changes in this revision

Viewing changes to src/gl/system.h

  • Committer: Bazaar Package Importer
  • Author(s): Otavio Salvador
  • Date: 2003-07-03 20:08:21 UTC
  • Revision ID: james.westby@ubuntu.com-20030703200821-se4xtqx25e5miczi
Tags: upstream-2.20
ImportĀ upstreamĀ versionĀ 2.20

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//------------------------------------------------------------------------------
 
2
// 
 
3
// This file is part of Toolkit for Conceptual Modeling (TCM).
 
4
// (c) copyright 1995, Vrije Universiteit Amsterdam.
 
5
// Author: Frank Dehne (frank@cs.vu.nl).
 
6
//
 
7
// TCM is free software; you can redistribute it and/or modify
 
8
// it under the terms of the GNU General Public License as published by
 
9
// the Free Software Foundation; either version 2 of the License, or
 
10
// (at your option) any later version. 
 
11
// 
 
12
// TCM is distributed in the hope that it will be useful,
 
13
// but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
// GNU General Public License for more details.
 
16
//
 
17
// You should have received a copy of the GNU General Public License
 
18
// along with TCM; if not, write to the Free Software
 
19
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 
20
// 02111-1307, USA.
 
21
//-----------------------------------------------------------------------------
 
22
#ifndef _SYSTEM_H 
 
23
#define _SYSTEM_H 
 
24
 
 
25
#include "bool.h"
 
26
class string;
 
27
 
 
28
/// Encapsulates some O.S. specific functions.
 
29
class System {
 
30
/*@Doc: {\large {\bf scope:} global} */
 
31
public:
 
32
        /// set unix signal handler.
 
33
        static void SetSignalHandler();
 
34
 
 
35
        /// copies into host the hostname of the machine.
 
36
        static bool GetHostName(char* host);
 
37
        ///
 
38
        static bool GetHostName(string* host);
 
39
 
 
40
        /// copies into login the loginname of the user.
 
41
        static bool GetLoginName(char* login);
 
42
        ///
 
43
        static bool GetLoginName(string* login);
 
44
 
 
45
        /// copies in time the current machine time as a string.
 
46
        static bool GetTime(char* time);
 
47
        ///
 
48
        static bool GetTime(string* time);
 
49
 
 
50
        /// returns a random number based on the time and the given number.
 
51
        static unsigned long GenerateId(unsigned long); 
 
52
 
 
53
        /// copies into printer the PRINTER environment variable.
 
54
        static bool GetPrinter(char* printer);
 
55
        ///
 
56
        static bool GetPrinter(string* printer);
 
57
 
 
58
        /// retrieve current working directory.
 
59
        static bool GetCwd(char* dir);
 
60
        ///
 
61
        static bool GetCwd(string* dir);
 
62
        
 
63
        /// retrieve home directory.
 
64
        static bool GetHome(char* home);
 
65
        ///
 
66
        static bool GetHome(string* home);
 
67
 
 
68
        /// copies the tool home directory variable into home.
 
69
        static void GetToolkitHome(char* home); 
 
70
        ///
 
71
        static void GetToolkitHome(string* home);
 
72
 
 
73
        /// copies the tool lib directory variable into lib.
 
74
        static void GetToolkitLib(char* lib);
 
75
        ///
 
76
        static void GetToolkitLib(string* lib);
 
77
 
 
78
        /// copies the tool config directory variable into conf.
 
79
        static void GetToolkitConfig(char* conf);
 
80
        ///
 
81
        static void GetToolkitConfig(string* conf);
 
82
 
 
83
        /// copies the tool share directory variable into share.
 
84
        static void GetToolkitShare(char* share);
 
85
        ///
 
86
        static void GetToolkitShare(string* share);
 
87
 
 
88
        /// copies the tool help directory variable into help.
 
89
        static void GetToolkitHelp(char* help);
 
90
        ///
 
91
        static void GetToolkitHelp(string* help);
 
92
 
 
93
        /// copies in dir and file the directory and file in the name 'path'.
 
94
        static void GiveFile(const char* path, char* dir, char* file);
 
95
        ///
 
96
        static void GiveFile(const string* path, string* dir, string* file);
 
97
 
 
98
        /// copies in file the file in the name 'path'.
 
99
        static void GiveFile(const char* path, char* file); 
 
100
        ///
 
101
        static void GiveFile(const string* path, string* file); 
 
102
 
 
103
        /// returns if file is regular (not directory, named pipe etc).
 
104
        static bool FileRegular(const char* file); 
 
105
 
 
106
        /// returns whether file exists
 
107
        static bool FileExists(const char* file);
 
108
 
 
109
        /// returns whether executable file exists
 
110
        static bool FileExecutable(const char* file);
 
111
 
 
112
        /// returns whether directory exists
 
113
        static bool DirExists(const char* dir);
 
114
 
 
115
        /// returns if there is command in a std dir, program becomes the path.
 
116
        static bool FindProgram(char* program, const char* command); 
 
117
        ///
 
118
        static bool FindProgram(string* program, const char* command); 
 
119
 
 
120
        /// return true if desc is a 'num1'x'num2' string.
 
121
        static bool NxnParse(const char* desc, int &num1, int &num2); 
 
122
        
 
123
        /// return if argv contains arg. Index will be the position in argv.
 
124
        static bool FindArg(char** argv, int argc, const char* arg, int &index);
 
125
 
 
126
        /// send an email message (for instance for stats or bug reports).
 
127
        static void SendEmail(const char* recipient, const char* subject, 
 
128
                const char* program, const char* version, const char* text);
 
129
 
 
130
        /// default toolkit home directory.
 
131
        static const char TOOLKIT_HOME_DEFAULT[];
 
132
 
 
133
        /// Statistics message subject for logging.
 
134
        static const char TOOLKIT_STAT_HEADER[];
 
135
 
 
136
        /// Bug report message subject.
 
137
        static const char TOOLKIT_BUG_HEADER[];
 
138
 
 
139
        /// Variable name that contains the tool home directory.
 
140
        static const char TOOLKIT_HOME_VAR_NAME[];
 
141
 
 
142
        /// most common Unix directories for system wide available binaries.
 
143
        static const char* STD_SEARCH_DIRS[];
 
144
 
 
145
        /// send an email after crash
 
146
        static bool sendBugEmail;
 
147
 
 
148
        /// email address to send to.
 
149
        static char emailAddress[];
 
150
 
 
151
        /// the command name of the current program (argv[0]).
 
152
        static char currentProgram[];
 
153
protected:
 
154
        /// called when signal occurs.
 
155
        static void SignalHandler(int s);
 
156
};
 
157
 
 
158
 
 
159
 
 
160
#endif