Main Page | Modules | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

DC_EventRepository.cpp

00001 // 00002 // Copyright 2004 P&P Software GmbH - All Rights Reserved 00003 // 00004 // DC_EventRepository.cpp 00005 // 00006 // Version 1.1 00007 // Date 13.09.03 (version 1.0) 00008 // 03.12.03 (version 1.1) 00009 // Author A. Pasetti (P&P Software), R. Totaro 00010 // 00011 // Change Record: 00012 // Version 1.1: The class was almost completely re-implemented. 00013 00014 #include "../GeneralInclude/CompilerSwitches.h" 00015 #include "../GeneralInclude/DebugSupport.h" 00016 #include "../GeneralInclude/BasicTypes.h" 00017 #include "../GeneralInclude/ClassId.h" 00018 #include "../GeneralInclude/Constants.h" 00019 #include "../System/ObsClock.h" 00020 #include "DC_Event.h" 00021 #include "DC_EventRepository.h" 00022 00023 DC_EventRepository::DC_EventRepository(void) { 00024 setClassId(ID_EVENTREPOSITORY); 00025 00026 counter =0; 00027 listSize =0; 00028 pList =pNULL; 00029 pObsClock =pNULL; 00030 globalEnabled=ENABLED; 00031 00032 for (int i=0;i<=LAST_EVENT_TYPE;i++) 00033 selectiveEnabled[i]=ENABLED; 00034 00035 reset(); 00036 } 00037 00038 void DC_EventRepository::setRepositorySize(unsigned int repositorySize) { 00039 assert(listSize==0 && repositorySize>0); 00040 00041 pList =new DC_Event*[repositorySize]; 00042 listSize=repositorySize; 00043 00044 for (unsigned int i=0;i<repositorySize;i++) 00045 pList[i]=pNULL; 00046 00047 createEventDataStructure(); 00048 } 00049 00050 void DC_EventRepository::createEventDataStructure(void) { 00051 assert(pList!=pNULL); 00052 00053 for (unsigned int i=0;i<listSize;i++) { 00054 pList[i]=new DC_Event; 00055 assert(pList[i]); 00056 } 00057 } 00058 00059 void DC_EventRepository::create(CC_RootObject *originator,TD_EventType eventId) { 00060 assert(isObjectConfigured() && 00061 originator!=pNULL && eventId>0 && eventId<=LAST_EVENT_TYPE); 00062 00063 // Only create event if creation is enabled 00064 if (isEnabled() && isEnabled(eventId)) { 00065 pList[counter%listSize]->setEventType(eventId); 00066 pList[counter%listSize]->setTimeStamp(pObsClock->getTime()); 00067 00068 counter++; 00069 } 00070 } 00071 00072 void DC_EventRepository::latest(void) { 00073 eventPointer=(counter>0?counter-1:0); 00074 iterationCounter=(counter>=listSize?listSize:counter); 00075 } 00076 00077 void DC_EventRepository::previous(void) { 00078 if (iterationCounter>0) { 00079 iterationCounter--; 00080 eventPointer--; 00081 } 00082 } 00083 00084 void DC_EventRepository::reset(void) { 00085 eventPointer =0; 00086 iterationCounter=0; 00087 } 00088 00089 bool DC_EventRepository::isObjectConfigured(void) { 00090 return (CC_RootObject::isObjectConfigured() && pList!=pNULL && pObsClock!=pNULL); 00091 }
Copyright 2003 P&P Software GmbH - All Rights Reserved