ScalerManager.cpp

Go to the documentation of this file.
00001 /*
00002  *  Copyright (C) 2002  Ryan Nunn and The Pentagram Team
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00019 #include "pent_include.h"
00020 #include "ScalerManager.h"
00021 #include "Scaler.h"
00022 #include "scalers/PointScaler.h"
00023 
00024 ScalerManager *ScalerManager::scaler_man = 0;
00025 
00026 //
00027 // Constructor
00028 //
00029 ScalerManager::ScalerManager()
00030 {
00031 }
00032 
00033 //
00034 // Destructor
00035 //
00036 ScalerManager::~ScalerManager()
00037 {
00038 }
00039 
00040 //
00041 // Get the total Number of scalers
00042 //
00043 uint32 ScalerManager::GetNumScalers()
00044 {
00045         return scalers.size();
00046 }
00047 
00048 //
00049 // Get the Index of a scaler from its Name
00050 //
00051 uint32 ScalerManager::GetIndexForName(const Pentagram::istring name)
00052 {
00053         std::vector<const Pentagram::Scaler*>::iterator it;
00054         uint32 index = 0;
00055 
00056         for (it = scalers.begin(); it != scalers.end(); ++it, ++index) {
00057 
00058                 if (name == (*it)->ScalerName()) return index;
00059         }
00060 
00061         return 0xFFFFFFFF;
00062 }
00063 
00064 //
00065 // Get Name of a Scaler from its Index
00066 //
00067 const char *ScalerManager::GetNameForIndex(uint32 index)
00068 {
00069         if (index >= scalers.size()) return 0;
00070 
00071         return scalers[index]->ScalerName();
00072 }
00073 
00074 
00075 //
00076 // Get a Scaler from its Index
00077 //
00078 const Pentagram::Scaler *ScalerManager::GetScaler(uint32 index)
00079 {
00080         if (index >= scalers.size()) return 0;
00081         
00082         return scalers[index];
00083 }
00084 
00085 //
00086 // Get the Index of a scaler from its Name
00087 //
00088 const Pentagram::Scaler *ScalerManager::GetScaler(const Pentagram::istring name)
00089 {
00090         std::vector<const Pentagram::Scaler*>::iterator it;
00091 
00092         for (it = scalers.begin(); it != scalers.end(); ++it) {
00093 
00094                 if (name == (*it)->ScalerName()) return *it;
00095         }
00096 
00097         return 0;
00098 }
00099 
00100 //
00101 // Adds a scaler
00102 // 
00103 uint32 ScalerManager::AddScaler(const Pentagram::Scaler *scaler)
00104 {
00105         if (!scaler) return 0xFFFFFFFF;
00106 
00107         std::vector<const Pentagram::Scaler*>::iterator it;
00108         uint32 index = 0;
00109 
00110         for (it = scalers.begin(); it != scalers.end(); ++it, ++index) {
00111 
00112                 if (scaler == (*it)) return index;
00113         }
00114 
00115         scalers.push_back(scaler);
00116         return scalers.size()-1;
00117 }
00118 
00119 //
00120 // Get the Point Sampling Scaler
00121 //
00122 const Pentagram::Scaler *ScalerManager::GetPointScaler()
00123 {
00124         // Point scaler is always first
00125         return &Pentagram::point_scaler;
00126 }
00127 
00128 

Generated on Fri Jul 27 22:27:34 2007 for pentagram by  doxygen 1.4.7