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