Comparing two device type instances is one of the worst-described and worst-designed functions of the FDT technology for two reasons:
The comparison process is a synchronous action. The Compare() method needs to return a result immediately.
Due to that, the DTM needs to implement a message pump. This is some kind of critical.
An actually, if we have it as a synchronous operation, one method would have been sufficient.
Why does FDT need the InitCompare() and ReleaseCompare() method? GetDtmForSystemTag() and ReleaseDtmForSystemTag() could also be called in the Compare() method itself.
It is not defined in which environment the second copy should be started.
There are three possibilities:
a) the copy is started without any topology around, which means that the copy cannot call GetChildNodes() or GetParentNodes().
b) the copy is started with the same environment like the original. That means that the original DTM and the copy get the same system tags when calling GetParentNodes() or GetChildNodes()
c) the copy is started in a copied environment. That means, it can call GetParentNodes(), but will get a copied parent instead of the original parent.
The correct way for this function would have been a method Compare() and a callback OnCompareFinished().
This would provide a real asynchronous operation, without the need for a message pump.
In addition, the number of methods would be reduced in that case.
Of course, the environment would still be needed to be defined. I would suggest that comparison must work without parent or child DTMs.
The reason for this is, that the compared DTM should not include information in the comparison of other DTMs.
If other DTMs are interesting to be compared, the frame application can call Compare() on those instances as well.
The reason for three methods seems to be the Comparison with user interface.
But even in this situation, the type could have been modeled as XML and passed as argument for Compare() so that the DTM needs to open the user interface.
Another question is, why a copy of the DTM needs to be started for comparison anyway.
From my point of view, the DTM could perform a comparison based on a persistence stream or property bag.
The DTM is capable of loading the stream anyway.
This would also clarify the question of environment for the copied DTM.