Linux multi-monitor fullscreen support
[ryzomcore.git] / nel / tools / 3d / pipeline_max / builtin / i_node.cpp
blobb24825c263e4ed8dfbe6d1b9830be5f38361fb0a
1 /**
2 * \file i_node.cpp
3 * \brief INode
4 * \date 2012-08-22 19:45GMT
5 * \author Jan Boon (Kaetemi)
6 * INode
7 */
9 /*
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>
29 #include "i_node.h"
31 // STL includes
32 #include <iomanip>
34 // NeL includes
35 // #include <nel/misc/debug.h>
37 // Project includes
39 using namespace std;
40 // using namespace NLMISC;
42 namespace PIPELINE {
43 namespace MAX {
44 namespace BUILTIN {
46 INode::INode(CScene *scene) : CReferenceTarget(scene)
51 INode::~INode()
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);
69 void INode::clean()
71 CReferenceTarget::clean();
74 void INode::build(uint16 version, uint filter)
76 CReferenceTarget::build(version);
79 void INode::disown()
81 CReferenceTarget::disown();
84 void INode::init()
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 { ";
105 uint i = 0;
106 for (std::set<NLMISC::CRefPtr<INode> >::iterator it = m_Children.begin(), end = m_Children.end(); it != end; ++it)
108 INode *node = (*it);
109 nlassert(node);
110 if (node)
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;
117 ostream << ss.str();
119 ostream << "> ";
120 ostream << "(" << ucstring(node->classDesc()->displayName()).toUtf8() << ", " << node->classDesc()->classId().toString() << ") ";
121 ostream << node->userName().toUtf8() << " ";
123 else
125 ostream << "\n" << pad << "\t" << i << ": NULL ";
127 ++i;
129 ostream << "} ";
132 INode *INode::parent()
134 nlerror("Unkown node class, cannot get parent node");
135 return NULL;
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");
156 return v;
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)
164 INode *node = (*it);
165 nlassert(node);
166 if (NLMISC::toLower(node->userName()) == unl)
167 return node;
169 return NULL;
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;
179 ostream << ss.str();
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;
191 ostream << ss.str();
193 ostream << "> ";
194 ostream << ucstring(object->classDesc()->displayName()).toUtf8() << " ";
196 uint i = 0 ;
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)
200 INode *node = (*it);
201 nlassert(node);
202 ostream << "\n" << pad << i << ": ";
203 node->dumpNodes(ostream, padpad);
204 ++i;
206 ostream << "} ";
209 IStorageObject *INode::createChunkById(uint16 id, bool container)
211 return CReferenceTarget::createChunkById(id, container);
214 } /* namespace BUILTIN */
215 } /* namespace MAX */
216 } /* namespace PIPELINE */
218 /* end of file */