wiki:HDI/editCP

beginEditCP() and endEditCP() are going away in 2.0 but you want to develop in 1.x now and migrate to 2.0 once it is stable. In this case you might consider the following:

#!cpp

using namespace OSG;



class FCEditGuard {



public:



#if OSG_MAJOR_VERSION < 2

  FCEditGuard(const FieldContainerPtr &a,

                    BitVector b = FieldBits::AllFields,

                    UInt32 c = ChangedOrigin::External)

    : obj(a), mask(b), origin(c)

  {

    beginEditCP(obj, mask, origin);

  }

#else

  FCEditGuard(const FieldContainerPtr &,

                    BitVector = FieldBits::AllFields,

                    UInt32 = ChangedOrigin::External)

  {}

#endif

    

  ~FCEditGuard()

  {

#if OSG_MAJOR_VERSION < 2

    endEditCP(obj, mask, origin);

#endif

  }

    

private:



#if OSG_MAJOR_VERSION < 2

  const FieldContainerPtr &obj;

        BitVector          mask;

        UInt32             origin;

#endif

    

};

Usage:

#!cpp

using namespace OSG;

:



NodePtr scene_root = Node::create();

  

{

  FCEditGuard f(scene_root);

    

  scene_root->setCore(Group::create());

} // f.~FCEditGuard() called here



:

For those worried about space, for OSG_MAJOR_VERSION >= 2 any decent compiler should be able to remove the then empty instances of type FCEditGuard from the translation unit.

Submitted by Jan Springer, 2006/11/02.

Last modified 7 years ago Last modified on 01/17/10 01:11:44