4 * \date 2012-08-22 19:45GMT
5 * \author Jan Boon (Kaetemi)
10 * Copyright (C) 2012 by authors
12 * This file is part of RYZOM CORE PIPELINE.
13 * RYZOM CORE PIPELINE is free software: you can redistribute it
14 * and/or modify it under the terms of the GNU Affero General Public
15 * License as published by the Free Software Foundation, either
16 * version 3 of the License, or (at your option) any later version.
18 * RYZOM CORE PIPELINE is distributed in the hope that it will be
19 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty
20 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Affero General Public License for more details.
23 * You should have received a copy of the GNU Affero General Public
24 * License along with RYZOM CORE PIPELINE. If not, see
25 * <http://www.gnu.org/licenses/>.
28 #include <nel/misc/types_nl.h>
35 // #include <nel/misc/debug.h>
40 // using namespace NLMISC;
46 INode::INode(CScene
*scene
) : CReferenceTarget(scene
)
56 const ucstring
INode::DisplayName
= ucstring("Node Interface");
57 const char *INode::InternalName
= "Node";
58 const char *INode::InternalNameUnknown
= "NodeUnknown";
59 const NLMISC::CClassId
INode::ClassId
= NLMISC::CClassId(0x8f5b13, 0x624d477d); /* Not official, please correct */
60 const TSClassId
INode::SuperClassId
= 0x00000001;
61 const CNodeClassDesc
NodeClassDesc(&DllPluginDescBuiltin
);
62 const CNodeSuperClassDesc
NodeSuperClassDesc(&NodeClassDesc
);
64 void INode::parse(uint16 version
, uint filter
)
66 CReferenceTarget::parse(version
);
71 CReferenceTarget::clean();
74 void INode::build(uint16 version
, uint filter
)
76 CReferenceTarget::build(version
);
81 CReferenceTarget::disown();
86 CReferenceTarget::init();
89 bool INode::inherits(const NLMISC::CClassId classId
) const
91 if (classId
== classDesc()->classId()) return true;
92 return CReferenceTarget::inherits(classId
);
95 const ISceneClassDesc
*INode::classDesc() const
97 return &NodeClassDesc
;
100 void INode::toStringLocal(std::ostream
&ostream
, const std::string
&pad
, uint filter
) const
102 CReferenceTarget::toStringLocal(ostream
, pad
);
103 // Print the implied connected children
104 ostream
<< "\n" << pad
<< "Children: IMPLICIT { ";
106 for (std::set
<NLMISC::CRefPtr
<INode
> >::iterator it
= m_Children
.begin(), end
= m_Children
.end(); it
!= end
; ++it
)
112 ostream
<< "\n" << pad
<< "\t" << i
<< ": <ptr=0x";
114 std::stringstream ss
;
115 ss
<< std::hex
<< std::setfill('0');
116 ss
<< std::setw(16) << (uint64
)(void *)node
;
120 ostream
<< "(" << ucstring(node
->classDesc()->displayName()).toUtf8() << ", " << node
->classDesc()->classId().toString() << ") ";
121 ostream
<< node
->userName().toUtf8() << " ";
125 ostream
<< "\n" << pad
<< "\t" << i
<< ": NULL ";
132 INode
*INode::parent()
134 nlerror("Unkown node class, cannot get parent node");
138 void INode::setParent(INode
*node
)
140 nlerror("Unkown node class, cannot set parent node");
143 void INode::addChild(INode
*node
)
145 m_Children
.insert(node
);
148 void INode::removeChild(INode
*node
)
150 m_Children
.erase(node
);
153 const ucstring
&INode::userName() const
155 static const ucstring v
= ucstring("Invalid INode");
159 INode
*INode::find(const ucstring
&userName
) const
161 ucstring unl
= NLMISC::toLower(userName
);
162 for (std::set
<NLMISC::CRefPtr
<INode
> >::iterator it
= m_Children
.begin(), end
= m_Children
.end(); it
!= end
; ++it
)
166 if (NLMISC::toLower(node
->userName()) == unl
)
172 void INode::dumpNodes(std::ostream
&ostream
, const std::string
&pad
) const
174 ostream
<< "<ptr=0x";
176 std::stringstream ss
;
177 ss
<< std::hex
<< std::setfill('0');
178 ss
<< std::setw(16) << (uint64
)(void *)this;
181 ostream
<< "> " << userName().toUtf8() << " [" << m_Children
.size() << "] { ";
182 CReferenceMaker
*object
= getReference(1);
183 if (object
) // TODO: Implement!
185 ostream
<< "\n" << pad
<< "Object: ";
186 ostream
<< "<ptr=0x";
188 std::stringstream ss
;
189 ss
<< std::hex
<< std::setfill('0');
190 ss
<< std::setw(16) << (uint64
)(void *)object
;
194 ostream
<< ucstring(object
->classDesc()->displayName()).toUtf8() << " ";
197 std::string padpad
= pad
+ "\t";
198 for (std::set
<NLMISC::CRefPtr
<INode
> >::iterator it
= m_Children
.begin(), end
= m_Children
.end(); it
!= end
; ++it
)
202 ostream
<< "\n" << pad
<< i
<< ": ";
203 node
->dumpNodes(ostream
, padpad
);
209 IStorageObject
*INode::createChunkById(uint16 id
, bool container
)
211 return CReferenceTarget::createChunkById(id
, container
);
214 } /* namespace BUILTIN */
215 } /* namespace MAX */
216 } /* namespace PIPELINE */