Patch by Alex Wilson (compilation fixes by myself): Extended the archiving/

unarchiving protocol to support archival of arbitrary object graphs.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@37431 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Ingo Weinhold
2010-07-08 14:54:25 +00:00
parent 8fbd792dd8
commit e5150e2847
10 changed files with 990 additions and 29 deletions
+4 -2
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2005-2009, Haiku Inc. All Rights Reserved.
* Copyright 2005-2010, Haiku Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -320,7 +320,9 @@ class BMessage {
BMessage* fQueueLink;
// fQueueLink is used by BMessageQueue to build a linked list
uint32 fReserved[9];
void* fArchivingPointer;
uint32 fReserved[8];
// deprecated
BMessage(BMessage *message);
+98 -16
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2001-2007, Haiku, Inc. All Rights Reserved.
* Copyright 2001-2010, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*/
#ifndef _ARCHIVABLE_H
@@ -12,25 +12,107 @@
class BMessage;
namespace BPrivate {
namespace Archiving {
class BArchiveManager;
class BUnarchiveManager;
}
}
using BPrivate::Archiving::BArchiveManager;
using BPrivate::Archiving::BUnarchiveManager;
class BArchivable {
public:
BArchivable(BMessage* from);
BArchivable();
virtual ~BArchivable();
public:
BArchivable(BMessage* from);
BArchivable();
virtual ~BArchivable();
virtual status_t Archive(BMessage* into, bool deep = true) const;
static BArchivable* Instantiate(BMessage* archive);
virtual status_t Archive(BMessage* into, bool deep = true) const;
static BArchivable* Instantiate(BMessage* archive);
// Private or reserved
virtual status_t Perform(perform_code d, void* arg);
virtual status_t Perform(perform_code d, void* arg);
private:
virtual void _ReservedArchivable1();
virtual void _ReservedArchivable2();
virtual void _ReservedArchivable3();
virtual status_t AllUnarchived(const BMessage* archive);
virtual status_t AllArchived(BMessage* archive) const;
uint32 _reserved[2];
private:
virtual void _ReservedArchivable3();
uint32 _reserved[2];
};
class BArchiver {
public:
BArchiver(BMessage* archive);
~BArchiver();
status_t AddArchivable(const char* name,
BArchivable* archivable, bool deep = true);
status_t GetTokenForArchivable(BArchivable* archivable,
int32& _token, bool deep = true);
bool IsArchived(BArchivable* archivable);
status_t Finish();
BMessage* ArchiveMessage() const;
private:
friend class BArchivable;
BArchiver(); // not defined
BArchiver(const BArchiver&); // not defined
void RegisterArchivable(const BArchivable* archivable);
BArchiveManager* fManager;
BMessage* fArchive;
bool fFinished;
};
class BUnarchiver {
public:
BUnarchiver(const BMessage* archive);
~BUnarchiver();
status_t GetArchivable(int32 token,
BArchivable** archivable);
status_t FindArchivable(const char* name,
BArchivable** archivable);
status_t FindArchivable(const char* name, int32 index,
BArchivable** archivable);
status_t EnsureUnarchived(const char* name,
int32 index = 0);
status_t EnsureUnarchived(int32 token);
bool IsInstantiated(int32 token);
bool IsInstantiated(const char* name,
int32 index = 0);
status_t Finish();
const BMessage* ArchiveMessage() const;
static bool IsArchiveManaged(BMessage* archive);
static BMessage* PrepareArchive(BMessage*& archive);
private:
friend class BArchivable;
BUnarchiver(); // not defined
BUnarchiver(const BUnarchiver&); // not defined
void RegisterArchivable(BArchivable* archivable);
void _CallDebuggerIfManagerNull();
BUnarchiveManager* fManager;
const BMessage* fArchive;
bool fFinished;
};
@@ -38,8 +120,8 @@ class BArchivable {
typedef BArchivable* (*instantiation_func)(BMessage*);
BArchivable* instantiate_object(BMessage *from, image_id *id);
BArchivable* instantiate_object(BMessage *from);
BArchivable* instantiate_object(BMessage* from, image_id* id);
BArchivable* instantiate_object(BMessage* from);
bool validate_instantiation(BMessage* from, const char* className);
instantiation_func find_instantiation_func(const char* className,
+15 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2005-2009, Haiku Inc. All rights reserved.
* Copyright 2005-2010, Haiku Inc. All rights reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -191,6 +191,20 @@ class BMessage::Private {
reply, sendTimeout, replyTimeout);
}
void*
ArchivingPointer()
{
return fMessage->fArchivingPointer;
}
void
SetArchivingPointer(void* pointer)
{
fMessage->fArchivingPointer = pointer;
}
// static methods
static status_t
@@ -21,9 +21,12 @@ enum {
PERFORM_CODE_SET_LAYOUT = 1006,
PERFORM_CODE_INVALIDATE_LAYOUT = 1007,
PERFORM_CODE_DO_LAYOUT = 1008,
PERFORM_CODE_GET_TOOL_TIP_AT = 1009
PERFORM_CODE_GET_TOOL_TIP_AT = 1009,
// support kit
PERFORM_CODE_ALL_ARCHIVED = 1010,
PERFORM_CODE_ALL_UNARCHIVED = 1011
};
@@ -0,0 +1,23 @@
/*
* Copyright 2010, Haiku, Inc.
* Distributed under the terms of the MIT License.
*/
#ifndef _BINARY_COMPATIBILITY_SUPPORT_H
#define _BINARY_COMPATIBILITY_SUPPORT_H
#include <binary_compatibility/Global.h>
struct perform_data_all_unarchived {
const BMessage* archive;
status_t return_value;
};
struct perform_data_all_archived {
BMessage* archive;
status_t return_value;
};
#endif /* _BINARY_COMPATIBILITY_INTERFACE_H_ */