Пример #1
0
void sci_base_observer_initialize(
   SCI_BASE_OBSERVER_T        * the_observer,
   SCI_BASE_OBSERVER_UPDATE_T   update,
   SCI_BASE_SUBJECT_T         * the_subject
)
{
   sci_base_observer_construct(the_observer, update);
   sci_base_subject_attach_observer(the_subject, the_observer);
}
/**
 * This is a helper function that will construct the state machine logger and
 * attach it to the state machine that is to be observed.
 *
 * @param[in] this_observer This is the state machine logger object that is
 *       going to observe the subject state machine.
 * @param[in] the_state_machine This is the state machine that is under
 *       observation.
 * @param[in] the_object This is the object that contains the state machine
 *       being observed it is used to report the address of the object for
 *       which a state transition has occurred.
 * @param[in] the_log_function This is the logging function to be used when a
 *       state machine transition occurs.  Since this is a base object type it
 *       does not actually know if the logging function is for the core or
 *       framework.
 * @param[in] the_object_name This is the name of the object that contains the
 *       state machine being observed.
 * @param[in] the_state_machine_name This is the name that will be displayed
 *       in the log string for the state machine being observed.
 * @param[in] the_object_mask This is the log object mask used when calling
 *       the logging function.
 *
 * @return Nothing
 */
void sci_base_state_machine_logger_initialize(
   SCI_BASE_STATE_MACHINE_LOGGER_T             * this_observer,
   SCI_BASE_STATE_MACHINE_T                    * the_state_machine,
   SCI_BASE_OBJECT_T                           * the_object,
   SCI_BASE_STATE_MACHINE_LOGGER_LOG_HANDLER_T   the_log_function,
   char                                        * log_object_name,
   char                                        * log_state_machine_name,
   U32                                           log_object_mask
)
{
   sci_base_state_machine_logger_construct(
      this_observer, the_object,
      the_log_function, log_object_name, log_state_machine_name, log_object_mask
   );

   sci_base_subject_attach_observer(
      &the_state_machine->parent, &this_observer->parent.parent
   );
}