~ubuntu-branches/ubuntu/quantal/ginkgocadx/quantal

« back to all changes in this revision

Viewing changes to src/cadxcore/prvext/prvext.h

  • Committer: Package Import Robot
  • Author(s): Andreas Tille
  • Date: 2011-11-09 12:29:00 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111109122900-idkd9vvhr31whz8z
Tags: 2.6.0.0~rc-1
* New upstream version
  Closes: #647413
* Rebuild against recent insighttoolkit
  Closes: #648167

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 *  
3
 
 *  $Id: prvext.h 4072 2011-08-10 13:45:52Z tovar $
 
3
 *  $Id: prvext.h 4365 2011-11-03 14:01:58Z carlos $
4
4
 *  Ginkgo CADx Project
5
5
 *
6
6
 *  Copyright 2008-10 MetaEmotion S.L. All rights reserved.
12
12
 *
13
13
 */
14
14
#pragma once
 
15
 
 
16
#include <iostream>
 
17
#include <string>
 
18
#include <fstream>
 
19
#include <sstream>
 
20
 
15
21
#include <api/api.h>
16
22
 
17
23
#if defined(_WINDOWS)
20
26
 
21
27
#include <main/licencia.h>
22
28
 
23
 
#include <iostream>
24
 
#include <string>
25
 
 
26
29
class wxWindow;
27
30
 
28
31
namespace GNC {
39
42
 
40
43
 
41
44
#if defined(WIN32)
 
45
        #define IMPLEMENT_BuildDescriptorEntryPoint() \
 
46
                extern "C" __declspec(dllexport) void BuildDescriptor(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow) { \
 
47
                        std::string args = lpszCmdLine; \
 
48
                        std::stringstream is(args); \
 
49
                        std::string path; \
 
50
                        std::string extFileName; \
 
51
                        is >> path; \
 
52
                        is >> extFileName; \
 
53
                        std::string fullPath = path + "\\" + extFileName + ".inf"; \
 
54
                        std::cout << "Writing extension descriptor to " << fullPath.c_str() << " ..." << std::endl; fstream fs; \
 
55
                        fs.open ( fullPath.c_str(), fstream::out); \
 
56
                        fs << "DLL=" << extFileName << ".dll" << std::endl; \
 
57
                        fs << PRIVATE_EXTENSION_NAME() << std::endl; \
 
58
                        fs << "CORE_VERSION=" << GINKGO_VERSION << std::endl; \
 
59
                        fs << "CORE_SUBVERSION=" << GINKGO_SUB_VERSION << std::endl; \
 
60
                        fs.close(); \
 
61
                        std::cout << "Done" << std::endl; \
 
62
                }
 
63
 
42
64
        #if defined(_DEBUG)
43
 
                #define IMPLEMENT_PrivateExtension(name) extern "C" __declspec(dllexport) PrivateExtension* PRIVATE_EXTENSION_NAME() { return new name();};
 
65
                #define IMPLEMENT_PrivateExtension(name) \
 
66
                        extern "C" __declspec(dllexport) PrivateExtension* PRIVATE_EXTENSION_NAME() { return new name();}\
 
67
                        IMPLEMENT_BuildDescriptorEntryPoint()
 
68
 
44
69
        #else
45
 
                #define IMPLEMENT_PrivateExtension(name) extern "C" __declspec(dllexport) PrivateExtension* PRIVATE_EXTENSION_NAME() { return new name();};
 
70
                #define IMPLEMENT_PrivateExtension(name) \
 
71
                        extern "C" __declspec(dllexport) PrivateExtension* PRIVATE_EXTENSION_NAME() { return new name();}\
 
72
                        IMPLEMENT_BuildDescriptorEntryPoint()
46
73
        #endif
47
74
#else
 
75
 
 
76
        #define IMPLEMENT_BuildDescriptorEntryPoint() \
 
77
                extern "C" EXTAPI int main(int argc, char**argv) { \
 
78
                        std::string args = argv[1]; \
 
79
                        std::stringstream is(args); \
 
80
                        std::string path; \
 
81
                        std::string extFileName; \
 
82
                        is >> path; \
 
83
                        is >> extFileName; \
 
84
                        std::string fullPath = path + "\\" + extFileName + ".inf"; \
 
85
                        std::cout << "Writing extension descriptor to " << fullPath.c_str() << " ..." << std::endl; fstream fs; \
 
86
                        fs.open ( fullPath.c_str(), fstream::out); \
 
87
                        fs << "DLL=" << extFileName << ".dll" << std::endl; \
 
88
                        fs << PRIVATE_EXTENSION_NAME() << std::endl; \
 
89
                        fs << "CORE_VERSION=" << GINKGO_VERSION << std::endl; \
 
90
                        fs << "CORE_SUBVERSION=" << GINKGO_SUB_VERSION << std::endl; \
 
91
                        fs.close(); \
 
92
                        std::cout << "Done" << std::endl; \
 
93
                }
 
94
 
48
95
        #if defined(_DEBUG)
49
 
                #define IMPLEMENT_PrivateExtension(name) extern "C" EXTAPI PrivateExtension* PRIVATE_EXTENSION_NAME() { return new name();};
 
96
                #define IMPLEMENT_PrivateExtension(name) \
 
97
                        extern "C" EXTAPI PrivateExtension* PRIVATE_EXTENSION_NAME() { return new name();};\
 
98
                        IMPLEMENT_BuildDescriptorEntryPoint()
50
99
        #else
51
 
