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

dtool/src/interrogatedb/indexRemapper.cxx

Go to the documentation of this file.
00001 // Filename: indexRemapper.cxx
00002 // Created by:  drose (05Aug00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include "indexRemapper.h"
00020 
00021 
00022 ////////////////////////////////////////////////////////////////////
00023 //     Function: IndexRemapper::Constructor
00024 //       Access: Public
00025 //  Description:
00026 ////////////////////////////////////////////////////////////////////
00027 IndexRemapper::
00028 IndexRemapper() {
00029 }
00030 
00031 ////////////////////////////////////////////////////////////////////
00032 //     Function: IndexRemapper::Destructor
00033 //       Access: Public
00034 //  Description:
00035 ////////////////////////////////////////////////////////////////////
00036 IndexRemapper::
00037 ~IndexRemapper() {
00038 }
00039 
00040 ////////////////////////////////////////////////////////////////////
00041 //     Function: IndexRemapper::clear
00042 //       Access: Public
00043 //  Description: Removes all mappings from the object.
00044 ////////////////////////////////////////////////////////////////////
00045 void IndexRemapper::
00046 clear() {
00047   _map_int.clear();
00048 }
00049 
00050 ////////////////////////////////////////////////////////////////////
00051 //     Function: IndexRemapper::add_mapping
00052 //       Access: Public
00053 //  Description: Adds a mapping from the integer 'from' to 'to'.
00054 ////////////////////////////////////////////////////////////////////
00055 void IndexRemapper::
00056 add_mapping(int from, int to) {
00057   _map_int[from] = to;
00058 }
00059 
00060 ////////////////////////////////////////////////////////////////////
00061 //     Function: IndexRemapper::in_map
00062 //       Access: Public
00063 //  Description: Returns true if the given 'from' integer has been
00064 //               assigned a mapping, false if it has not.
00065 ////////////////////////////////////////////////////////////////////
00066 bool IndexRemapper::
00067 in_map(int from) const {
00068   return _map_int.count(from) != 0;
00069 }
00070 
00071 ////////////////////////////////////////////////////////////////////
00072 //     Function: IndexRemapper::map_from
00073 //       Access: Public
00074 //  Description: Returns the integer that the given 'from' integer had
00075 //               been set to map to, or the same integer if nothing
00076 //               had been set for it.
00077 ////////////////////////////////////////////////////////////////////
00078 int IndexRemapper::
00079 map_from(int from) const {
00080   map<int, int>::const_iterator mi;
00081   mi = _map_int.find(from);
00082   if (mi == _map_int.end()) {
00083     return from;
00084   }
00085   return (*mi).second;
00086 }

Generated on Thu May 1 22:13:04 2003 for DTool by doxygen1.3