1 /****************************************************************************
2 **
3 ** Copyright (c) 2008-2012 C.B. Barber. All rights reserved.
4 ** $Id: //main/2011/qhull/src/libqhullcpp/RoadLogEvent.h#1 $$Change: 1490 $
5 ** $DateTime: 2012/02/19 20:27:01 $$Author: bbarber $
6 **
7 ****************************************************************************/
8 
9 #ifndef ROADLOGEVENT_H
10 #define ROADLOGEVENT_H
11 
12 #include <ostream>
13 #include <stdexcept>
14 #include <string>
15 
16 namespace orgQhull {
17 
18 #//Types
19     //! RoadLogEvent -- Record an event for the RoadLog
20     struct RoadLogEvent;
21 
22 struct RoadLogEvent {
23 
24 public:
25 #//Fields
26     const char     *format_string; //! Format string (a literal with format codes, for logging)
27     int             int_1;       //! Integer argument (%d, for logging)
28     int             int_2;       //! Integer argument (%d, for logging)
29     float           float_1;     //! Float argument (%f, for logging)
30     union {                      //! One additional argument (for logging)
31         const char *cstr_1;      //!   Cstr argument (%s) -- type checked at construct-time
32         const void *void_1;      //!   Void* argument (%x) -- Use upper-case codes for object types
33         long long   int64_1;     //!   signed int64 (%i).  Ambiguous if unsigned is also defined.
34         double      double_1;    //!   Double argument (%e)
35     };
36 
37 #//Constants
38 
39 #//Constructors
RoadLogEventRoadLogEvent40     RoadLogEvent() : format_string(0), int_1(0), int_2(0), float_1(0), int64_1(0) {};
RoadLogEventRoadLogEvent41     explicit RoadLogEvent(const char *fmt) : format_string(fmt), int_1(0), int_2(0), float_1(0), int64_1(0) {};
RoadLogEventRoadLogEvent42     RoadLogEvent(const char *fmt, int d) : format_string(fmt), int_1(d), int_2(0), float_1(0), int64_1(0) {};
RoadLogEventRoadLogEvent43     RoadLogEvent(const char *fmt, int d, int d2) : format_string(fmt), int_1(d), int_2(d2), float_1(0), int64_1(0) {};
RoadLogEventRoadLogEvent44     RoadLogEvent(const char *fmt, int d, int d2, float f) : format_string(fmt), int_1(d), int_2(d2), float_1(f), int64_1(0) {};
RoadLogEventRoadLogEvent45     RoadLogEvent(const char *fmt, int d, int d2, float f, const char *s) : format_string(fmt), int_1(d), int_2(d2), float_1(f), cstr_1(s) {};
RoadLogEventRoadLogEvent46     RoadLogEvent(const char *fmt, int d, int d2, float f, const void *x) : format_string(fmt), int_1(d), int_2(d2), float_1(f), void_1(x) {};
RoadLogEventRoadLogEvent47     RoadLogEvent(const char *fmt, int d, int d2, float f, int i) : format_string(fmt), int_1(d), int_2(d2), float_1(f), int64_1(i) {};
RoadLogEventRoadLogEvent48     RoadLogEvent(const char *fmt, int d, int d2, float f, long long i) : format_string(fmt), int_1(d), int_2(d2), float_1(f), int64_1(i) {};
RoadLogEventRoadLogEvent49     RoadLogEvent(const char *fmt, int d, int d2, float f, double g) : format_string(fmt), int_1(d), int_2(d2), float_1(f), double_1(g) {};
~RoadLogEventRoadLogEvent50     ~RoadLogEvent() {};
51     //! Default copy constructor and assignment
52 
53 #//GetSet
isDefinedRoadLogEvent54     bool                isDefined() const { return format_string!=0; }
int1RoadLogEvent55     int                 int1() const { return int_1; };
int2RoadLogEvent56     int                 int2() const { return int_2; };
float1RoadLogEvent57     float               float1() const { return float_1; };
formatRoadLogEvent58     const char         *format() const { return format_string; };
cstr1RoadLogEvent59     const char         *cstr1() const { return cstr_1; };
void1RoadLogEvent60     const void         *void1() const { return void_1; };
int64RoadLogEvent61     long long           int64() const { return int64_1; };
double1RoadLogEvent62     double              double1() const { return double_1; };
63 
64 #//Conversion
65 
66     std::string        toString(const char* tag, int code) const;
67 
68 private:
69 #//Class helpers
70     static bool         firstExtraCode(std::ostream &os, char c, char *extraCode);
71 
72 
73 };//class RoadLogEvent
74 
75 }//namespace orgQhull
76 
77 #endif // ROADLOGEVENT_H
78