Objects Unique IDs
Continuing the work of last week on user objects tracking, this week I started the implementation. The task for this week was to :
- Extract the object IDs from the user Code.
- Check if all IDs are unique or not.
- Form a list of IDs and object class name.
- Notify the user if any ID is repeated.
As I mentioned last week , it was quite hard to come up with something unique that distinguishes each user’s declared object, so I have decided to make the user provide the ID himself . Meaning that when he declares new object of certain classes he should pass a unique ID in the class template as an argument.
To extract the object ID from the class template this was pretty straight forward. I used the information found in the object file under the relocation section using readelf command. “readelf -rW <file-name>.o |c++filt”. This command will list all the user’s object constructor functions . From this output then it will be easy to extract the ID using the regular expression.
Then after extracting every ID a checking is made in order to assure if it’s unique or not. A list that contains all the classes names and IDs will be sent upon success to the schematic editor (jointJS ) so for it to be updated with the specific component that corresponds to each object.
Kindly refer to Islam’s blog entry for this week for more information about this.
Then,the user will be updated if any object ID is repeated as follows :
Beside working on that , so far our code was created for one session , meaning that it can’t handle more than one user at a time. So to solve this problem, when the user starts a new session a temporary directory will be created. This directory will store all the files the user will need at the session.The name of the directory will be created randomly and passed in a cookie. So on my back engine all I needed to do was to use Witty getCookie() function to obtain the name of the directory that corresponds to that session. All the temporary directories are created inside the approot.
That’s all for this week. Thanks for reading.