Changeset 235fb7a in rtems


Ignore:
Timestamp:
Feb 1, 2008, 9:56:47 PM (12 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.10, 4.11, 4.9, master
Children:
207b35ef
Parents:
6c4e9d0
Message:

2008-02-01 Joel Sherrill <joel.sherrill@…>

  • user/object.t: Added some examples.
Location:
doc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • doc/ChangeLog

    r6c4e9d0 r235fb7a  
     12008-02-01      Joel Sherrill <joel.sherrill@oarcorp.com>
     2
     3        * user/object.t: Added some examples.
     4
    152008-02-01      Joel Sherrill <joel.sherrill@oarcorp.com>
    26
  • doc/user/object.t

    r6c4e9d0 r235fb7a  
    8585@section Operations
    8686
    87 @subsection Decomposing an Object Id
    88 
    89 TBD
    90 
    91 @subsection Building an Object Id
    92 
    93 TBD
     87@subsection Decomposing and Recomposing an Object Id
     88
     89Services are provided to decompose an object Id into its
     90subordinate components. The following services are used
     91to do this:
     92
     93@itemize @bullet
     94@item @code{@value{DIRPREFIX}object_id_get_api}
     95@item @code{@value{DIRPREFIX}object_id_get_class}
     96@item @code{@value{DIRPREFIX}object_id_get_node}
     97@item @code{@value{DIRPREFIX}object_id_get_index}
     98@end itemize
     99
     100The following C language example illustrates the
     101decomposition of an Id and printing the values.
     102
     103@example
     104void printObjectId(rtems_id id)
     105@{
     106  printf(
     107    "API=%d Class=%d Node=%d Index=%d\n",
     108    rtems_object_id_get_api(id),
     109    rtems_object_id_get_class(id),
     110    rtems_object_id_get_node(id),
     111    rtems_object_id_get_index(id)
     112  );
     113@}
     114@end example
     115
     116This prints the components of the Ids as integers.
     117
     118It is also possible to construct an arbitrary Id using
     119the @code{@value{DIRPREFIX}build_id} service.  The following
     120C language example illustrates how to construct the
     121"next Id."
     122
     123@example
     124rtems_id nextObjectId(rtems_id id)
     125@{
     126  return rtems_build_id(
     127    rtems_object_id_get_api(id),
     128    rtems_object_id_get_class(id),
     129    rtems_object_id_get_node(id),
     130    rtems_object_id_get_index(id) + 1
     131  );
     132@}
     133@end example
     134
     135Note that this Id may not be valid in this
     136system or associated with an allocated object.
     137
     138@subsection Printing an Object Id
     139
     140RTEMS also provides services to associate the API and Class
     141portions of an Object Id with strings.  This allows the
     142application developer to provide more information about
     143an object in diagnostic messages.
     144
     145In the following C language example, an Id is decomposed into
     146its constituent parts and "pretty-printed."
     147
     148@example
     149void prettyPrintObjectId(rtems_id id)
     150@{
     151  uint32_t tmpAPI, tmpClass;
     152
     153  tmpAPI   = rtems_object_id_get_api(id),
     154  tmpClass = rtems_object_id_get_class(id),
     155
     156  printf(
     157    "API=%s Class=%s Node=%d Index=%d\n",
     158    rtems_object_get_api_name(tmpAPI),
     159    rtems_object_get_api_class_name(tmpAPI, tmpClass),
     160    rtems_object_id_get_node(id),
     161    rtems_object_id_get_index(id)
     162  );
     163@}
     164@end example
     165
     166@section Directives
    94167
    95168@c
Note: See TracChangeset for help on using the changeset viewer.