Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

magserverresult.h

Go to the documentation of this file.
00001 // magserverresult.h: interface for the MagServerResult class.
00002 //
00004 
00005 #if !defined(_MAGSERVERRESULT_H__INCLUDED_)
00006 #define _MAGSERVERRESULT_H__INCLUDED_
00007 
00008 #if _MSC_VER > 1000
00009 #pragma once
00010 #endif // _MSC_VER > 1000
00011 
00012 #include "mutableserverresult.h"
00013 #include <earthworm_defs.h>  // MAG_NULL
00014 #include <string>
00015 #include <vector>
00016 
00017 
00018 //-------------------------------------------------------------------
00019 
00020 
00021 typedef struct _MAG_SRVR_CHANNEL
00022 {
00023    long   ampid;  // id if amp came from database
00024    long   channelid;
00025    long   componentid;
00026    char   sta[10];
00027    char   comp[10];
00028    char   net[10];
00029    char   loc[10];
00030    float  lat;
00031    float  lon;
00032    float  elev;
00033    float  azm;
00034    float  dip;
00035 
00036    float  magnitude;
00037 
00038    float  amp1;
00039    double amp1time;
00040    float  amp1period;
00041 
00042    float  amp2;
00043    double amp2time;
00044    float  amp2period;
00045 
00046 } MAG_SRVR_CHANNEL;
00047 
00048 typedef std::vector<MAG_SRVR_CHANNEL> MAG_SRVR_CHANNEL_VECTOR;
00049 
00050 //-------------------------------------------------------------------
00051 class MagServerResult : public MutableServerResult  
00052 {
00053 protected:
00054 
00055    // ----------------------------------------------------------
00056    //     virtual methods from MutableServerMessage
00057    //     to be implemented for a complete derivative classes
00058    // ----------------------------------------------------------
00059 
00060    // BufferInitAlloc -- when preparing to format a message
00061    //                    using FormatBuffer()], this is
00062    //                    first called.  The result is,
00063    //                    for the first call, MessageBuffer
00064    //                    will be assured to be at least this
00065    //                    long.
00066    //                    Overriding this method allows
00067    //                    derivative classes to minimize
00068    //                    reallocations as bits are appended
00069    //                    to the message buffer;
00070    //
00071    // NOTE: In each derivative implementation,
00072    //       call <super_class>::BufferInitAlloc() to get the
00073    //       space needed by that super class (and all baser
00074    //       classes), then add the size needed by the
00075    //       derivative to arrive at the total size needed.
00076    //
00077    long BufferInitAlloc();
00078 
00079 
00080    // FormatDerivativeData
00081    //
00082    //     Method by which derivative classes append
00083    //     their content to MessageBuffer.
00084    //
00085    //
00086    //  NOTE: ALWAYS CALL <super_class>::FormatDerivativeData()
00087    //        at the start of each implementation to allow
00088    //        base classes to append their stuff (if any)
00089    //        to the buffer.
00090    //        Thus the buffer is built up from the base-most class.
00091    //
00092    // THROW worm_exception for errors
00093    //
00094    void FormatDerivativeData();
00095 
00096 
00097    // ParseDerivativeData
00098    //
00099    //     Method by which derivative classes extract
00100    //     their content from MessageBuffer.
00101    //
00102    //  NOTE: Always call <super_class>::ParseDerivativeData()
00103    //        at the top of each implementation to allow
00104    //        base classes to get their data out of the
00105    //        buffer first.
00106    //
00107    //  USAGE:
00108    //
00109    //     If parsing a multi-line message ('\n'-terminated lines),
00110    //     use a loop consisting of:
00111    //
00112    //       i = MessageBuffer.find("\n")  to find the first line end,
00113    //       MessageBuffer.substr(0, i)    to extract the string
00114    //                                        (excluding the '\n')
00115    //       MessageBuffer.erase(0, i+1)     to remove that portion
00116    //
00117    //     Since the message should be terminated by an additional
00118    //     '\n', when the string returned in the second step
00119    //     is of zero length, that is the end of the message.
00120    //
00121    //     (If find() does not, it returns MessageBuffer.npos)
00122    //
00123    // THROW worm_exception for errors
00124    //
00125    void ParseDerivativeData();
00126 
00127 
00128    // ----------------------------------------------------------
00129    //                   for MagServerResult
00130    // ----------------------------------------------------------
00131 
00132    long  EventId
00133       ,  OriginId
00134       ;
00135    int   MagType;
00136    float MagAverage;
00137    float MagError;
00138 
00139    std::string Author;
00140    
00141    MAG_SRVR_CHANNEL_VECTOR Channels;
00142    
00143 public:
00144 
00145         MagServerResult();
00146 
00147    void SetMagnitudeInfo(       long    p_eventid
00148                         ,       long    p_originid
00149                         ,       int     p_magtype
00150                         ,       float   p_average
00151                         ,       float   p_error
00152                         , const char  * p_author
00153                         );
00154 
00155    void ClearChannels();
00156 
00157    // This will not overwrite/update existing
00158    // information for a channel, calling it again
00159    // for the same channel will duplicate the channel
00160    void AddChannel( MAG_SRVR_CHANNEL p_channelinfo );
00161 
00162 
00163    const long GetEventId() const;
00164    
00165    const long GetOriginId() const;
00166 
00167    const int GetMagType() const;
00168 
00169    const float GetAverage() const;
00170 
00171    const float GetError() const;
00172 
00173    const char * GetAuthor() const;
00174 
00175    const int GetChannelCount();
00176 
00177    bool GetChannel( unsigned int p_index
00178                   , MAG_SRVR_CHANNEL * r_channel
00179                   ) const;
00180 
00181 };
00182 
00183 #endif // !defined(_MAGSERVERRESULT_H__INCLUDED_)

Generated on Tue May 6 09:16:04 2003 for Earthworm Libs by doxygen1.3-rc3