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

Options.cpp

Go to the documentation of this file.
00001 
00002 /*
00003     TEDDY - General graphics application library
00004     Copyright (C) 1999-2002  Timo Suoranta
00005     tksuoran@cc.helsinki.fi
00006 
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2.1 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 
00021     $Id: Options.cpp,v 1.6 2002/03/12 10:46:06 tksuoran Exp $
00022 */
00023 
00024 
00025 #include "Teddy/MixIn/Options.h"
00026 
00027 
00028 namespace Teddy {
00029 namespace MixIn {
00030 
00031 
00033 Options::Options(){
00034     options = 0;
00035 }
00036 
00037 
00039 Options::Options( const unsigned long options ){
00040     this->options = options;
00041 }
00042 
00043 
00044 /*virtual*/ Options::~Options(){
00045 }
00046 
00047 
00049 void Options::setOptions( const unsigned long options ){
00050     this->options = options;
00051 }
00052 
00053 
00055 unsigned long Options::getOptions() const {
00056     return this->options;
00057 }
00058 
00059 
00061 void Options::enable( const unsigned long options ){
00062     this->options |= options;
00063 }
00064 
00065 
00067 void Options::disable( const unsigned long options ){
00068     this->options &= ~options;
00069 }
00070 
00071 
00073 void Options::toggle( const unsigned long options ){
00074     this->options ^= options;
00075 }
00076 
00077 
00078 unsigned long Options::operator &( const Options &other ){
00079     return options & other.getOptions();
00080 }
00081 
00082 
00083 unsigned long Options::operator |( const Options &other ){
00084     return options | other.getOptions();
00085 }
00086 
00087 
00088 Options &Options::operator &=( const Options &other ){
00089     options &= other.getOptions();
00090     return *this;
00091 }
00092 
00093 
00094 Options &Options::operator |=( const Options &other ){
00095     options |= other.getOptions();
00096     return *this;
00097 }
00098 
00099 
00100 Options &Options::operator ^=( const Options &other ){
00101     options ^= other.getOptions();
00102     return *this;
00103 }
00104 
00105 
00107 bool Options::isEnabled( const unsigned long options ){
00108     if( (this->options & options) == options ){
00109         return true;
00110     }else{
00111         return false;
00112     }
00113 }
00114 
00115 
00116 const char *Options::isEnabledStr( const unsigned long options ){
00117     if( isEnabled(options) ){
00118         return "enabled";
00119     }else{
00120         return "disabled";
00121     }
00122 }
00123 
00124 
00126 bool Options::isDisabled( const unsigned long options ){
00127     if( (this->options & options) == 0 ){
00128         return true;
00129     }else{
00130         return false;
00131     }
00132 }
00133 
00134 
00135 };  //  namespace MixIn
00136 };  //  namespace Teddy
00137