[cad-linux-dev] Re: entity 'ID' attribute: what's it for?

  • From: Eric Wilhelm <ewilhelm@xxxxxxxxxxxxx>
  • To: CAD linux development <cad-linux-dev@xxxxxxxxxxxxx>
  • Date: Tue, 7 Sep 2004 08:59:11 -0500

# The following was supposedly scribed by
# Bruno Postle
# on Tuesday 07 September 2004 06:58 am:

>I notice from the example yaml files created so-far that each of the
>entities has an 'ID' attribute.
>
>What I mean is that if a file is called "23.yml", it also has an
>"ID: 23" field internally.
>
>Why is this?  Surely an object doesn't need to know its own address,
>the software accessing-it knows already.

No, that's what it was for.  This was intended to be used for audit 
purposes.  You're probably right though.  Having it in the file 
causes problems.

>This could cause problems, for example:
>
>-  It would be impossible to clone an element in a drawing by doing
>   a straight filesystem copy - The copying tool would have to
>   fiddle with the file internals as well.

Right, or maybe a clone could be dynamic via symlinks.

>Also, all the elements so far have numeric (integer) filenames/IDs.
>Is this intended to be part of the spec?

Yes, do you have a different suggestion?

>This makes sense with data imported from an existing dwg file, but
>isn't much use if you intend to access the data concurrently with
>two different applications or one multi-threaded application.  There
>are only so many integers available and locking the whole directory
>when creating new files would be horrible.

The important thing is to not re-use an ID when an element is deleted.   
I would like the ID to be persistent and unique for the life of the 
drawing.  Last I checked, the number-line went to infinity.  I never 
said it had to be allocated as an integer, just that it is 
mathematically an integer.

If that causes problems, should we mix in letters to have hex names, 
or use the whole [0-9,a-z] character-set as a 36-base number system?  
Either way, it still reduces to an integer.

I think we'll need a couple of files to handle the concurrent usage 
issue.  If two programs attempt to create entities with identical 
ID's simultaneously, how do they know what ID's to use?  Maybe each 
would lock a range of ID's?

With a database, row ID's are assigned as the rows are created, but in 
that case there is a daemon in charge of them.  Maybe concurrent 
programs should connect to a socket for "next ID" information?  Could 
this be done cleanly with a single file?

--Eric
-- 
"...our schools have been scientifically designed to 
prevent overeducation from happening."
                                        --William Troy Harris

Other related posts: