Odin(3)                                                                Odin(3)



NNAAMMEE
       Odin -

SSYYNNOOPPSSIISS
   PPuubblliicc MMeetthhooddss
       ccrreeaattee ()
       mapping qquueerryy__uunnuusseedd__iiddss ()
       int qquueerryy__mmaaxx__iidd ()
       int ggeett__nneeww__iidd ()
       void ffrreeee__iidd (int id)
       string ddeessttrruuccttoorr ()
       int cchheecckk__iidd (int id)
       int qquueerryy__iidd__ffrreeee (int id)
       string ggeett__ssaavvee__ffiillee__nnaammee (int id)

   PPuubblliicc AAttttrriibbuutteess
       mapping uunnuusseedd__iiddss
       int mmaaxx__iidd

DDEETTAAIILLEEDD DDEESSCCRRIIPPTTIIOONN
       This object is named after Odin, the all-seeing god of Norse mythology.
       It has a rather obscure but highly important job -- it keeps track of
       all the saveload identification numbers for all the objects in the MUD.
       When a new object is created, it is Odin's job to assign it a number
       and (using the number) a spot in the file system where it can save
       itself.

       The original saveload system didn't work this way, but since I intend
       to get rid of the old system as soon as this one is working, it doesn't
       matter much how it worked.

       In theory, this object stores every Unique ID (a 32-bit integer used by
       saveload to determine its filename). Every saveload object also knows
       its unique ID once it has loaded itself. Since it would eat way too
       much space to actually store every single unique ID, though (I'm aiming
       for this MUDlib to handle tens of thousands of objects), it optimizes
       by only storing *unused* unique ID's. This works well as long as all of
       the unique ID's are within a known, densely populated range (such as
       0-20,000, with 95% used).

       The mmaaxx__iidd iiss tthhee hhiigghheesstt kknnoowwnn uusseedd IIDD ((iiff tthheerree aarree nnoo kknnoowwnn uusseedd
       IIDD''ss,, tthheenn mmaaxx__iidd iiss 00,, wwhhiicchh iiss aann iilllleeggaall uunniiqquuee IIDD)).. TThhee zzeerroo--wwiiddtthh
       mmaappppiinngg uunnuusseedd__iiddss hhoollddss eevveerryy uunnuusseedd IIDD bbeettwweeeenn 00 aanndd mmaaxx__iidd..

       Odin does not save its data; it is regenerated during world-loading.
       Since this process can't be duplicated after the MUD has started, you
       will get an error if you try to destruct Odin before shutdown. This is
       quite deliberate -- it is possible for two objects to get confused and
       assign themselves the same save file, and it is possible for an object
       to get destructed without notifying Odin that its ID is now free.
       Regenerating the data on startup detects and fixes both kinds of
       problems.

       OObbjjeecctt data itself is stored under /data.

       Definition at line 37 of file odin.c.

MMEEMMBBEERR FFUUNNCCTTIIOONN DDOOCCUUMMEENNTTAATTIIOONN
   iinntt cchheecckk__iidd ((iinntt iidd))
       Used while the MUD is booting up. As each object loads, it calls
       check_id to inform odin which id's are already in use. Odin thus builds
       its database of id's from scratch.

       RReettuurrnnss::
           True, if the id really is unique. If a different object had already
           allocated that id, it will be detected here, and this function will
           return false; in this case, the object will ask for a new id, and
           will be split off into a seperate data file.

       Definition at line 115 of file odin.c.

       References max_id, and unused_ids.

   ccrreeaattee (())
       Initializes variables.

       Definition at line 48 of file odin.c.

       References max_id, and unused_ids.

   ssttrriinngg ddeessttrruuccttoorr (())
       Called if someone tries to destruct odin. The destruct is only
       permitted if the MUD is busy shutting down.

       Definition at line 101 of file odin.c.

   vvooiidd ffrreeee__iidd ((iinntt iidd))
       Frees up _i_d, allowing it to be used by another object. This function is
       called by objects when they are destructed.

       Definition at line 87 of file odin.c.

       References max_id, and unused_ids.

   iinntt ggeett__nneeww__iidd (())
       Called by objects when they are created. This function allocates a
       unique id for the object and returns it; no other object in the game
       will have that id.

       Definition at line 73 of file odin.c.

       References max_id, and unused_ids.

   ssttrriinngg ggeett__ssaavvee__ffiillee__nnaammee ((iinntt iidd))
       RReettuurrnnss::
           The full file name to which the object identified by _i_d should save
           its data.

       Definition at line 151 of file odin.c.

   iinntt qquueerryy__iidd__ffrreeee ((iinntt iidd))
       Added for debugging. Tells me if an ID is free or not.

       Definition at line 144 of file odin.c.

       References max_id, and unused_ids.

   iinntt qquueerryy__mmaaxx__iidd (())
       RReettuurrnnss::
           The current value of max_id. Mainly useful for debugging or
           curiosity.

       Definition at line 65 of file odin.c.

       References max_id.

   mmaappppiinngg qquueerryy__uunnuusseedd__iiddss (())
       RReettuurrnnss::
           A mapping of the unused id's. This mapping is returned as a copy.

       WWaarrnniinngg::
           This call is very expensive. Only call it for debugging reasons;
           you should never use this in normal code.

       Definition at line 58 of file odin.c.

       References unused_ids.

MMEEMMBBEERR DDAATTAA DDOOCCUUMMEENNTTAATTIIOONN
   iinntt mmaaxx__iidd
       The highest used unique ID.

       Definition at line 45 of file odin.c.

       Referenced by check_id(), create(), free_id(), get_new_id(),
       query_id_free(), and query_max_id().

   mmaappppiinngg uunnuusseedd__iiddss
       A mapping of all the currently unused ID's that are less than max_id.

       Definition at line 43 of file odin.c.

       Referenced by check_id(), create(), free_id(), get_new_id(),
       query_id_free(), and query_unused_ids().


AAUUTTHHOORR
       Generated automatically by Doxygen for Walraven from the source code.



Walraven                          8 Jan 2004                           Odin(3)
