00001 // Filename: dxfLayerMap.cxx 00002 // Created by: drose (04May04) 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 "dxfLayerMap.h" 00016 #include "dxfFile.h" 00017 00018 //////////////////////////////////////////////////////////////////// 00019 // Function: DXFLayerMap::get_layer 00020 // Access: Public 00021 // Description: Looks up the layer name in the map, and returns a 00022 // pointer to the associated DXFLayer. If this is the 00023 // first time this layer name has been used, creates a 00024 // new DXFLayer by the given name. In this case, it 00025 // calls dxffile->new_layer() to create the layer, 00026 // allowing user code to override this function to 00027 // create a specialized time, if desired. 00028 //////////////////////////////////////////////////////////////////// 00029 DXFLayer *DXFLayerMap:: 00030 get_layer(const string &name, DXFFile *dxffile) { 00031 iterator lmi; 00032 lmi = find(name); 00033 if (lmi != end()) { 00034 // The layer was already here. 00035 return (*lmi).second; 00036 } 00037 00038 // Need a new layer. 00039 DXFLayer *layer = dxffile->new_layer(name); 00040 (*this)[name] = layer; 00041 00042 return layer; 00043 } 00044