1/*
2 * Copyright 2011, Rene Gollent, rene@gollent.com.
3 * Distributed under the terms of the MIT License.
4 */
5
6
7#include "BMessageTypeHandler.h"
8
9#include <new>
10
11#include "BMessageValueNode.h"
12#include "Type.h"
13
14
15BMessageTypeHandler::~BMessageTypeHandler()
16{
17}
18
19
20float
21BMessageTypeHandler::SupportsType(Type* type)
22{
23	if (dynamic_cast<CompoundType*>(type) != NULL
24		&& type->Name() == "BMessage")
25		return 1.0f;
26
27	return 0.0f;
28}
29
30
31status_t
32BMessageTypeHandler::CreateValueNode(ValueNodeChild* nodeChild, Type* type,
33	ValueNode*& _node)
34{
35	if (SupportsType(type) == 0.0f)
36		return B_BAD_VALUE;
37
38	ValueNode* node = new(std::nothrow) BMessageValueNode(nodeChild,
39		type);
40
41	if (node == NULL)
42		return B_NO_MEMORY;
43
44	_node = node;
45
46	return B_OK;
47}
48