osgEarth 2.1.1
|
00001 /* -*-c++-*- */ 00002 /* osgEarth - Dynamic map generation toolkit for OpenSceneGraph 00003 * Copyright 2008-2010 Pelican Mapping 00004 * http://osgearth.org 00005 * 00006 * osgEarth is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU Lesser General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public License 00017 * along with this program. If not, see <http://www.gnu.org/licenses/> 00018 */ 00019 #ifndef OSGEARTH_FEATURES_VIRTUAL_FEATURE_SOURCE 00020 #define OSGEARTH_FEATURES_VIRTUAL_FEATURE_SOURCE 00021 00022 #include <osgEarthUtil/Common> 00023 #include <osgEarthFeatures/FeatureSource> 00024 #include <osgEarth/Layer> 00025 #include <vector> 00026 00027 namespace osgEarth { namespace Features 00028 { 00029 using namespace osgEarth; 00030 using namespace osgEarth::Features; 00031 using namespace osgEarth::Symbology; 00032 00037 struct OSGEARTHFEATURES_EXPORT FeaturePredicate : public osg::Referenced 00038 { 00039 virtual bool acceptFeature( Feature* f ) const =0; 00040 }; 00041 00042 // internal class 00043 struct FeatureSourceMapping 00044 { 00045 FeatureSourceMapping(FeatureSource* fs, FeaturePredicate* fp) : _source(fs), _predicate(fp) { } 00046 osg::ref_ptr<FeatureSource> _source; 00047 osg::ref_ptr<FeaturePredicate> _predicate; 00048 }; 00049 typedef std::vector<FeatureSourceMapping> FeatureSourceMappingVector; 00050 00051 00052 class OSGEARTHFEATURES_EXPORT VirtualFeatureSource : public FeatureSource 00053 { 00054 public: 00056 VirtualFeatureSource() { } 00057 00062 void add( FeatureSource* source, FeaturePredicate* predicate ); 00063 00064 public: // FeatureSource 00065 virtual FeatureCursor* createFeatureCursor( const Query& query ); 00066 virtual void initialize( const std::string& referenceURI ); 00067 virtual const FeatureProfile* createFeatureProfile(); 00068 virtual const FeatureSchema& getSchema() const; 00069 virtual Feature* getFeature( FeatureID id ) { return 0L; } 00070 00071 protected: 00072 FeatureSourceMappingVector _sources; 00073 }; 00074 00075 } } // namespace osgEarth::Features 00076 00077 #endif // OSGEARTH_FEATURES_VIRTUAL_FEATURE_SOURCE