papyrus logo

utility.h

Go to the documentation of this file.
00001 /***************************************************************************
00002  *   Copyright (C) 2004 by Rick L. Vinyard, Jr.                            *
00003  *   rvinyard@cs.nmsu.edu                                                  *
00004  *                                                                         *
00005  *   This file is part of the papyrus library.                             *
00006  *                                                                         *
00007  *   papyrus is free software; you can redistribute it and/or modify       *
00008  *   it under the terms of the GNU Lesser General Public License           *
00009  *   version 3.0 as published by the Free Software Foundation.             *
00010  *                                                                         *
00011  *   papyrus is distributed in the hope that it will be useful,            *
00012  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00013  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00014  *   GNU Lesser General Public License version 3.0 for more details.       *
00015  *                                                                         *
00016  *   You should have received a copy of the GNU Lesser General Public      *
00017  *   License along with the papyrus library. If not, see                   *
00018  *   <http://www.gnu.org/licenses/>.                                       *
00019  ***************************************************************************/
00020 #ifndef PAPYRUS_UTILITY_H
00021 #define PAPYRUS_UTILITY_H
00022 
00023 #include <papyrus/enums.h>
00024 #include <glibmm/ustring.h>
00025 #include <papyrus/pointer.h>
00026 
00027 #define PAPYRUS_CLASS_NAME( StrName )             \
00028   static const Glib::ustring& name_string()       \
00029   {                                               \
00030     static const Glib::ustring cn(StrName);       \
00031     return cn;                                    \
00032   }                                               \
00033                                                   \
00034   virtual const Glib::ustring& class_name() const \
00035   {                                               \
00036     static const Glib::ustring cn(StrName);       \
00037     return cn;                                    \
00038   }
00039 
00040 #define PAPYRUS_RENDERABLE( Name )                  \
00041   typedef PapyrusPointer<Name> pointer;             \
00042                                                     \
00043   typedef PapyrusPointer<const Name> const_pointer; \
00044                                                     \
00045   typedef PapyrusWeakPointer<Name> weak_pointer;    \
00046                                                     \
00047   using Renderable::render;                         \
00048                                                     \
00049   PAPYRUS_CLASS_NAME("Name")
00050 
00051 #define PAPYRUS_CLONE_METHOD( Type )          \
00052   virtual Drawable::pointer clone() const {   \
00053     Type::pointer other = Type::create();     \
00054     *other = *this;                           \
00055     return other;                             \
00056   }
00057   
00058 #define PAPYRUS_DRAWABLE(Name)                \
00059   PAPYRUS_RENDERABLE(Name)                    \
00060                                               \
00061   PAPYRUS_CLONE_METHOD(Name)
00062 
00063 #define PAPYRUS_CREATE( BaseObjCall )     \
00064   pointer p = pointer( new BaseObjCall ); \
00065   p->m_self = p;                          \
00066   return p;
00067 
00068   namespace Papyrus {
00069 
00070   double rad2units(double value, DegRad units);
00071 
00072   double units2rad(double value, DegRad units);
00073 
00074   bool strcaseeq( const Glib::ustring& str1, const Glib::ustring& str2 );
00075 
00076   int strcasecmp( const Glib::ustring& str1, const Glib::ustring& str2 );
00077   
00078   class Drawable;
00079   
00080   struct wp_lt_compare {
00081     bool operator()( const PapyrusWeakPointer<Drawable>&, const PapyrusWeakPointer<Drawable>& );
00082   };
00083   
00084   }
00085 
00086 #endif

Generated on Fri Apr 16 12:40:11 2010 for papyrus by doxygen 1.6.1