/usr/include/osgEarth/Registry is in libosgearth-dev 2.9.0+dfsg-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 | /* -*-c++-*- */
/* osgEarth - Dynamic map generation toolkit for OpenSceneGraph
* Copyright 2016 Pelican Mapping
* http://osgearth.org
*
* osgEarth is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>
*/
#ifndef OSGEARTH_REGISTRY
#define OSGEARTH_REGISTRY 1
#include <osgEarth/Common>
#include <osgEarth/CachePolicy>
#include <osgEarth/SharedSARepo>
#include <osgEarth/Containers>
#include <osgEarth/TraversalData>
#include <osgEarth/ShaderGenerator>
#include <OpenThreads/ReentrantMutex>
#include <OpenThreads/ScopedLock>
#include <osgEarth/ThreadingUtils>
#include <osgEarth/SpatialReference>
#include <osg/Referenced>
#include <osg/OperationThread>
#include <set>
#define GDAL_SCOPED_LOCK \
OpenThreads::ScopedLock<OpenThreads::ReentrantMutex> _slock( osgEarth::getGDALMutex() )\
namespace osgText {
class Font;
}
namespace osgEarth
{
class Cache;
class Capabilities;
class Profile;
class ShaderFactory;
class TaskServiceManager;
class URIReadCallback;
class ColorFilterRegistry;
class StateSetCache;
class ObjectIndex;
class Units;
typedef SharedSARepo<osg::Program> ProgramSharedRepo;
extern OSGEARTH_EXPORT OpenThreads::ReentrantMutex& getGDALMutex();
/**
* Application-wide global repository.
*/
class OSGEARTH_EXPORT Registry : public osg::Referenced
{
public:
/** Access the global Registry singleton. */
static Registry* instance(bool erase = false);
/** Gets a well-known named profile instance. */
const Profile* getNamedProfile( const std::string& name ) const;
/** Gets the global-geodetic builtin profile */
const Profile* getGlobalGeodeticProfile() const;
/** @deprecated Gets the global-meractor builtin profile (mercator/WGS84 datum) */
const Profile* getGlobalMercatorProfile() const;
/** Gets the spherical-mercator builtin profile (mercator/sphere) */
const Profile* getSphericalMercatorProfile() const;
/** @deprecated Gets the unified cube builtin profile */
const Profile* getCubeProfile() const;
/** Gets a spatial reference object */
SpatialReference* getOrCreateSRS(const SpatialReference::Key& key);
/** Access to the application-wide GDAL serialization mutex. GDAL is not thread-safe. */
OpenThreads::ReentrantMutex& getGDALMutex();
/** Gets a default cache object - based on environment settings - unless setDefaultCache
was called to override it. */
Cache* getDefaultCache() const;
/** Sets a default cache that a Map will use if none other is specified. */
void setDefaultCache(Cache* cache);
/** The default cache policy (used when no policy is set elsewhere) */
const optional<CachePolicy>& defaultCachePolicy() const;
void setDefaultCachePolicy( const CachePolicy& policy );
/** The override cache policy (overrides all others if set) */
const optional<CachePolicy>& overrideCachePolicy() const;
void setOverrideCachePolicy( const CachePolicy& policy );
/** The default cache driver. */
void setDefaultCacheDriverName( const std::string& name );
const std::string& getDefaultCacheDriverName() const;
/**
* Given a CachePolicy, composites in the default and override cache policies
* as necessary to create an effective CachePolicy. First it will populate
* any unset properties in "cp" with defaults if they are available. Then it
* will override any properties in "cp" with overrides that are available.
*/
bool resolveCachePolicy(optional<CachePolicy>& cp) const;
/**
* Whether the given filename is blacklisted
*/
bool isBlacklisted(const std::string &filename);
/**
* Blacklist the given filename
*/
void blacklist(const std::string &filename);
/**
* Gets the number of blacklisted filenames
*/
unsigned int getNumBlacklistedFilenames();
/**
* Clears the blacklist
*/
void clearBlacklist();
/**
* Sets or gets a default system font to use
*/
void setDefaultFont( osgText::Font* font );
osgText::Font* getDefaultFont();
/**
* The graphics hardware capabilities for this platform.
*/
bool hasCapabilities() const;
const Capabilities& getCapabilities() const;
void setCapabilities( Capabilities* caps );
static const Capabilities& capabilities() { return instance()->getCapabilities(); }
/**
* Gets or sets the default shader factory. You can replace the default
* shader factory if you want to alter any of osgEarth's baseline shaders
* (advanced usage).
*/
ShaderFactory* getShaderFactory() const;
void setShaderFactory( ShaderFactory* lib );
static ShaderFactory* shaderFactory() { return instance()->getShaderFactory(); }
/**
* The default shader generator.
*/
ShaderGeneratorProxy getShaderGenerator() const;
void setShaderGenerator(ShaderGenerator* gen);
static ShaderGeneratorProxy shaderGenerator() { return instance()->getShaderGenerator(); }
/**
* Global object index.
*/
ObjectIndex* getObjectIndex() const;
static ObjectIndex* objectIndex() { return instance()->getObjectIndex(); }
/**
* A default StateSetCache to use by any process that uses one.
* A StateSetCache assist in stateset sharing across multiple nodes.
* Note: A registry-wide SSC is only supported in OSG 3.1.4+. See
* the Registry.cpp comments for details.
*/
StateSetCache* getStateSetCache() const;
void setStateSetCache( StateSetCache* cache );
static StateSetCache* stateSetCache() { return instance()->getStateSetCache(); }
/**
* A shared cache for osg::Program objects created by the shader
* composition subsystem (VirtualProgram).
*/
ProgramSharedRepo* getProgramSharedRepo();
static ProgramSharedRepo* programSharedRepo() { return instance()->getProgramSharedRepo(); }
/**
* Gets a reference to the global task service manager.
*/
TaskServiceManager* getTaskServiceManager() {
return _taskServiceManager.get(); }
/**
* Generates an instance-wide global unique ID.
*/
UID createUID();
/**
* Sets a global read callback for URI objects.
*/
void setURIReadCallback( URIReadCallback* callback );
/**
* Gets the global read callback for URI objects.
*/
URIReadCallback* getURIReadCallback() const;
/**
* Gets the default set of osgDB::Options to use.
*/
const osgDB::Options* getDefaultOptions() const;
/**
* Clones an options structure (fixing the archive caching), or creates
* a new one.
*/
static osgDB::Options* cloneOrCreateOptions( const osgDB::Options* options =0L );
/**
* Registers a Units definition.
*/
void registerUnits( const Units* staticInstance );
const Units* getUnits(const std::string& name) const;
/**
* The name of the default terrain engine driver
*/
//void setDefaultTerrainEngineDriverName( const std::string& name );
const std::string& getDefaultTerrainEngineDriverName() const { return _terrainEngineDriver; }
/**
* If set, all MapNodes will use the terrain driver specified here regardless
* of the driver in the TerrainOptions/earth file.
*/
optional<std::string>& overrideTerrainEngineDriverName() { return _overrideTerrainEngineDriverName; }
const optional<std::string>& overrideTerrainEngineDriverName() const { return _overrideTerrainEngineDriverName; }
/**
* For debugging - tracks activities in progress.
*/
void startActivity(const std::string& name);
void startActivity(const std::string& name, const std::string& text);
void endActivity(const std::string& name);
void getActivities(std::set<std::string>& output);
/**
* Gets the mime-type corresponding to a given extension.
*/
std::string getMimeTypeForExtension(const std::string& extension);
/**
* Gets the file extension corresponding to a given mime-type.
*/
std::string getExtensionForMimeType(const std::string& mimeType);
/**
* Sets the policy for calling osg::Texture::setUnRefImageDataAfterApply
* in the osgEarth terrain engine.
*/
optional<bool>& unRefImageDataAfterApply() { return _unRefImageDataAfterApply; }
const optional<bool>& unRefImageDataAfterApply() const { return _unRefImageDataAfterApply; }
/**
* Adds a texture image unit number that osgEarth should never use.
*/
void setTextureImageUnitOffLimits(int unit);
const std::set<int> getOffLimitsTextureImageUnits() const;
/** General purpose transient data store to support VisitorData in pre-osg 3.4 */
TransientUserDataStore& dataStore() { return _dataStore; }
const TransientUserDataStore& dataStore() const { return _dataStore; }
//! Access to the general-purpose async operations queue
osg::OperationQueue* getAsyncOperationQueue() const { return _opQueue.get(); }
/**
* Gets the device pixel ratio.
*/
float getDevicePixelRatio() const;
/**
* Sets the device pixel ratio. This value will be used to scale the size of objects specified in pixels.
* This value is useful when running in high dpi environments on high resolution displays.
*/
void setDevicePixelRatio(float devicePixelRatio);
protected:
virtual ~Registry();
Registry();
void destruct();
bool _gdal_registered;
osg::ref_ptr<const Profile> _global_geodetic_profile;
osg::ref_ptr<const Profile> _global_mercator_profile;
osg::ref_ptr<const Profile> _spherical_mercator_profile;
osg::ref_ptr<const Profile> _cube_profile;
mutable Threading::Mutex _regMutex;
int _numGdalMutexGets;
mutable osg::ref_ptr<Cache> _defaultCache;
mutable optional<CachePolicy> _defaultCachePolicy;
mutable optional<CachePolicy> _overrideCachePolicy;
mutable bool _overrideCachePolicyInitialized;
typedef std::set<std::string> StringSet;
StringSet _blacklistedFilenames;
Threading::ReadWriteMutex _blacklistMutex;
osg::ref_ptr<ShaderFactory> _shaderLib;
osg::ref_ptr<ShaderGenerator> _shaderGen;
osg::ref_ptr<TaskServiceManager> _taskServiceManager;
// unique ID generator:
int _uidGen;
mutable Threading::Mutex _uidGenMutex;
// system capabilities:
osg::ref_ptr< Capabilities > _caps;
mutable Threading::Mutex _capsMutex;
void initCapabilities();
osg::ref_ptr<osgDB::Options> _defaultOptions;
osg::ref_ptr<URIReadCallback> _uriReadCallback;
osg::ref_ptr<osgText::Font> _defaultFont;
typedef std::vector<const Units*> UnitsVector;
UnitsVector _unitsVector;
mutable Threading::ReadWriteMutex _unitsVectorMutex;
osg::ref_ptr<StateSetCache> _stateSetCache;
std::string _terrainEngineDriver;
optional<std::string> _overrideTerrainEngineDriverName;
mutable optional<std::string> _cacheDriver;
typedef std::pair<std::string,std::string> Activity;
struct ActivityLess {
bool operator()(const Activity& lhs, const Activity& rhs) const {
return lhs.first < rhs.first;
}
};
std::set<Activity,ActivityLess> _activities;
mutable Threading::Mutex _activityMutex;
ProgramSharedRepo _programRepo;
optional<bool> _unRefImageDataAfterApply;
osg::ref_ptr<ObjectIndex> _objectIndex;
std::set<int> _offLimitsTextureImageUnits;
TransientUserDataStore _dataStore;
osg::ref_ptr<osg::OperationQueue> _opQueue;
typedef std::vector< osg::ref_ptr<osg::OperationThread> > ThreadPool;
ThreadPool _opThreadPool;
unsigned _threadPoolSize;
float _devicePixelRatio;
typedef std::map<SpatialReference::Key, osg::ref_ptr<SpatialReference> > SRSCache;
mutable SRSCache _srsCache;
mutable Threading::Mutex _srsMutex;
};
}
/** Proxy class for automatic registration of Units with the Registry.*/
struct osgEarthRegisterUnits {
osgEarthRegisterUnits(const osgEarth::Units* units) {
osgEarth::Registry::instance()->registerUnits(units);
}
};
#define OSGEARTH_REGISTER_UNITS(NAME,INSTANCE) \
extern "C" void osgearth_units_##NAME(void) {} \
static osgEarthRegisterUnits s_osgEarthRegistryUnitsProxy##NAME (INSTANCE)
#define USE_OSGEARTH_UNITS(NAME ) \
extern "C" void osgearth_units_##NAME(void); \
static osgDB::PluginFunctionProxy proxy_osgearth_units_##NAME(osgearth_units_##NAME);
#endif //OSGEARTH_REGISTRY
|