diff options
author | Andrew Jeffery <andrew@aj.id.au> | 2018-02-28 00:35:50 +1030 |
---|---|---|
committer | Andrew Jeffery <andrew@aj.id.au> | 2018-04-04 00:31:37 +0930 |
commit | ad343101c59beb0c2b0c1033f031ff76ff2237d7 (patch) | |
tree | 28c21f3cbf47ce720dd1e006bfdff7c52e45eb8d /test/vpnor/create_pnor_partition_table.cpp | |
parent | fc62158caeaef009cd0055ce8cc35586581840b8 (diff) | |
download | phosphor-mboxd-ad343101c59beb0c2b0c1033f031ff76ff2237d7.tar.gz phosphor-mboxd-ad343101c59beb0c2b0c1033f031ff76ff2237d7.zip |
pnor_partition: Refactor to enforce stronger boundaries for abstractions
The RORequest and RWRequest classes did not provide a clear abstraction
over the operation of populating a window or partition associated with a
CREATE_{READ,WRITE}_WINDOW request. The role of the classes was to find
the partition for the provided offset, locate and then open its backing
file.
However, the file-descriptor for the backing file was exposed outside of
the class, as was the FFS partition struct, both of which were managed
_internal_ to the class. Thus the classes provided no encapsulation of
state and awkwardly split the tasks of managing and utilising the
resources between the callee and caller.
This commit inverts the behaviour in a fulfil() method handles the
mechanics of locating, opening, manipulating and closing the backing
file, requiring nothing of the caller. The pnor_partition reference is
managed entirely inside the Request class, derived from the offset
passed to the constructor.
Unifying the mechanics into fulfil() results in a decent reduction in
lines of code at the expense of some cyclomatic complexity. fulfil() is
publicly exposed via read() and write() wrappers on the class, and the
RORequest and RWRequest classes are removed as a result.
Change-Id: Ie587ed31f1a6db97bcb490dbcc2e27ece0b1f82c
Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Diffstat (limited to 'test/vpnor/create_pnor_partition_table.cpp')
0 files changed, 0 insertions, 0 deletions