[1452] | 1 | //#--------------------------------------------------------------------------- |
---|
| 2 | //# PKSmsg.h: Message handling for the PKSIO classes. |
---|
| 3 | //#--------------------------------------------------------------------------- |
---|
[1720] | 4 | //# livedata - processing pipeline for single-dish, multibeam spectral data. |
---|
| 5 | //# Copyright (C) 2008-2009, Australia Telescope National Facility, CSIRO |
---|
[1452] | 6 | //# |
---|
[1720] | 7 | //# This file is part of livedata. |
---|
[1452] | 8 | //# |
---|
[1720] | 9 | //# livedata is free software: you can redistribute it and/or modify it under |
---|
| 10 | //# the terms of the GNU General Public License as published by the Free |
---|
| 11 | //# Software Foundation, either version 3 of the License, or (at your option) |
---|
| 12 | //# any later version. |
---|
| 13 | //# |
---|
| 14 | //# livedata is distributed in the hope that it will be useful, but WITHOUT |
---|
[1452] | 15 | //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
[1720] | 16 | //# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
---|
| 17 | //# more details. |
---|
[1452] | 18 | //# |
---|
[1720] | 19 | //# You should have received a copy of the GNU General Public License along |
---|
| 20 | //# with livedata. If not, see <http://www.gnu.org/licenses/>. |
---|
[1452] | 21 | //# |
---|
[1720] | 22 | //# Correspondence concerning livedata may be directed to: |
---|
| 23 | //# Internet email: mcalabre@atnf.csiro.au |
---|
| 24 | //# Postal address: Dr. Mark Calabretta |
---|
| 25 | //# Australia Telescope National Facility, CSIRO |
---|
| 26 | //# PO Box 76 |
---|
| 27 | //# Epping NSW 1710 |
---|
| 28 | //# AUSTRALIA |
---|
[1452] | 29 | //# |
---|
[1720] | 30 | //# http://www.atnf.csiro.au/computing/software/livedata.html |
---|
| 31 | //# $Id: PKSmsg.h,v 1.3 2009-09-29 07:33:38 cal103 Exp $ |
---|
[1452] | 32 | //#--------------------------------------------------------------------------- |
---|
| 33 | //# Original: 2008/09/18, Mark Calabretta, ATNF |
---|
| 34 | //#--------------------------------------------------------------------------- |
---|
| 35 | |
---|
| 36 | #ifndef ATNF_PKSMSG_H |
---|
| 37 | #define ATNF_PKSMSG_H |
---|
| 38 | |
---|
| 39 | #include <casa/stdio.h> |
---|
| 40 | |
---|
| 41 | using namespace std; |
---|
| 42 | |
---|
| 43 | // <summary> |
---|
| 44 | // Message handling for the PKSIO classes. |
---|
| 45 | // </summary> |
---|
| 46 | |
---|
| 47 | class PKSmsg |
---|
| 48 | { |
---|
| 49 | public: |
---|
| 50 | // Constructor. |
---|
| 51 | PKSmsg(); |
---|
| 52 | |
---|
| 53 | // Destructor. |
---|
| 54 | virtual ~PKSmsg(); |
---|
| 55 | |
---|
| 56 | // Set message disposition. If fd is non-zero messages will be written |
---|
| 57 | // to that file descriptor, else stored for retrieval by getMsg(). |
---|
| 58 | virtual int setMsg( |
---|
| 59 | FILE *fd = 0x0); |
---|
| 60 | |
---|
| 61 | // Log a message. |
---|
| 62 | virtual void logMsg(const char *msg = 0x0); |
---|
| 63 | |
---|
| 64 | // Get a message string, or 0x0 if there is none. The null-terminated |
---|
| 65 | // message string may contain embedded newline characters and will have |
---|
| 66 | // a trailing newline. |
---|
| 67 | const char *getMsg(); |
---|
| 68 | |
---|
| 69 | // Get the next group of messages by type: ERROR, WARNING, or otherwise. |
---|
| 70 | // The null-terminated message string may contain embedded newline |
---|
| 71 | // characters but will NOT have a trailing newline. Call this repeatedly |
---|
| 72 | // to unwind the message stack (otherwise messages may be lost). |
---|
| 73 | enum msgType {NORMAL, WARNING, ERROR}; |
---|
| 74 | const char *getMsg(msgType &type); |
---|
| 75 | |
---|
| 76 | // Clear the message buffer. |
---|
| 77 | void clearMsg(void); |
---|
| 78 | |
---|
| 79 | protected: |
---|
| 80 | // Initialize messaging. |
---|
| 81 | void initMsg(); |
---|
| 82 | |
---|
| 83 | private: |
---|
| 84 | // For messaging. |
---|
| 85 | char *cMsgBuff, *cMsgIdx; |
---|
| 86 | int cMsgLen, cNMsg; |
---|
| 87 | FILE *cMsgFD; |
---|
| 88 | }; |
---|
| 89 | |
---|
| 90 | #endif |
---|