~ubuntu-branches/ubuntu/wily/ginkgocadx/wily-proposed

« back to all changes in this revision

Viewing changes to src/cadxcore/api/globals.h

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Tille
  • Date: 2011-05-02 08:09:26 UTC
  • Revision ID: james.westby@ubuntu.com-20110502080926-bql5wep49c7hg91t
Tags: upstream-2.4.1.1
ImportĀ upstreamĀ versionĀ 2.4.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  
 
3
 *  $Id: globals.h 3497 2011-03-14 10:01:05Z carlos $
 
4
 *  Ginkgo CADx Project
 
5
 *
 
6
 *  Copyright 2008-10 MetaEmotion S.L. All rights reserved.
 
7
 *  http://ginkgo-cadx.com
 
8
 *
 
9
 *  This file is licensed under LGPL v3 license.
 
10
 *  See License.txt for details
 
11
 *
 
12
 */
 
13
#pragma once
 
14
 
 
15
#include <iostream>
 
16
#if defined(_WINDOWS)
 
17
#include <windows.h>
 
18
#endif
 
19
 
 
20
#if defined (_GINKGO_DEBUG)
 
21
         #define GDEBUG(expr) std::cout << "D: " << expr << "   @ " << __FILE__ << ":" << __LINE__ << std::endl;
 
22
 
 
23
#else // !defined (_GINKGO_DEBUG)
 
24
         #define GDEBUG(expr) /* nada */
 
25
#endif
 
26
 
 
27
#if defined (_GINKGO_TRACE)
 
28
         #define GTRACE(expr) std::cout << "T: " << expr << "   @ " << __FILE__ << ":" << __LINE__ << std::endl;
 
29
 
 
30
#else // !defined (_GINKGO_DEBUG)
 
31
         #define GTRACE(expr) /* nada */
 
32
#endif
 
33
 
 
34
#if defined(__WXGTK__) || defined(__WXMAC__) || defined(__WXMSW__)
 
35
 
 
36
#if defined (_WIN32)
 
37
        #define TOPATH(stringwx) (stringwx.To8BitData()==NULL)?"":stringwx.To8BitData()
 
38
        #define FROMPATH(stringstd) wxString::From8BitData(stringstd.c_str())
 
39
#else
 
40
        #define TOPATH(stringwx) stringwx.ToUTF8()
 
41
        #define FROMPATH(stringstd) wxString::FromUTF8(stringstd.c_str())
 
42
#endif
 
43
 
 
44
#ifndef AUI_NAMESPACE
 
45
//#define AUI_NAMESPACE TEST::
 
46
#endif
 
47
 
 
48
#ifndef AUI_NAMESPACE
 
49
#define AUI_NAMESPACE
 
50
#define GINKGO_AUI_DECLARE(clase) class clase;
 
51
#define AUI_USE_NAMESPACE()
 
52
#else
 
53
#define GINKGO_AUI_DECLARE(clase) namespace AUI_NAMESPACE { class clase; }
 
54
#define AUI_USE_NAMESPACE() using namespace AUI_NAMESPACE;
 
55
#endif
 
56
 
 
57
#endif
 
58
 
 
59
namespace GNC {
 
60
        namespace GCS {
 
61
 
 
62
                class Timer
 
63
                {
 
64
                private:
 
65
                        #if defined(_WINDOWS)
 
66
                                LARGE_INTEGER mInicio;
 
67
                                LARGE_INTEGER mFin;
 
68
                                LARGE_INTEGER mFrecuencia;
 
69
                        #else
 
70
 
 
71
                        #endif
 
72
                public:
 
73
                        Timer()
 
74
                        {
 
75
                        }
 
76
 
 
77
                        void start()
 
78
                        {
 
79
                                #if defined(_WINDOWS)
 
80
                                        QueryPerformanceCounter( &mInicio );
 
81
                                #else
 
82
 
 
83
                                #endif
 
84
                        }
 
85
 
 
86
                        void restart() {
 
87
                                #if defined(_WINDOWS)
 
88
                                        QueryPerformanceCounter( &mInicio );
 
89
                                #else
 
90
 
 
91
                                #endif
 
92
                        }
 
93
 
 
94
                        void stop() {
 
95
                                #if defined(_WINDOWS)
 
96
                                        QueryPerformanceCounter(&mFin);
 
97
                                        QueryPerformanceFrequency(&mFrecuencia);
 
98
                                #else
 
99
 
 
100
                                #endif
 
101
                        }
 
102
 
 
103
                        friend std::ostream& operator<<(std::ostream& out, const Timer& t)
 
104
                        {
 
105
                                #if defined(_WINDOWS)
 
106
                                        const double tiempo = (double)(t.mFin.QuadPart - t.mInicio.QuadPart ) / (double) t.mFrecuencia.QuadPart;
 
107
                                        return out << tiempo << " seg. " << 1.0 / tiempo << " Op./seg.";
 
108
                                #else
 
109
                                        return out << "No implementado";
 
110
 
 
111
                                #endif
 
112
                        }
 
113
 
 
114
                        friend std::ostream& operator<<(std::ostream& out, const Timer* t)
 
115
                        {
 
116
                                if (t == NULL) {
 
117
                                        return out << "NULL";
 
118
                                }
 
119
                                else {
 
120
                                        return out << *t;
 
121
                                }
 
122
                        }
 
123
                };
 
124
        }
 
125
}