SampleSubject/SampleSubject.cc

Go to the documentation of this file.
00001 //
00002 // Copyright 2002 Sony Corporation 
00003 //
00004 // Permission to use, copy, modify, and redistribute this software for
00005 // non-commercial use is hereby granted.
00006 //
00007 // This software is provided "as is" without warranty of any kind,
00008 // either expressed or implied, including but not limited to the
00009 // implied warranties of fitness for a particular purpose.
00010 //
00011 
00012 #include <string.h>
00013 #include <OPENR/OSyslog.h>
00014 #include <OPENR/core_macro.h>
00015 #include "SampleSubject.h"
00016 
00017 SampleSubject::SampleSubject()
00018 {
00019 }
00020 
00021 OStatus
00022 SampleSubject::DoInit(const OSystemEvent& event)
00023 {
00024     NEW_ALL_SUBJECT_AND_OBSERVER;
00025     REGISTER_ALL_ENTRY;
00026     SET_ALL_READY_AND_NOTIFY_ENTRY;
00027     return oSUCCESS;
00028 }
00029 
00030 OStatus
00031 SampleSubject::DoStart(const OSystemEvent& event)
00032 {
00033     ENABLE_ALL_SUBJECT;
00034     ASSERT_READY_TO_ALL_OBSERVER;
00035     return oSUCCESS;
00036 }    
00037 
00038 OStatus
00039 SampleSubject::DoStop(const OSystemEvent& event)
00040 {
00041     DISABLE_ALL_SUBJECT;
00042     DEASSERT_READY_TO_ALL_OBSERVER;
00043     return oSUCCESS;
00044 }
00045 
00046 OStatus
00047 SampleSubject::DoDestroy(const OSystemEvent& event)
00048 {
00049     DELETE_ALL_SUBJECT_AND_OBSERVER;
00050     return oSUCCESS;
00051 }
00052 
00053 void 
00054 SampleSubject::Ready(const OReadyEvent& event)
00055 { 
00056     OSYSPRINT(("SampleSubject::Ready() : %s\n",
00057                event.IsAssert() ? "ASSERT READY" : "DEASSERT READY"));
00058 
00059     static int counter = 0;
00060     char str[32];
00061 
00062     if (counter == 0) {
00063 
00064         strcpy(str, "!!! Hello world !!!");
00065         subject[sbjSendString]->SetData(str, sizeof(str));  
00066         subject[sbjSendString]->NotifyObservers();  
00067 
00068     } else if (counter == 1) {
00069 
00070         strcpy(str, "!!! Hello world again !!!");
00071         subject[sbjSendString]->SetData(str, sizeof(str));
00072         subject[sbjSendString]->NotifyObservers();  
00073 
00074     }
00075 
00076     counter++;
00077 }

Generated on Sun Dec 2 23:04:30 2007 for openSDK by  doxygen 1.3.9.1