From 1a683e2f83c9fad16075fe5496b263d12f62e018 Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Tue, 14 May 2013 16:12:21 +0000 Subject: [PATCH] From Ulrich Hertlein, "Attached is a patch that introduces 'static_cast' on some instances where the code returns '.size()' of a std::vector. This caused some warnings when using clang++ on OS X." --- include/osg/BufferObject | 6 +++--- include/osg/Geode | 4 ++-- include/osg/LOD | 2 +- include/osg/PagedLOD | 14 +++++++------- include/osg/Program | 2 +- include/osg/Shader | 4 ++-- include/osg/StateSet | 4 ++-- include/osg/Texture | 4 ++-- include/osg/Uniform | 2 +- include/osgDB/DatabasePager | 8 ++++---- include/osgDB/ImagePager | 2 +- include/osgDB/Options | 4 ++-- include/osgDB/Serializer | 2 +- include/osgGA/GUIEventAdapter | 2 +- include/osgTerrain/Layer | 2 +- include/osgTerrain/TerrainTile | 2 +- 16 files changed, 32 insertions(+), 32 deletions(-) diff --git a/include/osg/BufferObject b/include/osg/BufferObject index 86b5a8897..9cc17eaac 100644 --- a/include/osg/BufferObject +++ b/include/osg/BufferObject @@ -406,8 +406,8 @@ class OSG_EXPORT GLBufferObjectSet : public Referenced unsigned int computeNumGLBufferObjectsInList() const; unsigned int getNumOfGLBufferObjects() const { return _numOfGLBufferObjects; } - unsigned int getNumOrphans() const { return _orphanedGLBufferObjects.size(); } - unsigned int getNumPendingOrphans() const { return _pendingOrphanedGLBufferObjects.size(); } + unsigned int getNumOrphans() const { return static_cast(_orphanedGLBufferObjects.size()); } + unsigned int getNumPendingOrphans() const { return static_cast(_pendingOrphanedGLBufferObjects.size()); } protected: @@ -565,7 +565,7 @@ class OSG_EXPORT BufferObject : public Object BufferData* getBufferData(unsigned int index) { return _bufferDataList[index]; } const BufferData* getBufferData(unsigned int index) const { return _bufferDataList[index]; } - unsigned int getNumBufferData() const { return _bufferDataList.size(); } + unsigned int getNumBufferData() const { return static_cast(_bufferDataList.size()); } void setGLBufferObject(unsigned int contextID, GLBufferObject* glbo) { _glBufferObjects[contextID] = glbo; } diff --git a/include/osg/Geode b/include/osg/Geode index b6a97fcde..66bb1543e 100644 --- a/include/osg/Geode +++ b/include/osg/Geode @@ -90,7 +90,7 @@ class OSG_EXPORT Geode : public Node /** Return the number of Drawables currently attached to the * \c Geode. */ - inline unsigned int getNumDrawables() const { return _drawables.size(); } + inline unsigned int getNumDrawables() const { return static_cast(_drawables.size()); } /** Return the \c Drawable at position \c i.*/ inline Drawable* getDrawable( unsigned int i ) { return _drawables[i].get(); } @@ -121,7 +121,7 @@ class OSG_EXPORT Geode : public Node { if (_drawables[drawableNum]==drawable) return drawableNum; } - return _drawables.size(); // drawable not found. + return static_cast(_drawables.size()); // drawable not found. } /** Get the list of drawables.*/ diff --git a/include/osg/LOD b/include/osg/LOD index 9345daabc..0d636ec6c 100644 --- a/include/osg/LOD +++ b/include/osg/LOD @@ -112,7 +112,7 @@ class OSG_EXPORT LOD : public Group /** returns the number of ranges currently set. * An LOD which has been fully set up will have getNumChildren()==getNumRanges(). */ - inline unsigned int getNumRanges() const { return _rangeList.size(); } + inline unsigned int getNumRanges() const { return static_cast(_rangeList.size()); } /** set the list of MinMax ranges for each child.*/ inline void setRangeList(const RangeList& rangeList) { _rangeList=rangeList; } diff --git a/include/osg/PagedLOD b/include/osg/PagedLOD index b88c76c6f..b2798240d 100644 --- a/include/osg/PagedLOD +++ b/include/osg/PagedLOD @@ -82,35 +82,35 @@ class OSG_EXPORT PagedLOD : public LOD void setFileName(unsigned int childNo, const std::string& filename) { expandPerRangeDataTo(childNo); _perRangeDataList[childNo]._filename=filename; } const std::string& getFileName(unsigned int childNo) const { return _perRangeDataList[childNo]._filename; } - unsigned int getNumFileNames() const { return _perRangeDataList.size(); } + unsigned int getNumFileNames() const { return static_cast(_perRangeDataList.size()); } void setPriorityOffset(unsigned int childNo, float priorityOffset) { expandPerRangeDataTo(childNo); _perRangeDataList[childNo]._priorityOffset=priorityOffset; } float getPriorityOffset(unsigned int childNo) const { return _perRangeDataList[childNo]._priorityOffset; } - unsigned int getNumPriorityOffsets() const { return _perRangeDataList.size(); } + unsigned int getNumPriorityOffsets() const { return static_cast(_perRangeDataList.size()); } void setPriorityScale(unsigned int childNo, float priorityScale) { expandPerRangeDataTo(childNo); _perRangeDataList[childNo]._priorityScale=priorityScale; } float getPriorityScale(unsigned int childNo) const { return _perRangeDataList[childNo]._priorityScale; } - unsigned int getNumPriorityScales() const { return _perRangeDataList.size(); } + unsigned int getNumPriorityScales() const { return static_cast(_perRangeDataList.size()); } /** Sets the minimum amount of time, in seconds, that must pass without a child being traversed before it can be expired. */ void setMinimumExpiryTime(unsigned int childNo, double minTime) { expandPerRangeDataTo(childNo); _perRangeDataList[childNo]._minExpiryTime=minTime; } double getMinimumExpiryTime(unsigned int childNo) const { return _perRangeDataList[childNo]._minExpiryTime; } - unsigned int getNumMinimumExpiryTimes() const { return _perRangeDataList.size(); } + unsigned int getNumMinimumExpiryTimes() const { return static_cast(_perRangeDataList.size()); } /** Sets the minimum number of frames that must be rendered without a child being traversed before it can be expired. */ void setMinimumExpiryFrames(unsigned int childNo, unsigned int minFrames) { expandPerRangeDataTo(childNo); _perRangeDataList[childNo]._minExpiryFrames=minFrames; } unsigned int getMinimumExpiryFrames(unsigned int childNo) const { return _perRangeDataList[childNo]._minExpiryFrames; } - unsigned int getNumMinimumExpiryFrames() const { return _perRangeDataList.size(); } + unsigned int getNumMinimumExpiryFrames() const { return static_cast(_perRangeDataList.size()); } void setTimeStamp(unsigned int childNo, double timeStamp) { expandPerRangeDataTo(childNo); _perRangeDataList[childNo]._timeStamp=timeStamp; } double getTimeStamp(unsigned int childNo) const { return _perRangeDataList[childNo]._timeStamp; } - unsigned int getNumTimeStamps() const { return _perRangeDataList.size(); } + unsigned int getNumTimeStamps() const { return static_cast(_perRangeDataList.size()); } void setFrameNumber(unsigned int childNo, unsigned int frameNumber) { expandPerRangeDataTo(childNo); _perRangeDataList[childNo]._frameNumber=frameNumber; } unsigned getFrameNumber(unsigned int childNo) const { return _perRangeDataList[childNo]._frameNumber; } - unsigned int getNumFrameNumbers() const { return _perRangeDataList.size(); } + unsigned int getNumFrameNumbers() const { return static_cast(_perRangeDataList.size()); } /** Return the DatabaseRequest object used by the DatabasePager to keep track of file load requests diff --git a/include/osg/Program b/include/osg/Program index ad68b2ae5..d31fbc8b1 100644 --- a/include/osg/Program +++ b/include/osg/Program @@ -158,7 +158,7 @@ class OSG_EXPORT Program : public osg::StateAttribute GLenum getFormat() const {return _format;} /** Get the size of the program binary data.*/ - unsigned int getSize() const { return _data.size(); } + unsigned int getSize() const { return static_cast(_data.size()); } /** Get a ptr to the program binary data.*/ unsigned char* getData() { return _data.empty() ? 0 : &(_data.front()); } diff --git a/include/osg/Shader b/include/osg/Shader index 2aa461643..295d4c0a0 100644 --- a/include/osg/Shader +++ b/include/osg/Shader @@ -53,7 +53,7 @@ class OSG_EXPORT ShaderBinary : public osg::Object void assign(unsigned int size, const unsigned char* data); /** Get the size of the shader binary data.*/ - unsigned int getSize() const { return _data.size(); } + unsigned int getSize() const { return static_cast(_data.size()); } /** Get a ptr to the shader binary data.*/ unsigned char* getData() { return _data.empty() ? 0 : &(_data.front()); } @@ -294,7 +294,7 @@ class OSG_EXPORT ShaderComponent : public osg::Object osg::Shader* getShader(unsigned int i) { return _shaders[i].get(); } const osg::Shader* getShader(unsigned int i) const { return _shaders[i].get(); } - unsigned int getNumShaders() const { return _shaders.size(); } + unsigned int getNumShaders() const { return static_cast(_shaders.size()); } virtual void compileGLObjects(State& state) const; virtual void resizeGLObjectBuffers(unsigned int maxSize); diff --git a/include/osg/StateSet b/include/osg/StateSet index 98e791896..e14398f80 100644 --- a/include/osg/StateSet +++ b/include/osg/StateSet @@ -220,7 +220,7 @@ class OSG_EXPORT StateSet : public Object inline const TextureModeList& getTextureModeList() const { return _textureModeList; } /** Return the number texture units active in the TextureModeList.*/ - inline unsigned int getNumTextureModeLists() const { return _textureModeList.size(); } + inline unsigned int getNumTextureModeLists() const { return static_cast(_textureModeList.size()); } typedef std::vector TextureAttributeList; @@ -257,7 +257,7 @@ class OSG_EXPORT StateSet : public Object inline const TextureAttributeList& getTextureAttributeList() const { return _textureAttributeList; } /** Return the number of texture units active in the TextureAttributeList.*/ - inline unsigned int getNumTextureAttributeLists() const { return _textureAttributeList.size(); } + inline unsigned int getNumTextureAttributeLists() const { return static_cast(_textureAttributeList.size()); } void setAssociatedModes(const StateAttribute* attribute, StateAttribute::GLModeValue value); diff --git a/include/osg/Texture b/include/osg/Texture index b91bdb9ab..9961dcf5a 100644 --- a/include/osg/Texture +++ b/include/osg/Texture @@ -1276,8 +1276,8 @@ class OSG_EXPORT Texture : public osg::StateAttribute unsigned int computeNumTextureObjectsInList() const; unsigned int getNumOfTextureObjects() const { return _numOfTextureObjects; } - unsigned int getNumOrphans() const { return _orphanedTextureObjects.size(); } - unsigned int getNumPendingOrphans() const { return _pendingOrphanedTextureObjects.size(); } + unsigned int getNumOrphans() const { return static_cast(_orphanedTextureObjects.size()); } + unsigned int getNumPendingOrphans() const { return static_cast(_pendingOrphanedTextureObjects.size()); } protected: diff --git a/include/osg/Uniform b/include/osg/Uniform index d4e48bbba..f7dbab4c1 100644 --- a/include/osg/Uniform +++ b/include/osg/Uniform @@ -661,7 +661,7 @@ class OSG_EXPORT Uniform : public Object * Get the number of parents of this Uniform. * @return the number of parents of this Uniform. */ - inline unsigned int getNumParents() const { return _parents.size(); } + inline unsigned int getNumParents() const { return static_cast(_parents.size()); } /** convenient scalar (non-array) value assignment */ diff --git a/include/osgDB/DatabasePager b/include/osgDB/DatabasePager index d1daa54b2..5c8444843 100644 --- a/include/osgDB/DatabasePager +++ b/include/osgDB/DatabasePager @@ -134,7 +134,7 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl const DatabaseThread* getDatabaseThread(unsigned int i) const { return _databaseThreads[i].get(); } - unsigned int getNumDatabaseThreads() const { return _databaseThreads.size(); } + unsigned int getNumDatabaseThreads() const { return static_cast(_databaseThreads.size()); } /** Set whether the database pager thread should be paused or not.*/ void setDatabasePagerThreadPause(bool pause); @@ -245,13 +245,13 @@ class OSGDB_EXPORT DatabasePager : public osg::NodeVisitor::DatabaseRequestHandl virtual void updateSceneGraph(const osg::FrameStamp& frameStamp); /** Report how many items are in the _fileRequestList queue */ - unsigned int getFileRequestListSize() const { return _fileRequestQueue->size() + _httpRequestQueue->size(); } + unsigned int getFileRequestListSize() const { return static_cast(_fileRequestQueue->size() + _httpRequestQueue->size()); } /** Report how many items are in the _dataToCompileList queue */ - unsigned int getDataToCompileListSize() const { return _dataToCompileList->size(); } + unsigned int getDataToCompileListSize() const { return static_cast(_dataToCompileList->size()); } /** Report how many items are in the _dataToMergeList queue */ - unsigned int getDataToMergeListSize() const { return _dataToMergeList->size(); } + unsigned int getDataToMergeListSize() const { return static_cast(_dataToMergeList->size()); } /** Report whether any requests are in the pager.*/ bool getRequestsInProgress() const; diff --git a/include/osgDB/ImagePager b/include/osgDB/ImagePager index 04844f354..662f44847 100644 --- a/include/osgDB/ImagePager +++ b/include/osgDB/ImagePager @@ -72,7 +72,7 @@ class OSGDB_EXPORT ImagePager : public osg::NodeVisitor::ImageRequestHandler const ImageThread* getImageThread(unsigned int i) const { return _imageThreads[i].get(); } - unsigned int getNumImageThreads() const { return _imageThreads.size(); } + unsigned int getNumImageThreads() const { return static_cast(_imageThreads.size()); } void setPreLoadTime(double preLoadTime) { _preLoadTime=preLoadTime; } diff --git a/include/osgDB/Options b/include/osgDB/Options index b6704350e..5ed4acefd 100644 --- a/include/osgDB/Options +++ b/include/osgDB/Options @@ -175,7 +175,7 @@ class OSGDB_EXPORT Options : public osg::Object void removePluginData(const std::string& s) const { _pluginData.erase(s); } /** Get number of PluginData values */ - unsigned int getNumPluginData() const { return _pluginData.size(); } + unsigned int getNumPluginData() const { return static_cast(_pluginData.size()); } /** Sets a plugindata value PluginData with a string */ @@ -195,7 +195,7 @@ class OSGDB_EXPORT Options : public osg::Object void removePluginStringData(const std::string& s) const { _pluginStringData.erase(s); } /** Get number of PluginStrData values */ - unsigned int getNumPluginStringData() const { return _pluginStringData.size(); } + unsigned int getNumPluginStringData() const { return static_cast(_pluginStringData.size()); } /** Parse string into plugin string data. This will be automatically done in Options(const std::string&) */ void parsePluginStringData(const std::string& str, char separator1=' ', char separator2='='); diff --git a/include/osgDB/Serializer b/include/osgDB/Serializer index 28349d55a..7f75a1d9c 100644 --- a/include/osgDB/Serializer +++ b/include/osgDB/Serializer @@ -40,7 +40,7 @@ public: typedef std::map ValueToString; IntLookup() {} - unsigned int size() const { return _stringToValue.size(); } + unsigned int size() const { return static_cast(_stringToValue.size()); } void add( const char* str, Value value ) { diff --git a/include/osgGA/GUIEventAdapter b/include/osgGA/GUIEventAdapter index 131ed3eb9..0084a6b79 100644 --- a/include/osgGA/GUIEventAdapter +++ b/include/osgGA/GUIEventAdapter @@ -416,7 +416,7 @@ public: META_Object(osgGA, TouchData); - unsigned int getNumTouchPoints() const { return _touches.size(); } + unsigned int getNumTouchPoints() const { return static_cast(_touches.size()); } iterator begin() { return _touches.begin(); } const_iterator begin() const { return _touches.begin(); } diff --git a/include/osgTerrain/Layer b/include/osgTerrain/Layer index 5307017cf..9835a69f0 100644 --- a/include/osgTerrain/Layer +++ b/include/osgTerrain/Layer @@ -526,7 +526,7 @@ class OSGTERRAIN_EXPORT CompositeLayer : public Layer void removeLayer(unsigned int i) { _layers.erase(_layers.begin()+i); } - unsigned int getNumLayers() const { return _layers.size(); } + unsigned int getNumLayers() const { return static_cast(_layers.size()); } protected: diff --git a/include/osgTerrain/TerrainTile b/include/osgTerrain/TerrainTile index aedd56b16..f32fd4017 100644 --- a/include/osgTerrain/TerrainTile +++ b/include/osgTerrain/TerrainTile @@ -139,7 +139,7 @@ class OSGTERRAIN_EXPORT TerrainTile : public osg::Group const Layer* getColorLayer(unsigned int i) const { return i<_colorLayers.size() ? _colorLayers[i].get() : 0; } /** Get the number of colour layers.*/ - unsigned int getNumColorLayers() const { return _colorLayers.size(); } + unsigned int getNumColorLayers() const { return static_cast(_colorLayers.size()); } /** Set hint to whether the TerrainTechnique should create per vertex normals for lighting purposes.*/