-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathOwnership.h
73 lines (60 loc) · 1.63 KB
/
Ownership.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* Ownership.h
*
* Created on: Sep 9, 2012
* Author: knuthelv
*/
#ifndef DDS_Policy_Ownership_h_Included
#define DDS_Policy_Ownership_h_Included
#include"DDS/CommonDefines.h"
#include"DDS/Policy/PolicyKind.h"
#include"DDS/Policy/QosPolicyBase.h"
#include"DDS/Export.h"
namespace DDS { namespace Policy
{
/**
* @abstract
*
* This policy controls whether the Service allows multiple DataWriter objects to update the same instance (identified by
* Topic + key) of a data-object.
*
* There are two kinds of OWNERSHIP selected by the setting of the kind: SHARED and EXCLUSIVE.
*/
class DLL_STATE Ownership : public QosPolicyBase
{
public:
Ownership(Policy::OwnershipKind::Type kind)
: kind_(kind)
{ }
Ownership()
: kind_(Policy::OwnershipKind::SHARED)
{ }
DEFINE_POLICY_TRAITS(Ownership, 6, DDS::Policy::RequestedOfferedKind::COMPATIBLE, false)
public:
virtual void Write(NetworkLib::SerializeWriter *writer) const
{
writer->WriteInt32((int32_t) kind_);
}
virtual void Read(NetworkLib::SerializeReader *reader)
{
kind_ = (Policy::OwnershipKind::Type) reader->ReadInt32();
}
public:
void SetKind(Policy::OwnershipKind::Type kind) { kind_ = kind; }
Policy::OwnershipKind::Type GetKind() const { return kind_; }
public:
static Ownership Exclusive()
{
static Ownership ownership(Policy::OwnershipKind::EXCLUSIVE);
return ownership;
}
static Ownership Shared()
{
static Ownership ownership(Policy::OwnershipKind::SHARED);
return ownership;
}
private:
Policy::OwnershipKind::Type kind_;
};
}}
#endif