00001
00002
00003
00004
00005
00006
00007
00008
00009
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 }