| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

TrimmingAgent Class Reference

#include <TrimmingAgent.h>

Inheritance diagram for TrimmingAgent:

[legend]
Collaboration diagram for TrimmingAgent:
[legend]
List of all members.

Public Member Functions

 TrimmingAgent (MsgStream *msgStream)
 ~TrimmingAgent ()
virtual bool analyse (IRegistry *pRegistry, int level)
 Analyse the data object.
const TimeStamp earliest ()
 Returns the earliest time for an object not to be trimmed.
const TimeStamplatest ()
 Returns tthe latest time for an object not to be trimmed.
const TimeStampwindow ()
 Returns the time difference between the latest and earliest time used by this object.
const TimeStampwindow (const std::string &path)
 Returns the time difference between the latest and earliest time for the specified path or default if none specified.
void setLatest (const TimeStamp &latest)
 Sets the latest time for an object not to be trimmed and, using the default window size, the earliest time for an object not to be trimmed.
void setWindow (const TimeStamp &window)
 Sets the default time difference between the latest and ealiest times of the window.
void setWindow (const std::string &path, const TimeStamp &window)
 Sets the time difference between the latest and ealiest times for the specified path.

Private Types

typedef std::map< std::string,
TimeStamp
WindowMap_t
 The set of customized windows.

Private Attributes

TimeStamp m_latest
 The latest time for an object not to be trimmed.
TimeStamp m_window
 The default window size.
MsgStreamm_msgStream
 Stream through which to output messages.
WindowMap_t m_windows

Detailed Description

Definition at line 12 of file TrimmingAgent.h.


Member Typedef Documentation

typedef std::map<std::string, TimeStamp> TrimmingAgent::WindowMap_t [private]

The set of customized windows.

Definition at line 89 of file TrimmingAgent.h.


Constructor & Destructor Documentation

TrimmingAgent::TrimmingAgent ( MsgStream msgStream  ) 

Definition at line 9 of file TrimmingAgent.cpp.

00009                                                  :
00010   m_window(0),
00011   m_msgStream(msgStream){
00012 }

TrimmingAgent::~TrimmingAgent (  ) 

Definition at line 14 of file TrimmingAgent.cpp.

00014                               {
00015   if (0 != m_msgStream) {
00016     delete m_msgStream;
00017   }
00018 }


Member Function Documentation

bool TrimmingAgent::analyse ( IRegistry pRegistry,
int  level 
) [virtual]

Analyse the data object.

Returns:
Boolean indicating wether the tree below should be analysed

Implements IDataStoreAgent.

Definition at line 20 of file TrimmingAgent.cpp.

00021                                              {
00022   DataObject* object = pRegistry->object();
00023   if (0 == object) {
00024     return true;
00025   }
00026   
00027   DybArchiveList* list = dynamic_cast<DybArchiveList*>(object);
00028   if (0 == list) {
00029     return true;
00030   }
00031 
00032   std::string path = pRegistry->identifier();
00033   TimeStamp earliest = m_latest;
00034   earliest.Add(-1.0 * window(path));
00035 
00036   unsigned int dataCount = 0; 
00037   unsigned int temporalCount = 0; 
00038   DybArchiveList::iterator entry = list->begin();
00039   while (list->end() != entry) {
00040     (*m_msgStream)<< MSG::VERBOSE<< "not end" <<endreq;
00041     DataObject* dataObject = (*entry);
00042 
00043     // Protect against zero object.
00044     if ( 0 == dataObject) {
00045       entry = list->erase(entry);
00046     } else {
00047       // wangzhe 
00048       //ITemporal* temporalObject = dynamic_cast<ITemporal*>(dataObject);
00049       TemporalDataObject * temporalObject = dynamic_cast<TemporalDataObject*>(dataObject);
00050       // wz
00051       
00052       if (0 == temporalObject) {
00053         entry = list->erase(entry);
00054         ++dataCount;
00055       } else {
00056         // for debuging
00057         (*m_msgStream)<< MSG::VERBOSE<< path<<endreq;
00058         (*m_msgStream)<< MSG::VERBOSE<< "pObj "<<temporalObject<<endreq;
00059         (*m_msgStream)<< MSG::VERBOSE<< "m_latest "<<m_latest<<endreq;
00060         (*m_msgStream)<< MSG::VERBOSE<< "earliest "<<earliest<<endreq;
00061         (*m_msgStream)<< MSG::VERBOSE<< "window "<<double(window(path))<< " seconds"<<endreq;
00062         (*m_msgStream)<< MSG::VERBOSE<< "obj latest   "<<temporalObject->latest()<<endreq;
00063         (*m_msgStream)<< MSG::VERBOSE<< "obj earliest "<<temporalObject->earliest()<<endreq;
00064         (*m_msgStream)<< MSG::VERBOSE<< "obj refCount "<<temporalObject->refCount()<<endreq;
00065         // only earliest time is always in time order.
00066         // Some event with long delay coincidence might inverse the sequence.
00067         if (temporalObject->earliest() <= earliest) {
00068           (*m_msgStream)
00069               << MSG::DEBUG<< "Erased from AES " << path
00070               << " dt = " << double(earliest - temporalObject->earliest()) << " seconds"
00071               << endreq;
00072           entry = list->erase(entry);
00073           ++temporalCount;
00074         } else {
00075           ++entry;
00076         }
00077         // for debuging
00078         // (*m_msgStream) << MSG::VERBOSE<<"obj refCount "<<temporalObject->refCount()<<endreq;
00079       }
00080     }
00081   }
00082   if (0 != m_msgStream) {
00083     if (0 != dataCount) {
00084       std::string plural = "";
00085       if (1 != dataCount) {
00086         plural == "s";
00087       }
00088       (*m_msgStream) << MSG::DEBUG
00089                      << "Removed "
00090                      << dataCount
00091                      << " DataObject"
00092                      << plural
00093                      << " from the \""
00094                      << path
00095                      << "\" node in the archive."
00096                      << endreq;    
00097     }
00098     if (0 != temporalCount) {
00099       std::string plural = "";
00100       if (1 != dataCount) {
00101         plural == "s";
00102       }
00103       (*m_msgStream) << MSG::DEBUG
00104                      << "Removed "
00105                      << temporalCount
00106                      << " ITemporal object"
00107                      << plural
00108                      << " from the \""
00109                      << path
00110                      << "\" node in the archive."
00111                      << endreq;
00112     }
00113   }
00114   return true;
00115 }

