Skip to content

Commit 413a65c

Browse files
kavehshahedibhufmann
authored andcommitted
Get tags for virtual table lines and cells
Signed-off-by: Kaveh Shahedi <[email protected]>
1 parent 03173f7 commit 413a65c

File tree

3 files changed

+74
-2
lines changed

3 files changed

+74
-2
lines changed

test_tsp.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
from tsp.health import HealthStatus
3333
from tsp.response import ResponseStatus
3434
from tsp.tsp_client import TspClient
35+
from tsp.virtual_table_tag import VirtualTableTag
3536

3637
STATISTICS_DP_ID = (
3738
"org.eclipse.tracecompass.analysis.timing.core.segmentstore.SegmentStoreStatisticsDataProvider:"
@@ -529,10 +530,12 @@ def test_fetch_virtual_table_lines(self, ust):
529530
assert line.index is not None
530531
if i == 0:
531532
assert line.index == LOW_INDEX
533+
assert line.tags is VirtualTableTag.NO_TAGS
532534

533535
assert len(line.cells) > 0
534536
for cell in line.cells:
535537
assert cell.content is not None
538+
assert cell.tags is VirtualTableTag.NO_TAGS
536539

537540
self._delete_experiments()
538541
self._delete_traces()

tsp/virtual_table_model.py

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@
2222

2323
"""VirtualTableModel class file."""
2424

25+
from tsp.virtual_table_tag import VirtualTableTag
26+
2527
SIZE_KEY = "size"
2628
LOW_INDEX_KEY = "lowIndex"
2729
COLUMN_IDS_KEY = "columnIds"
2830
LINES_KEY = "lines"
31+
TAGS_KEY = "tags"
2932

3033
TABLE_LINE_INDEX_KEY = "index"
3134
TABLE_LINE_CELLS_KEY = "cells"
@@ -99,13 +102,32 @@ def __init__(self, params):
99102
self.cells.append(VirtualTableLineCell(cell))
100103
del params[TABLE_LINE_CELLS_KEY]
101104

105+
self.tags = VirtualTableTag.NO_TAGS
106+
if TAGS_KEY in params:
107+
if params.get(TAGS_KEY) is not None and type(params.get(TAGS_KEY)) is int:
108+
tags = int(params.get(TAGS_KEY))
109+
110+
match tags:
111+
case 0: # Tag 0 is used for no tags
112+
self.tags = VirtualTableTag.NO_TAGS
113+
case 1 | 2: # Tags 1 and 2 are reserved
114+
self.tags = VirtualTableTag.RESERVED
115+
case 4: # Tag 4 is used for border
116+
self.tags = VirtualTableTag.BORDER
117+
case 8: # Tag 8 is used for highlight
118+
self.tags = VirtualTableTag.HIGHLIGHT
119+
case _: # Other tags are not supported
120+
self.tags = VirtualTableTag.NO_TAGS
121+
del params[TAGS_KEY]
122+
102123
def print(self):
103124

104125
print(f" index: {self.index}")
126+
print(f" tags: {self.tags.name}")
105127
print(" cells:")
106128
for i, cell in enumerate(self.cells):
107129
cell.print()
108-
print(f" {'-' * 10}")
130+
print(f" {'-' * 30}")
109131

110132
class VirtualTableLineCell:
111133
'''
@@ -120,5 +142,25 @@ def __init__(self, params):
120142
self.content = params.get(TABLE_LINE_CELL_CONTENT_KEY)
121143
del params[TABLE_LINE_CELL_CONTENT_KEY]
122144

145+
self.tags = VirtualTableTag.NO_TAGS
146+
if TAGS_KEY in params:
147+
if params.get(TAGS_KEY) is not None and type(params.get(TAGS_KEY)) is int:
148+
tags = int(params.get(TAGS_KEY))
149+
150+
match tags:
151+
case 0: # Tag 0 is used for no tags
152+
self.tags = VirtualTableTag.NO_TAGS
153+
case 1 | 2: # Tags 1 and 2 are reserved
154+
self.tags = VirtualTableTag.RESERVED
155+
case 4: # Tag 4 is used for border
156+
self.tags = VirtualTableTag.BORDER
157+
case 8: # Tag 8 is used for highlight
158+
self.tags = VirtualTableTag.HIGHLIGHT
159+
case _: # Other tags are not supported
160+
self.tags = VirtualTableTag.NO_TAGS
161+
del params[TAGS_KEY]
162+
123163
def print(self):
124-
print(f" \"{TABLE_LINE_CELL_CONTENT_KEY}\": \"{self.content}\"")
164+
print(f" \"{TABLE_LINE_CELL_CONTENT_KEY}\": \"{self.content}\"")
165+
print(f" \"tags\": {self.tags.name}")
166+
print(f" {'-' * 10}")

tsp/virtual_table_tag.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
from enum import Enum
2+
3+
class VirtualTableTag(Enum):
4+
'''
5+
Tag is a bit mask to apply for tagging elements (e.g. table lines, states).
6+
This can be used by the server to indicate if a filter matches and what action to apply.
7+
'''
8+
9+
'''
10+
Simply no tags
11+
'''
12+
NO_TAGS = 'NO_TAGS'
13+
14+
'''
15+
Some tags are reserved for the server
16+
'''
17+
RESERVED = 'RESERVED'
18+
19+
'''
20+
Border tag
21+
'''
22+
BORDER = 'BORDER'
23+
24+
'''
25+
Highlight tag
26+
'''
27+
HIGHLIGHT = 'HIGHLIGHT'

0 commit comments

Comments
 (0)