2011-06-22 02:59:54 +04:00
|
|
|
/*
|
2015-06-07 20:27:13 +03:00
|
|
|
* Copyright 2011-2015, Rene Gollent, rene@gollent.com.
|
2011-06-22 02:59:54 +04:00
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef BMESSAGE_VALUE_NODE_H
|
|
|
|
#define BMESSAGE_VALUE_NODE_H
|
|
|
|
|
2011-06-26 22:35:56 +04:00
|
|
|
#include <Message.h>
|
2011-07-03 00:11:54 +04:00
|
|
|
#include <MessagePrivate.h>
|
2011-06-26 22:35:56 +04:00
|
|
|
#include <ObjectList.h>
|
2011-07-03 00:11:54 +04:00
|
|
|
#include <Variant.h>
|
2011-06-22 02:59:54 +04:00
|
|
|
|
2011-07-03 00:11:54 +04:00
|
|
|
#include "ValueLocation.h"
|
2011-06-22 02:59:54 +04:00
|
|
|
#include "ValueNode.h"
|
|
|
|
|
|
|
|
|
2011-07-01 05:54:58 +04:00
|
|
|
class CompoundType;
|
|
|
|
|
|
|
|
|
2011-06-22 02:59:54 +04:00
|
|
|
class BMessageValueNode : public ValueNode {
|
|
|
|
public:
|
2015-06-07 20:27:13 +03:00
|
|
|
BMessageValueNode(
|
|
|
|
ValueNodeChild* nodeChild, Type* type);
|
2011-06-26 22:35:56 +04:00
|
|
|
virtual ~BMessageValueNode();
|
2011-06-22 02:59:54 +04:00
|
|
|
|
2011-06-26 22:35:56 +04:00
|
|
|
virtual Type* GetType() const;
|
|
|
|
virtual status_t ResolvedLocationAndValue(
|
|
|
|
ValueLoader* valueLoader,
|
|
|
|
ValueLocation*& _location,
|
|
|
|
Value*& _value);
|
2011-06-22 02:59:54 +04:00
|
|
|
|
2011-06-28 04:20:59 +04:00
|
|
|
virtual bool ChildCreationNeedsValue() const
|
|
|
|
{ return true; }
|
2015-06-07 20:27:13 +03:00
|
|
|
virtual status_t CreateChildren(TeamTypeInformation* info);
|
2011-06-26 22:35:56 +04:00
|
|
|
virtual int32 CountChildren() const;
|
|
|
|
virtual ValueNodeChild* ChildAt(int32 index) const;
|
2011-06-22 02:59:54 +04:00
|
|
|
|
2011-07-03 00:11:54 +04:00
|
|
|
private:
|
2011-07-08 01:51:50 +04:00
|
|
|
|
2015-06-07 20:27:13 +03:00
|
|
|
status_t _GetTypeForTypeCode(
|
|
|
|
TeamTypeInformation* info,
|
|
|
|
type_code type,
|
2011-07-03 00:11:54 +04:00
|
|
|
Type*& _type);
|
|
|
|
status_t _FindField(const char* name,
|
|
|
|
type_code type,
|
|
|
|
BMessage::field_header** result) const;
|
|
|
|
uint32 _HashName(const char* name) const;
|
|
|
|
status_t _FindDataLocation(const char* name,
|
|
|
|
type_code type, int32 index,
|
|
|
|
ValueLocation& location) const;
|
|
|
|
|
2011-06-22 02:59:54 +04:00
|
|
|
private:
|
2011-07-01 06:40:16 +04:00
|
|
|
class BMessageFieldNode;
|
|
|
|
class BMessageFieldNodeChild;
|
2011-06-26 22:35:56 +04:00
|
|
|
|
|
|
|
// for GCC2
|
2011-07-01 06:40:16 +04:00
|
|
|
friend class BMessageFieldNode;
|
|
|
|
friend class BMessageFieldNodeChild;
|
2011-07-08 01:51:50 +04:00
|
|
|
friend class BMessageWhatNodeChild;
|
2011-06-28 04:08:15 +04:00
|
|
|
|
|
|
|
typedef BObjectList<ValueNodeChild> ChildNodeList;
|
|
|
|
|
2011-06-26 22:35:56 +04:00
|
|
|
private:
|
|
|
|
Type* fType;
|
2011-06-28 04:08:15 +04:00
|
|
|
ChildNodeList fChildren;
|
2011-07-03 00:11:54 +04:00
|
|
|
BVariant fDataLocation;
|
|
|
|
BMessage::message_header*
|
|
|
|
fHeader;
|
|
|
|
BMessage::field_header* fFields;
|
|
|
|
uint8* fData;
|
|
|
|
BMessage fMessage;
|
2011-07-08 01:51:50 +04:00
|
|
|
bool fIsFlatMessage;
|
2011-06-26 22:35:56 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-07-01 06:40:16 +04:00
|
|
|
class BMessageValueNode::BMessageFieldNode : public ValueNode {
|
2011-06-26 22:35:56 +04:00
|
|
|
public:
|
2011-07-01 06:40:16 +04:00
|
|
|
BMessageFieldNode(
|
|
|
|
BMessageFieldNodeChild *child,
|
2011-06-26 22:35:56 +04:00
|
|
|
BMessageValueNode* parent,
|
|
|
|
const BString& name,
|
|
|
|
type_code type, int32 count);
|
|
|
|
|
2011-07-01 06:40:16 +04:00
|
|
|
virtual ~BMessageFieldNode();
|
2011-06-26 22:35:56 +04:00
|
|
|
|
|
|
|
virtual Type* GetType() const;
|
|
|
|
|
|
|
|
virtual status_t ResolvedLocationAndValue(
|
|
|
|
ValueLoader* loader,
|
|
|
|
ValueLocation *& _location,
|
|
|
|
Value*& _value);
|
|
|
|
|
2015-06-07 20:27:13 +03:00
|
|
|
virtual status_t CreateChildren(TeamTypeInformation* info);
|
2011-07-03 00:11:54 +04:00
|
|
|
virtual int32 CountChildren() const;
|
|
|
|
virtual ValueNodeChild* ChildAt(int32 index) const;
|
|
|
|
|
2011-06-26 22:35:56 +04:00
|
|
|
private:
|
|
|
|
BString fName;
|
|
|
|
Type* fType;
|
|
|
|
BMessageValueNode* fParent;
|
|
|
|
type_code fFieldType;
|
|
|
|
int32 fFieldCount;
|
2011-07-04 18:05:42 +04:00
|
|
|
ChildNodeList fChildren;
|
2011-06-26 22:35:56 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2011-07-01 06:40:16 +04:00
|
|
|
class BMessageValueNode::BMessageFieldNodeChild : public ValueNodeChild {
|
2011-06-26 22:35:56 +04:00
|
|
|
public:
|
2011-07-01 06:40:16 +04:00
|
|
|
BMessageFieldNodeChild(
|
2011-06-28 04:08:15 +04:00
|
|
|
BMessageValueNode* parent,
|
2011-07-03 00:11:54 +04:00
|
|
|
Type* nodeType,
|
2011-06-26 22:35:56 +04:00
|
|
|
const BString &name,
|
2011-07-04 18:05:42 +04:00
|
|
|
type_code type, int32 count,
|
|
|
|
int32 index = -1);
|
2011-06-26 22:35:56 +04:00
|
|
|
|
2011-07-01 06:40:16 +04:00
|
|
|
virtual ~BMessageFieldNodeChild();
|
2011-06-26 22:35:56 +04:00
|
|
|
|
|
|
|
virtual const BString& Name() const;
|
|
|
|
virtual Type* GetType() const;
|
|
|
|
virtual ValueNode* Parent() const;
|
|
|
|
|
|
|
|
virtual bool IsInternal() const;
|
|
|
|
virtual status_t CreateInternalNode(
|
|
|
|
ValueNode*& _node);
|
|
|
|
|
|
|
|
virtual status_t ResolveLocation(ValueLoader* valueLoader,
|
|
|
|
ValueLocation*& _location);
|
|
|
|
|
|
|
|
private:
|
|
|
|
BString fName;
|
2011-07-04 18:05:42 +04:00
|
|
|
BString fPresentationName;
|
2011-06-26 22:35:56 +04:00
|
|
|
Type* fType;
|
2011-06-28 04:08:15 +04:00
|
|
|
BMessageValueNode* fParent;
|
2011-06-26 22:35:56 +04:00
|
|
|
type_code fFieldType;
|
|
|
|
int32 fFieldCount;
|
2011-07-04 18:05:42 +04:00
|
|
|
int32 fFieldIndex;
|
2011-06-26 22:35:56 +04:00
|
|
|
};
|
|
|
|
|
2011-06-22 02:59:54 +04:00
|
|
|
#endif // BMESSAGE_VALUE_NODE_H
|