const TimeStamp TrimmingAgent::earliest (  ) 

Returns the earliest time for an object not to be trimmed.

Definition at line 117 of file TrimmingAgent.cpp.

00117                                         {
00118   TimeStamp result = m_latest;
00119   result.Add(m_window);
00120   return result;
00121 }

const TimeStamp & TrimmingAgent::latest (  ) 

Returns tthe latest time for an object not to be trimmed.

Definition at line 123 of file TrimmingAgent.cpp.

00123                                        {
00124   return m_latest;
00125 }

const TimeStamp & TrimmingAgent::window (  ) 

Returns the time difference between the latest and earliest time used by this object.

Definition at line 127 of file TrimmingAgent.cpp.

00127                                        {
00128   return m_window;
00129 }

const TimeStamp & TrimmingAgent::window ( const std::string &  path  ) 

Returns the time difference between the latest and earliest time for the specified path or default if none specified.

Definition at line 131 of file TrimmingAgent.cpp.

00131                                                             {
00132     WindowMap_t::iterator wit = m_windows.find(path);
00133     if (wit == m_windows.end()) {
00134         return m_window;
00135     }
00136     return wit->second;
00137 }

void TrimmingAgent::setLatest ( const TimeStamp latest  ) 

Sets the latest time for an object not to be trimmed and, using the default window size, the earliest time for an object not to be trimmed.

Definition at line 139 of file TrimmingAgent.cpp.

00139                                                      {
00140   m_latest = latest;
00141 }

void TrimmingAgent::setWindow ( const TimeStamp window  ) 

Sets the default time difference between the latest and ealiest times of the window.

Definition at line 143 of file TrimmingAgent.cpp.

00143                                                      {
00144   m_window = window;
00145 }

void TrimmingAgent::setWindow ( const std::string &  path,
const TimeStamp window 
)

Sets the time difference between the latest and ealiest times for the specified path.

Definition at line 147 of file TrimmingAgent.cpp.

00148                                                        {
00149   m_windows[path] = window;
00150 }


Member Data Documentation

TimeStamp TrimmingAgent::m_latest [private]

The latest time for an object not to be trimmed.

Definition at line 74 of file TrimmingAgent.h.

TimeStamp TrimmingAgent::m_window [private]

The default window size.

Definition at line 79 of file TrimmingAgent.h.

MsgStream* TrimmingAgent::m_msgStream [private]

Stream through which to output messages.

Definition at line 84 of file TrimmingAgent.h.

WindowMap_t TrimmingAgent::m_windows [private]

Definition at line 90 of file TrimmingAgent.h.


The documentation for this class was generated from the following files:
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:40:08 2011 for DybEventMgr by doxygen 1.4.7