source: geniuswebcore/geniusweb/party/Capabilities.py@ 73

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

Fix for IssueValue hashcode.

File size: 1.7 KB
Line 
1from typing import Set
2
3
4class Capabilities:
5 '''
6 The capabilities of a party
7 '''
8
9
10 knownprofileclasses = [
11 "geniusweb.profile.utilityspace.UtilitySpace",
12 "geniusweb.profile.utilityspace.LinearAdditive",
13 "geniusweb.profile.utilityspace.LinearAdditiveUtilitySpace",
14 "geniusweb.profile.utilityspace.SumOfGroupsUtilitySpace",
15 "geniusweb.profile.DefaultPartialOrdering",
16 "geniusweb.profile.FullOrdering",
17 "geniusweb.profile.DefaultProfile",
18 "geniusweb.profile.Profile",
19 "geniusweb.profile.PartialOrdering",
20 ]
21
22 def __init__(self, behaviours:Set[str], profiles:Set[str]):
23 '''
24 @param behaviours the {@link ProtocolRef} that a Party can handle, as
25 returned by NegoProtocol.getRef()
26 @param profiles the {@link Profile} classes that Party acan handle
27 '''
28 if (behaviours == None):
29 raise ValueError("behaviours==null")
30
31 prof:str
32 for prof in profiles:
33 if prof not in self.knownprofileclasses:
34 raise ValueError("profile " + prof + " must be a subclass of Profile")
35 self.__behaviours = behaviours
36 self.__profiles = profiles
37
38 def getBehaviours(self)-> Set[str]:
39 '''
40 @return the behaviours (protocols) that are supported
41 '''
42 return self.__behaviours
43
44 def getProfiles(self)-> Set[str]:
45 '''
46 @return the profile classes that are supported
47 '''
48 return self.__profiles
49
50 def __repr__(self)-> str:
51 return "Capabilities[" + str(self.__profiles)+"," + str(self.__behaviours) + "]"
52
53 def __hash__(self):
54 return hash((tuple(self.__profiles), tuple(self.__behaviours)))
55
56 def __eq__(self, other):
57 return isinstance(other, self.__class__) \
58 and self.__profiles == other.__profiles \
59 and self.__behaviours==other.__behaviours
Note: See TracBrowser for help on using the repository browser.