include/messages.h

Go to the documentation of this file.
00001 /********************************************************************************
00002  *  Neural Network Framework.                                                   *
00003  *  Copyright (C) 2005-2008 Gianluca Massera <emmegian@yahoo.it>                *
00004  *                                                                              *
00005  *  This program is free software; you can redistribute it and/or modify        *
00006  *  it under the terms of the GNU General Public License as published by        *
00007  *  the Free Software Foundation; either version 2 of the License, or           *
00008  *  (at your option) any later version.                                         *
00009  *                                                                              *
00010  *  This program is distributed in the hope that it will be useful,             *
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of              *
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               *
00013  *  GNU General Public License for more details.                                *
00014  *                                                                              *
00015  *  You should have received a copy of the GNU General Public License           *
00016  *  along with this program; if not, write to the Free Software                 *
00017  *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA  *
00018  ********************************************************************************/
00019 
00020 // --- You can't include it directly
00021 #ifndef TYPES_INCLUDES
00022 #error "You can't include messages.h directly; Instead, You have to include types.h"
00023 #endif
00024 
00025 #ifndef MESSAGGES_H
00026 #define MESSAGGES_H
00027 
00028 namespace nnfw {
00029 
00035 //--- This is for internal use; it encapsulate string-data
00036 class nnfwStringPrivate;
00037 
00040 class NNFW_API nnfwString {
00041 public:
00045     nnfwString();
00047     ~nnfwString();
00049     nnfwString( const nnfwString& );
00051     nnfwString( int );
00053     nnfwString( unsigned int );
00055     nnfwString( double );
00057     nnfwString( float );
00059     nnfwString( char );
00061     nnfwString( const char* );
00063 
00066     nnfwString& append( const nnfwString& p );
00068     nnfwString& operator=( const nnfwString& left );
00070     bool operator==( const nnfwString& left );
00072     const char* toUtf8() const;
00074 private:
00075     nnfwStringPrivate* prv;
00076 };
00077 
00080 class NNFW_API nMessage {
00081 public:
00085     nMessage();
00087     ~nMessage() { /* nothing to do */ };
00089 protected:
00090     //--- Helper class for printing messages
00091     class NNFW_API msgLine {
00092     public:
00093         msgLine( nMessage* parent );
00094         ~msgLine();
00095         msgLine& operator<<( const nnfwString& part ) {
00096             msg.append( part );
00097             return (*this);
00098         };
00099         void set( const nnfwString& str ) {
00100             msg = str;
00101         };
00102     private:
00103         nMessage* parent;
00104         nnfwString msg;
00105     };
00106     bool linePending;
00107     msgLine* pending;
00108 };
00109 
00112 class NNFW_API nWarning : public nMessage {
00113 public:
00117     nMessage::msgLine operator<<( const nnfwString& part ) {
00118         nMessage::msgLine line(this);
00119         line.set( nnfwString("== WARNING: ").append(part) );
00120         return line;
00121     };
00123 };
00124 
00127 class NNFW_API nError : public nMessage {
00128 public:
00132     nMessage::msgLine operator<<( const nnfwString& part ) {
00133         nMessage::msgLine line(this);
00134         line.set( nnfwString("== ERROR: ").append(part) );
00135         return line;
00136     };
00138 };
00139 
00142 class NNFW_API nFatal : public nMessage {
00143 public:
00147     nMessage::msgLine operator<<( const nnfwString& part ) {
00148         nMessage::msgLine line(this);
00149         line.set( nnfwString("== FATAL: ").append(part) );
00150         return line;
00151     };
00153 };
00154 
00155 }
00156 
00157 #endif
00158 
00159 
BerliOS Developer Logo Valid XHTML 1.0 Transitional Valid CSS!