source: geniuswebcore/geniusweb/inform/Settings.py@ 94

Last change on this file since 94 was 90, checked in by Bart Vastenhouw, 3 years ago

Refactor to help reusing partiesserver.

File size: 2.8 KB
Line 
1from geniusweb.inform.Inform import Inform
2from geniusweb.progress.Progress import Progress
3from geniusweb.references.Parameters import Parameters
4from geniusweb.references.ProfileRef import ProfileRef
5from geniusweb.references.ProtocolRef import ProtocolRef
6from geniusweb.actions.PartyId import PartyId
7
8
9class Settings (Inform):
10 '''
11 Informs a Party about all settings for the upcoming negotiation session. This
12 should be sent to a party one time, so that the party knows the situation.
13 '''
14
15 def __init__(self, id:PartyId , profile:ProfileRef ,protocol:ProtocolRef ,
16 progress:Progress ,parameters:Parameters ):
17 '''
18 @param id the {@link PartyId} for this party
19 @param profile the profile used for this party in this session
20 @param protocol the protocol used in this session
21 @param progress the {@link Progress} object used for this session
22 @param parameters a {@link Map} <String, Object> containing
23 initialization parameters for this party. The Object
24 can be a HashMap, ArrayList, String, or number
25 (Integer, Double, etc). The Object should not be just
26 any Object because deserialization will work only with
27 the mentioned types.
28 '''
29 assert isinstance(id, PartyId)
30 assert isinstance(profile, ProfileRef)
31 assert isinstance(protocol, ProtocolRef)
32 assert isinstance(progress, Progress)
33 assert isinstance(parameters, Parameters)
34
35 self._profile = profile;
36 self._protocol = protocol;
37 self._progress = progress;
38 self._parameters = parameters;
39 self._id = id;
40
41 def getProfile(self) -> ProfileRef:
42 '''
43 @return the profile used for this party in this session
44 '''
45 return self._profile
46
47 def getProtocol(self) -> ProtocolRef :
48 return self._protocol
49
50 def getProgress(self) -> Progress :
51 '''
52 @return the {@link Progress} object used for this session
53 '''
54 return self._progress
55
56
57 def getID(self) -> PartyId :
58 '''
59 @return the party ID of this party
60 '''
61 return self._id
62
63 def getParameters(self)->Parameters :
64 '''
65 @return a {@link HashMap}<String,Object> containing initialization
66 parameters that can be used by the party.
67 '''
68 return self._parameters
69
70 def __repr__(self)->str:
71 return "Settings[" + str(self._id) + "," + str(self._profile) + "," + \
72 str(self._protocol) + ","+ str(self._progress) + "," + str(self._parameters) + "]"
73
74 def __eq__(self, other):
75 return isinstance(other, self.__class__)\
76 and self._profile == other._profile \
77 and self._protocol == other._protocol \
78 and self._progress == other._progress \
79 and self._parameters == other._parameters\
80 and self._id == other._id
81
82 def __hash__(self):
83 return hash((self._id, self._parameters, self._progress, self._protocol, self._profile))
84
Note: See TracBrowser for help on using the repository browser.