Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Message.h

Go to the documentation of this file.
00001 /*************** <auto-copyright.pl BEGIN do not edit this line> **************
00002  *
00003  * VR Juggler is (C) Copyright 1998-2003 by Iowa State University
00004  *
00005  * Original Authors:
00006  *   Allen Bierbaum, Christopher Just,
00007  *   Patrick Hartling, Kevin Meinert,
00008  *   Carolina Cruz-Neira, Albert Baker
00009  *
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Library General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2 of the License, or (at your option) any later version.
00014  *
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Library General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU Library General Public
00021  * License along with this library; if not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00023  * Boston, MA 02111-1307, USA.
00024  *
00025  * -----------------------------------------------------------------
00026  * File:          $RCSfile: Message.h,v $
00027  * Date modified: $Date: 2003/03/06 17:12:00 $
00028  * Version:       $Revision: 1.4 $
00029  * -----------------------------------------------------------------
00030  *
00031  *************** <auto-copyright.pl END do not edit this line> ***************/
00032 
00033 #ifndef _VRJ_TEST_MESSAGE_H_
00034 #define _VRJ_TEST_MESSAGE_H_
00035 
00036 #include <vector>
00037 #include <string>
00038 #include <sstream>
00039 
00040 namespace vrj {
00041 namespace test
00042 {
00043 
00044 /* Message with extra details.
00045 *
00046 * Really just a wrapper around a vector of std::strings
00047 * that describe the type of problem encountered
00048 */
00049 class Message
00050 {
00051 public:
00052   Message()
00053   {;}
00054 
00055   explicit Message( const std::string& shortDesc )
00056       : mShortDesc(shortDesc)
00057   {
00058      mShortDesc = shortDesc;
00059   }
00060 
00061   Message( const std::string &shortDesc,
00062            const std::string &detail1 )
00063       : mShortDesc(shortDesc)
00064   { addDetail(detail1); }
00065 
00066   Message( const std::string &shortDesc,
00067            const std::string &detail1,
00068            const std::string &detail2 )
00069       : mShortDesc(shortDesc)
00070   { addDetail(detail1, detail2); }
00071 
00072   Message( const std::string &shortDesc,
00073            const std::string &detail1,
00074            const std::string &detail2,
00075            const std::string &detail3 )
00076   : mShortDesc(shortDesc)
00077   { addDetail(detail1, detail2, detail3); }
00078 
00082   std::string shortDesc()
00083   { return mShortDesc; }
00084 
00098   std::string details() const
00099   {
00100      std::stringstream oss;
00101 
00102      for(unsigned i=0;i<mDetails.size();i++)
00103         oss << "- " << mDetails[i] << "\n";
00104 
00105      return oss.str();
00106   }
00107 
00110   void clearDetails()
00111   {  mDetails.clear(); }
00112 
00114   std::vector<std::string> getDetails()
00115   { return mDetails;}
00116 
00118   void addDetail( const std::string &detail )
00119   { mDetails.push_back(detail); }
00120 
00122   void addDetail( const std::string& detail1,
00123                   const std::string& detail2 )
00124   { addDetail(detail1); addDetail(detail2); }
00125 
00127   void addDetail( const std::string &detail1,
00128                   const std::string &detail2,
00129                   const std::string &detail3 )
00130   { addDetail(detail1); addDetail(detail2); addDetail(detail3); }
00131 
00133   void setShortDesc( const std::string& shortDesc )
00134   { mShortDesc = shortDesc; }
00135 
00136 private:
00137   std::string              mShortDesc;    
00138   std::vector<std::string> mDetails;      
00139 };
00140 
00141 } }
00142 
00143 #endif
00144 
00145 

Generated on Sun May 2 15:10:17 2004 for VR Juggler by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002