root/OpenSceneGraph/trunk/src/osgWrappers/deprecated-dotosg/osg/StateAttribute.cpp @ 13041

Revision 13041, 2.4 kB (checked in by robert, 2 years ago)

Ran script to remove trailing spaces and tabs

  • Property svn:eol-style set to native
Line 
1#include "osg/StateAttribute"
2
3#include "osgDB/Registry"
4#include "osgDB/Input"
5#include "osgDB/Output"
6
7using namespace osg;
8using namespace osgDB;
9using namespace std;
10
11// forward declare functions to use later.
12bool StateAttribute_readLocalData(Object& obj, Input& fr);
13bool StateAttribute_writeLocalData(const Object& obj, Output& fw);
14
15// register the read and write functions with the osgDB::Registry.
16osg::StateAttribute* g_stateAttribute = 0;
17REGISTER_DOTOSGWRAPPER(StateAttribute)
18(
19    g_stateAttribute, // no instance, osg::StateAttribute is an abstract class.
20    "StateAttribute",
21    "Object StateAttribute",
22    &StateAttribute_readLocalData,
23    &StateAttribute_writeLocalData
24);
25
26
27bool StateAttribute_readLocalData(Object& obj, Input& fr)
28{
29    bool iteratorAdvanced = false;
30    StateAttribute& stateAttribute = static_cast<StateAttribute&>(obj);
31
32    static ref_ptr<StateAttributeCallback> s_callback = new osg::StateAttributeCallback;
33    while (fr.matchSequence("UpdateCallback {"))
34    {
35        //int entry = fr[0].getNoNestedBrackets();
36        fr += 2;
37        StateAttributeCallback* callback = dynamic_cast<StateAttributeCallback*>(fr.readObjectOfType(*s_callback));
38        if (callback) {
39            stateAttribute.setUpdateCallback(callback);
40        }
41        iteratorAdvanced = true;
42    }
43
44    while (fr.matchSequence("EventCallback {"))
45    {
46        //int entry = fr[0].getNoNestedBrackets();
47        fr += 2;
48        StateAttributeCallback* callback = dynamic_cast<StateAttributeCallback*>(fr.readObjectOfType(*s_callback));
49        if (callback) {
50            stateAttribute.setEventCallback(callback);
51        }
52        iteratorAdvanced = true;
53    }
54
55    return iteratorAdvanced;
56}
57
58bool StateAttribute_writeLocalData(const Object& obj,Output& fw)
59{
60    const StateAttribute& stateAttribute = static_cast<const StateAttribute&>(obj);
61
62    if (stateAttribute.getUpdateCallback())
63    {
64        fw.indent() << "UpdateCallback {" << std::endl;
65        fw.moveIn();
66        fw.writeObject(*stateAttribute.getUpdateCallback());
67        fw.moveOut();
68        fw.indent() << "}" << std::endl;
69    }
70
71    if (stateAttribute.getEventCallback())
72    {
73        fw.indent() << "EventCallback {" << std::endl;
74        fw.moveIn();
75        fw.writeObject(*stateAttribute.getEventCallback());
76        fw.moveOut();
77        fw.indent() << "}" << std::endl;
78    }
79
80    return true;
81}
Note: See TracBrowser for help on using the browser.