OpenSceneGraph/include/osgSim/ShapeAttribute

129 lines
3.9 KiB
Plaintext
Raw Normal View History

2007-12-13 00:56:28 +08:00
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2007 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library 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
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGSIM_SHAPEATTRIBUTE
#define OSGSIM_SHAPEATTRIBUTE 1
#include <osg/Object>
Fixed warnings. OpenSceneGraph/src/osgGA/NodeTrackerManipulator.cpp:32:1: warning: base class ?class osg::Object? should be explicitly initialized in the copy constructor OpenSceneGraph/src/osgGA/TerrainManipulator.cpp:31:1: warning: base class ?class osg::Object? should be explicitly initialized in the copy constructor OpenSceneGraph/include/osgSim/ShapeAttribute:99:9: warning: base class ?class std::vector<osgSim::ShapeAttribute>? should be explicitly initialized in the copy constructor OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::gi? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::byte_before_the_zipfile? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::num_file? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::pos_in_central_dir? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::current_file_ok? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::central_pos? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::size_central_dir? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::offset_central_dir? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::cur_file_info? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::cur_file_info_internal? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::pfile_in_zip_read? OpenSceneGraph/src/osgViewer/CompositeViewer.cpp:30:1: warning: base class ?class osg::Object? should be explicitly initialized in the copy constructor OpenSceneGraph/src/osgViewer/View.cpp:159:1: warning: base class ?class osg::Object? should be explicitly initialized in the copy constructor OpenSceneGraph/src/osgViewer/Viewer.cpp:196:1: warning: base class ?class osg::Object? should be explicitly initialized in the copy constructor OpenSceneGraph/src/osgViewer/Viewer.cpp:196:1: warning: base class ?class osgViewer::ViewerBase? should be explicitly initialized in the copy constructor OpenSceneGraph/include/osgManipulator/Dragger:47:9: warning: base class ?class osg::Object? should be explicitly initialized in the copy constructor
2011-06-23 19:09:49 +08:00
#include <osg/MixinVector>
2007-12-10 19:20:22 +08:00
#include <osgSim/Export>
namespace osgSim
{
2007-12-10 19:20:22 +08:00
class OSGSIM_EXPORT ShapeAttribute
{
public:
/// ShapeAttribute data type.
enum Type
{
UNKNOWN,
INTEGER,
DOUBLE,
STRING
};
ShapeAttribute();
ShapeAttribute(const char * name);
ShapeAttribute(const char * name, int value);
ShapeAttribute(const char * name, double value);
/** Note, ShapeAttribute takes a copy of both name and value, the calling code should manage its own clean up of the original strings.*/
ShapeAttribute(const char * name, const char * value);
ShapeAttribute(const ShapeAttribute & sa);
~ShapeAttribute();
ShapeAttribute& operator = (const ShapeAttribute& sa);
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
int compare(const osgSim::ShapeAttribute& sa) const;
inline bool operator == (const osgSim::ShapeAttribute& sa) const { return compare(sa)==0; }
inline bool operator != (const osgSim::ShapeAttribute& sa) const { return compare(sa)!=0; }
inline bool operator < (const osgSim::ShapeAttribute& sa) const { return compare(sa)<0; }
/// Get the attribute name.
const std::string & getName() const { return _name; }
/// Set the attribute name.
void setName(const std::string& name) { _name = name; }
/// Get the attribute data type.
const Type getType() const { return _type; }
/// Get the attribute data as an int.
int getInt() const { return _integer; }
/// Get the attribute data as a double.
double getDouble() const { return _double; }
/// Get the attribute data as a string.
const char * getString() const { return _string; }
/// Set an integer attribute data.
void setValue(int value) { free(); _type = INTEGER; _integer = value; }
/// Set a double attribute data.
void setValue(double value) { free(); _type = DOUBLE; _double = value; }
/// Set a string attribute data.
void setValue(const char * value);
private:
void free();
void copy(const ShapeAttribute& sa);
std::string _name;
Type _type;
union
{
int _integer;
double _double;
char* _string;
};
};
Fixed warnings. OpenSceneGraph/src/osgGA/NodeTrackerManipulator.cpp:32:1: warning: base class ?class osg::Object? should be explicitly initialized in the copy constructor OpenSceneGraph/src/osgGA/TerrainManipulator.cpp:31:1: warning: base class ?class osg::Object? should be explicitly initialized in the copy constructor OpenSceneGraph/include/osgSim/ShapeAttribute:99:9: warning: base class ?class std::vector<osgSim::ShapeAttribute>? should be explicitly initialized in the copy constructor OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::gi? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::byte_before_the_zipfile? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::num_file? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::pos_in_central_dir? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::current_file_ok? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::central_pos? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::size_central_dir? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::offset_central_dir? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::cur_file_info? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::cur_file_info_internal? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::pfile_in_zip_read? OpenSceneGraph/src/osgViewer/CompositeViewer.cpp:30:1: warning: base class ?class osg::Object? should be explicitly initialized in the copy constructor OpenSceneGraph/src/osgViewer/View.cpp:159:1: warning: base class ?class osg::Object? should be explicitly initialized in the copy constructor OpenSceneGraph/src/osgViewer/Viewer.cpp:196:1: warning: base class ?class osg::Object? should be explicitly initialized in the copy constructor OpenSceneGraph/src/osgViewer/Viewer.cpp:196:1: warning: base class ?class osgViewer::ViewerBase? should be explicitly initialized in the copy constructor OpenSceneGraph/include/osgManipulator/Dragger:47:9: warning: base class ?class osg::Object? should be explicitly initialized in the copy constructor
2011-06-23 19:09:49 +08:00
class OSGSIM_EXPORT ShapeAttributeList : public osg::Object, public osg::MixinVector<ShapeAttribute>
{
public:
META_Object(osgSim, ShapeAttributeList)
ShapeAttributeList():
Object()
{}
/** Copy constructor, optional CopyOp object can be used to control
* shallow vs deep copying of dynamic data.*/
ShapeAttributeList(const ShapeAttributeList& sal,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY):
Fixed warnings. OpenSceneGraph/src/osgGA/NodeTrackerManipulator.cpp:32:1: warning: base class ?class osg::Object? should be explicitly initialized in the copy constructor OpenSceneGraph/src/osgGA/TerrainManipulator.cpp:31:1: warning: base class ?class osg::Object? should be explicitly initialized in the copy constructor OpenSceneGraph/include/osgSim/ShapeAttribute:99:9: warning: base class ?class std::vector<osgSim::ShapeAttribute>? should be explicitly initialized in the copy constructor OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::gi? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::byte_before_the_zipfile? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::num_file? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::pos_in_central_dir? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::current_file_ok? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::central_pos? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::size_central_dir? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::offset_central_dir? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::cur_file_info? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::cur_file_info_internal? OpenSceneGraph/src/osgPlugins/zip/unzip.cpp:3102:14: warning: missing initializer for member ?unz_s::pfile_in_zip_read? OpenSceneGraph/src/osgViewer/CompositeViewer.cpp:30:1: warning: base class ?class osg::Object? should be explicitly initialized in the copy constructor OpenSceneGraph/src/osgViewer/View.cpp:159:1: warning: base class ?class osg::Object? should be explicitly initialized in the copy constructor OpenSceneGraph/src/osgViewer/Viewer.cpp:196:1: warning: base class ?class osg::Object? should be explicitly initialized in the copy constructor OpenSceneGraph/src/osgViewer/Viewer.cpp:196:1: warning: base class ?class osgViewer::ViewerBase? should be explicitly initialized in the copy constructor OpenSceneGraph/include/osgManipulator/Dragger:47:9: warning: base class ?class osg::Object? should be explicitly initialized in the copy constructor
2011-06-23 19:09:49 +08:00
osg::Object(sal, copyop),
osg::MixinVector<ShapeAttribute>(sal)
{
}
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
virtual int compare(const osgSim::ShapeAttributeList& sal) const;
protected:
virtual ~ShapeAttributeList() {}
};
}
#endif // ** SHAPEATTRIBUTE_ ** //