MCPcopy Create free account
hub / github.com/AcademySoftwareFoundation/MaterialX / validate

Method validate

source/MaterialXCore/Interface.cpp:148–208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

146}
147
148bool PortElement::validate(string* message) const
149{
150 bool res = true;
151
152 NodePtr connectedNode = getConnectedNode();
153 if (hasNodeName() || hasOutputString())
154 {
155 NodeGraphPtr nodeGraph = resolveNameReference<NodeGraph>(getNodeName());
156 if (!nodeGraph)
157 {
158 validateRequire(connectedNode != nullptr, res, message, "Invalid port connection");
159 }
160 }
161 if (connectedNode)
162 {
163 const string& outputString = getOutputString();
164 if (!outputString.empty())
165 {
166 OutputPtr output;
167 if (hasNodeName())
168 {
169 NodeDefPtr nodeDef = connectedNode->getNodeDef();
170 output = nodeDef ? nodeDef->getOutput(outputString) : OutputPtr();
171 if (output)
172 {
173 validateRequire(connectedNode->getType() == MULTI_OUTPUT_TYPE_STRING, res, message,
174 "Multi-output type expected in port connection");
175 }
176 }
177 else if (hasNodeGraphString())
178 {
179 NodeGraphPtr nodeGraph = resolveNameReference<NodeGraph>(getNodeGraphString());
180 if (nodeGraph)
181 {
182 output = nodeGraph->getOutput(outputString);
183 if (nodeGraph->getNodeDef())
184 {
185 validateRequire(nodeGraph->getOutputCount() > 1, res, message,
186 "Multi-output type expected in port connection");
187 }
188 }
189 }
190 else
191 {
192 // Document has no concept of a multioutput type
193 output = getDocument()->getOutput(outputString);
194 }
195 validateRequire(output != nullptr, res, message, "No output found for port connection");
196
197 if (output)
198 {
199 validateRequire(getType() == output->getType(), res, message, "Mismatched types in port connection");
200 }
201 }
202 else if (connectedNode->getType() != MULTI_OUTPUT_TYPE_STRING)
203 {
204 validateRequire(getType() == connectedNode->getType(), res, message, "Mismatched types in port connection");
205 }

Callers

nothing calls this directly

Calls 13

hasNodeNameFunction · 0.85
hasOutputStringFunction · 0.85
hasNodeGraphStringFunction · 0.85
getDocumentFunction · 0.85
hasDefaultGeomPropStringFunction · 0.85
hasInterfaceNameFunction · 0.85
getParentFunction · 0.70
hasValueFunction · 0.70
getTypeFunction · 0.50
emptyMethod · 0.45
getNodeDefMethod · 0.45
getOutputMethod · 0.45

Tested by

no test coverage detected