In earlier articles (Get More from DOORS with DXL Graphics, Get More from DOORS with DXL Links), I introduced some of the special features of The DOORS. the edition and execution of IBM Rational® DOORS® DXL files inside Eclipse. We recommend users to read the Eclipse Basic tutorial to get familiar with the. These scripts are provided free of charge for the benefit of DOORS users. You may copy, modify or distribute any of these scripts as you wish, but please leave.
|Published (Last):||15 December 2016|
|PDF File Size:||12.39 Mb|
|ePub File Size:||3.80 Mb|
|Price:||Free* [*Free Regsitration Required]|
I was recently asked about the possibility to store large amounts of linked data efficiently in DXL. So in this post we want to take a look at two questions: A very simple example would be to simply store the contents or the links of a module from DXL. Most people would probably use a “Nested Skip” approach.
The code could look like this: While simple, this approach has two drawbacks: One can imagine that this becomes very complex, once more complex data is being stored, e.
The same is true for storing “class instances”, i. Whenever a large amount of instances will be created, Skip lists are a bad choice for storage. While for more recent DOORS versions the allocations and deallocations are much quicker, the effect of having a large number of allocations is still relevant.
You can read about allocations here: So imagine you want tutorila store the structure of a complete DOORS project, with tutorkal the links inside, so you can make your awesome traceability analysis, without constantly closing and opening modules. So normally you will come up with a class structure like this classes prefixed with S to avoid name clashes with DOORS types: As you can see, with this structure there a two problems: From the allocations perspective you can say: From a code perspective, managing a nesting level of 4 with 4 different skip types will give you spaghetti code.
So lets take a look on what we can do to change this. The good news about this is, you will not suffer from any slowdown inside your scripts! The bad news is you will suffer from bad permanent memory leaks, since the memory for the DXLObjects is never freed automatically! tugorial
Use of DXL Scripts
Most of you should by now know, that we can translate the above class hierarchy to DXL code, by creating custom structs. I already described how to make structs at several places in the forum, e. And while IBM tried to remove alowdown in my opinion with a stupid approach by removing DxlObjects from the allocation list, probably as a esult of some PR, there is a better way to store objects without producing the risk for permanent leaks.
The idea is, instead of using a skip list to store each object instance, to simply use an Array.
Each column inside the array is a property value, each row is doorx object. This will allocate 8 MB x number of propreties which will not kill your memory, but k is a good starting size. Memory will not be freed and pile up!
But this can be easily fixed by introducing a stack of freed indexes to be reused, whenever a new object is allocated. This slighly complicates the class boilerplate, but the code will be the same for ALL classes. If you care about this behaviour you need to check for null on each property access! While this template solves the problem of not creating allocations for class instances we still need to look on how to create properties for the dooors and how to solve the nesting problem i.
Properties can be added to an array managed class in an easy way as already shown xoors Making a “virtual function” template is left as an exercise for the reader See github tutorial for virtual functions. Ok, now lets take a look on how we can implement those array properties efficiently.
As already mentioned using a Skip property is not indicated since it will again create one allocation per instance. Therefore what we will do is replace the Skip by our own implementation called “List” which has the same efficient memory management as shown above.
Note that we have an “underscore” type parameter in the list, so our list can use any data type. For these kinds of properties the property definition is a bit different see the attached List. Unfortunately in DXL we cannot implement a custom for loop, for iterating over the list.
To implement an iteration protocol for DXL with a nice syntax I propose: Feel free to adapt the example list implementation in the attached doogs as you which fast append to the end of the list, etc. The important stuff is, that now having a List which items do not produce any allocation we are free to implement our classes that will not use any allocation.
So assuming that we have made our classes SObject, SModule, SLink and SAttrValue according to the above description we can now easily code our complete project cache script: Look how nice and easy the code looks, using our classes.
We have complete type safety, so that we will never have a wrong type inside a skip list and get crashes. This is a huge benefit! For all that made it to the end, thanks for reading. Like the post if you read itso I know there is still DXL programmers interesting in tutorials. For all of those who need to store tree data and are looking for an optimized Tree implementation look here: Answered question This question has been answered.
Unanswered question This question has not been answered yet. Motivation A very simple example would be to simply store the contents or the tuorial of a module from DXL.
Getting Started with DXL
Example Problem So imagine you want to store the structure of a complete DOORS project, with all the links inside, so you can make your awesome traceability analysis, without constantly closing and opening modules. Using classes – how to use arrays to reduce allocations Most of you should by now know, that we can translate the above class hierarchy to DXL code, by creating custom structs.
Class Properties Properties can be added to an array managed class in an easy way as already shown above: Solving the problem of array properties Ok, now lets take a look on how we can implement those array properties efficiently.
Applying the approach to the Example Problem So assuming that we have made our classes SObject, SModule, SLink and SAttrValue according to the above description we can now easily code our complete project cache script: Log in to reply. Feed for this topic.