2007-01-29 00:35:08 +03:00
|
|
|
/*
|
|
|
|
* Copyright 2001-2007, Haiku, Inc. All Rights Reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*
|
|
|
|
* Authors:
|
|
|
|
* DarkWyrm, bpmagic@columbus.rr.com
|
|
|
|
*/
|
2003-03-21 18:18:59 +03:00
|
|
|
#ifndef AREALINK_H
|
|
|
|
#define AREALINK_H
|
|
|
|
|
2007-01-29 00:35:08 +03:00
|
|
|
|
2003-03-21 18:18:59 +03:00
|
|
|
#include <InterfaceDefs.h>
|
2007-01-29 00:35:08 +03:00
|
|
|
#include <List.h>
|
2003-03-21 18:18:59 +03:00
|
|
|
#include <OS.h>
|
|
|
|
|
2007-01-29 00:35:08 +03:00
|
|
|
|
2003-03-21 18:18:59 +03:00
|
|
|
#define MAX_ATTACHMENT_SIZE 65535 // in bytes
|
|
|
|
#define SIZE_SIZE 2 // size of the size records in an AreaLink area
|
|
|
|
|
|
|
|
class AreaLinkHeader;
|
|
|
|
|
|
|
|
|
2007-01-29 00:35:08 +03:00
|
|
|
class AreaLink {
|
|
|
|
public:
|
|
|
|
AreaLink(area_id area, bool is_arealink_area = false);
|
|
|
|
AreaLink();
|
|
|
|
~AreaLink();
|
|
|
|
|
|
|
|
void SetTarget(area_id area, bool is_arealink_area = false);
|
|
|
|
area_id GetTarget() const { return fTarget; }
|
|
|
|
|
|
|
|
void Attach(const void *data, size_t size);
|
|
|
|
inline void Attach(const int32 &data);
|
|
|
|
inline void Attach(const int16 &data);
|
|
|
|
inline void Attach(const int8 &data);
|
|
|
|
inline void Attach(const float &data);
|
|
|
|
inline void Attach(const bool &data);
|
|
|
|
inline void Attach(const rgb_color &data);
|
|
|
|
inline void Attach(const BRect &data);
|
|
|
|
inline void Attach(const BPoint &data);
|
|
|
|
|
|
|
|
void MakeEmpty();
|
|
|
|
void *ItemAt(const int32 index) const { return fAttachList->ItemAt(index); }
|
|
|
|
int32 CountAttachments() const { return fAttachList->CountItems(); }
|
|
|
|
void *BaseAddress() const { return (void *)fBaseAddress; }
|
2003-03-21 18:18:59 +03:00
|
|
|
|
2007-01-29 00:35:08 +03:00
|
|
|
void Lock();
|
|
|
|
void Unlock();
|
|
|
|
bool IsLocked();
|
|
|
|
|
|
|
|
private:
|
|
|
|
void _ReadAttachments();
|
|
|
|
|
|
|
|
private:
|
|
|
|
BList *fAttachList;
|
|
|
|
area_id fTarget;
|
|
|
|
bool fAreaIsOk;
|
|
|
|
bool fHaveLock;
|
|
|
|
int8 *fBaseAddress;
|
|
|
|
AreaLinkHeader *fHeader;
|
2003-03-21 18:18:59 +03:00
|
|
|
};
|
|
|
|
|
2007-01-29 00:35:08 +03:00
|
|
|
#endif // AREALINK_H
|