WhirlyGlobe  1.1
A 3D interactive globe toolkit for ios
/Users/sjg/iPhone/WhirlyGlobe/WhirlyGlobeSrc/WhirlyGlobeLib/include/Identifiable.h
00001 /*
00002  *  Identifiable.h
00003  *  WhirlyGlobeLib
00004  *
00005  *  Created by Steve Gifford on 2/7/11.
00006  *  Copyright 2011 mousebird consulting
00007  *
00008  *  Licensed under the Apache License, Version 2.0 (the "License");
00009  *  you may not use this file except in compliance with the License.
00010  *  You may obtain a copy of the License at
00011  *  http://www.apache.org/licenses/LICENSE-2.0
00012  *
00013  *  Unless required by applicable law or agreed to in writing, software
00014  *  distributed under the License is distributed on an "AS IS" BASIS,
00015  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016  *  See the License for the specific language governing permissions and
00017  *  limitations under the License.
00018  *
00019  */
00020 
00021 #import <set>
00022 
00023 namespace WhirlyGlobe
00024 {
00025 
00032 typedef unsigned long SimpleIdentity;
00033     
00036 static const SimpleIdentity EmptyIdentity = 0;
00037     
00039 typedef std::set<SimpleIdentity> SimpleIDSet;
00040 
00046 class Identifiable
00047 {
00048 public:
00050         // Note: This will probably work with multiple threads
00051         Identifiable();
00052         virtual ~Identifiable() { }
00053         
00055         SimpleIdentity getId() const { return myId; }
00056         
00059         void setId(SimpleIdentity inId) { myId = inId; }
00060 
00064         static SimpleIdentity genId();
00065     
00067     bool operator < (const Identifiable &that) { return myId < that.myId; }
00068                 
00069 protected:
00070         SimpleIdentity myId;
00071 };
00072         
00074 typedef struct
00075 {
00076         bool operator () (const Identifiable *a,const Identifiable *b) { return a->getId() < b->getId(); }
00077 } IdentifiableSorter;
00078 
00079 }
00080