atomizer.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002 /
00003 /   File:           atomizer.h
00004 /
00005 /   Description:    Kernel atomizer module API
00006 /
00007 /   Copyright 1999, Be Incorporated, All Rights Reserved.
00008 /
00009 *******************************************************************************/
00010 
00011 #ifndef _ATOMIZER_MODULE_H_
00012 #define _ATOMIZER_MODULE_H_
00013 
00014 #include <module.h>
00015 
00016 #ifdef __cplusplus
00017 extern "C" {
00018 #endif
00019 
00020 /*
00021     An atomizer is a software device that returns a unique token for a
00022     null-terminated UTF8 string.
00023 
00024     Each atomizer comprises a separate token space.  The same string interned
00025     in two different atomizers will generate two distinct tokens.
00026 
00027     Atomizers and the tokens they generate are only guaranteed valid between
00028     matched calls to get_module/put_module.
00029     
00030     void * find_or_make_atomizer(const char *string)
00031         Returns a token that identifies the named atomizer, creating a new
00032         atomizer if the named atomizer does not exist.  Pass null, a zero
00033         length string, or the value B_SYSTEM_ATOMIZER_NAME for string will
00034         return a pointer to the system atomizer.  Returns (void *)(0)
00035         if the atomizer could not be created (for whatever reason).  A return
00036         value of (void *)(-1) refers to the system atomizer.
00037 
00038     status_t delete_atomizer(void *atomizer)
00039         Delete the atomizer specified.  Returns B_OK if successfull, B_ERROR
00040         otherwise.  An error return usually means that a race condition was
00041         detected while destroying the atomizer.
00042 
00043     void * atomize(void *atomizer, const char *string, int create)
00044         Return the unique token for the specified string, creating a new token
00045         if the string was not previously atomized and create is non-zero.  If
00046         atomizer is (void *)(-1), use the system atomizer (saving the step of
00047         looking it up with find_or_make_atomizer().  Returns (const char *)(0)
00048         if there were any errors detected: insufficient memory or a race
00049         condition with someone deleting the atomizer.
00050 
00051     const char * string_for_token(void *atomizer, void *atom)
00052         Return a pointer to the string described by atom in the provided atomizer.
00053         Returns (const char *)(0) if either the atomizer or the atom were invalid.
00054 
00055     status_t get_next_atomizer_info(void **cookie, atomizer_info *info)
00056         Returns info about the next atomizer in the list of atomizers by modifying
00057         the contents of info.  The pointer specified by *cookie should be set to
00058         (void *)(0) to retrieve the first atomizer, and should not be modified
00059         thereafter.  Returns B_ERROR when there are no more atomizers.
00060         Adding or deleting atomizers between calls to get_next_atomizer() results
00061         in a safe but undefined behavior.
00062 
00063     void * get_next_atom(void *atomizer, uint32 *cookie)
00064         Returns the next atom interned in specified atomizer,  *cookie
00065         should be set to (uint32)(0) to get the first atom.  Returns
00066         (void *)(0) when there are no more atoms.  Adding atoms between
00067         calls to get_next_atom() may cause atoms to be skipped.
00068 
00069     Atomizers are SMP-safe.  Check return codes for errors!
00070 
00071 */
00072 
00073 #define B_ATOMIZER_MODULE_NAME "generic/atomizer/v1"
00074 #define B_SYSTEM_ATOMIZER_NAME "BeOS System Atomizer"
00075 
00076 typedef struct {
00077     void    *atomizer;  /* An opaque token representing the atomizer. */
00078     char    name[B_OS_NAME_LENGTH]; /* The first B_OS_NAME_LENGTH bytes of the atomizer name, null terminated. */
00079     uint32  atom_count; /* The number of atoms currently interned in this atomizer. */
00080 } atomizer_info;
00081 
00082 typedef struct {
00083     module_info     minfo;
00084     const void *    (*find_or_make_atomizer)(const char *string);
00085     status_t        (*delete_atomizer)(const void *atomizer);
00086     const void *    (*atomize)(const void *atomizer, const char *string, int create);
00087     const char *    (*string_for_token)(const void * atomizer, const void *atom);
00088     status_t        (*get_next_atomizer_info)(void **cookie, atomizer_info *info);
00089     const void *    (*get_next_atom)(const void *atomizer, uint32 *cookie);
00090 } atomizer_module_info;
00091 
00092 #ifdef __cplusplus
00093 }
00094 #endif
00095 
00096 #endif
00097 

Copyright 2005 by yellowTAB GmbH, Be Inc., Palm Source Inc. and their respective legal successors
All rights reserved.