                #define IMPLEMENT_PrivateExtension(name) extern "C" EXTAPI PrivateExtension* PRIVATE_EXTENSION_NAME() { return new name();};
 
100
                #define IMPLEMENT_PrivateExtension(name) \
 
101
                        extern "C" EXTAPI PrivateExtension* PRIVATE_EXTENSION_NAME() { return new name();};\
 
102
                        IMPLEMENT_BuildDescriptorEntryPoint()
52
103
        #endif
53
104
 
54
105
        
57
108
class PrivateExtension
58
109
{
59
110
public:
60
 
        PrivateExtension(const std::string& sid, const std::string& provider, const std::string& description, int version, int subversion, int subrelease, const unsigned char* pixelDataIcon = NULL, unsigned int iconSize = 0)
 
111
        PrivateExtension(const std::string& sid, const std::string& provider, const std::string& description, int version, int subversion, int subrelease, const char* svnBuildString, const char* codename, const char* updateurl, const unsigned char* pixelDataIcon = NULL, unsigned int iconSize = 0)
61
112
        {
62
113
                this->sid = sid;
63
114
                this->provider = provider;
65
116
                this->version = version;
66
117
                this->subversion = subversion;
67
118
                this->subrelease = subrelease;
 
119
                this->build = ParseSVNBuild(svnBuildString);
 
120
                this->codename = codename;
 
121
                this->updateurl = updateurl;
 
122
 
68
123
                this->iconSize = iconSize;
69
124
                this->pixelDataIcon = pixelDataIcon;
70
 
 
71
 
                this->coreVersion = GINKGO_VERSION;
72
 
                this->coreSubversion = GINKGO_SUB_VERSION;
73
 
 
 
125
                
74
126
                AsignarFechaCompilacion(__DATE__);
75
127
        }
76
128
 
102
154
                return this->subrelease;
103
155
        }
104
156
 
 
157
        int GetBuild() const
 
158
        {
 
159
                return this->build;
 
160
        }
 
161
 
 
162
        std::string GetCodeName() const
 
163
        {
 
164
                return this->codename;
 
165
        }
 
166
 
105
167
        const std::string& GetSID() const
106
168
        {
107
169
                return this->sid;
137
199
                return this->fecha_compilacion;
138
200
        }
139
201
 
140
 
        int GetCoreVersion() const 
 
202
        int GetSVNBuild() const 
141
203
        {
142
 
                return coreVersion;
 
204
                return build;
143
205
        }
144
206
 
145
 
        int GetCoreSubVersion() const 
 
207
        const std::string& GetUpdateURL() const
146
208
        {
147
 
                return coreSubversion;
 
209
                return updateurl;
148
210
        }
149
211
 
150
212
        const unsigned char* GetPixelDataIcon()
161
223
                this->version = o.version;
162
224
                this->subversion = o.subversion;
163
225
                this->subrelease = o.subrelease;
 
226
                this->build = o.build;
 
227
                this->codename = o.codename;
 
228
 
164
229
                this->sid = o.sid;
165
230
                this->provider = o.provider;
166
231
                this->description = o.description;
167
232
                this->fecha_compilacion = o.fecha_compilacion;
 
233
                this->updateurl = o.updateurl;
168
234
 
169
 
                this->coreVersion = o.coreVersion;
170
 
                this->coreSubversion = o.coreSubversion;
171
235
                this->pixelDataIcon = o.pixelDataIcon;
172
236
                this->iconSize = o.iconSize;
173
237
                return *this;
175
239
 
176
240
        friend std::ostream& operator<<(std::ostream &os, const PrivateExtension& ext)
177
241
        {
178
 
                return os << ext.GetSID() << " V" << ext.GetVersion() << "." << ext.GetSubVersion()<< "." << ext.GetSubRelease() << ". (c) " << ext.GetProvider().c_str() << " " << ext.GetFechaCompilacion().c_str();
 
242
                os << "SID=" << ext.sid.c_str() << std::endl;
 
243
                os << "DESCRIPTION=" << ext.description.c_str() << std::endl;
 
244
                os << "PROVIDER=" << ext.provider.c_str() << std::endl;
 
245
                //os << "COMPILATION=" << ext.fecha_compilacion.c_str() << std::endl;
 
246
                os << "VERSION=" << ext.version << std::endl;
 
247
                os << "SUBVERSION=" << ext.subversion << std::endl;
 
248
                os << "RELEASE=" << ext.subrelease << std::endl;
 
249
                os << "BUILD=" << ext.build << std::endl;
 
250
                os << "CODENAME=" << ext.codename.c_str() << std::endl;
 
251
                os << "UPDATEURL=" << ext.updateurl.c_str();
 
252
                return os;              
179
253
        }
180
254
 
181
255
        friend std::ostream& operator<<(std::ostream& os, PrivateExtension* ext)
192
266
        int version;
193
267
        int subversion;
194
268
        int subrelease;
195
 
        int coreVersion;
196
 
        int coreSubversion;
 
269
        int build;
 
270
 
 
271
        std::string codename;
197
272
        std::string sid;
198
273
        std::string provider;
199
274
        std::string description;
200
275
        std::string fecha_compilacion;
201
276
        std::string path;
 
277
        std::string updateurl;
202
278
        const unsigned char* pixelDataIcon;
203
279
        unsigned int    iconSize;
 
280
 
 
281
private:
 
282
        int ParseSVNBuild(const char* str)
 
283
        {
 
284
                int num = -1;
 
285
                std::string beg;
 
286
                std::string end;
 
287
                std::stringstream ss(str);
 
288
                ss >> beg >> num >> end;
 
289
                return num;
 
290
        }
 
291
 
204
292
};
205
293
 
206
294
//define a function pointer type for convenience