root/OpenSceneGraph/trunk/src/osg/CopyOp.cpp @ 6459

Revision 6459, 2.0 kB (checked in by robert, 6 years ago)

From Eric Wing, pedantic warning fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under 
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version.  The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 * OpenSceneGraph Public License for more details.
12*/
13#include <osg/CopyOp>
14#include <osg/Node>
15#include <osg/StateSet>
16#include <osg/Texture>
17#include <osg/Drawable>
18#include <osg/Array>
19#include <osg/PrimitiveSet>
20#include <osg/Shape>
21
22using namespace osg;
23
24#define COPY_OP( TYPE, FLAG ) \
25TYPE* CopyOp::operator() (const TYPE* obj) const \
26{ \
27    if (obj && _flags&FLAG) \
28        return dynamic_cast<TYPE*>( obj->clone(*this) ); \
29    else \
30        return const_cast<TYPE*>(obj); \
31}
32
33COPY_OP( Object,         DEEP_COPY_OBJECTS )
34COPY_OP( Node,           DEEP_COPY_NODES )
35COPY_OP( Drawable,       DEEP_COPY_DRAWABLES )
36COPY_OP( StateSet,       DEEP_COPY_STATESETS )
37COPY_OP( Texture,        DEEP_COPY_TEXTURES )
38COPY_OP( Image,          DEEP_COPY_IMAGES )
39COPY_OP( Array,          DEEP_COPY_ARRAYS )
40COPY_OP( PrimitiveSet,   DEEP_COPY_PRIMITIVES )
41COPY_OP( Shape,          DEEP_COPY_SHAPES )
42COPY_OP( Uniform,        DEEP_COPY_UNIFORMS )
43
44Referenced* CopyOp::operator() (const Referenced* ref) const
45{
46    return const_cast<Referenced*>(ref);
47}
48
49StateAttribute* CopyOp::operator() (const StateAttribute* attr) const
50{
51    if (attr && _flags&DEEP_COPY_STATEATTRIBUTES)
52    {
53        const Texture* textbase = dynamic_cast<const Texture*>(attr);
54        if (textbase)
55        {
56            return operator()(textbase);
57        }
58        else 
59        {
60            return dynamic_cast<StateAttribute*>(attr->clone(*this));
61        }
62    }
63    else
64        return const_cast<StateAttribute*>(attr);
65}
66
Note: See TracBrowser for help on using the browser.