/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Public Member Functions | Private Types | Private Member Functions | Private Attributes
TrimmingAgent Class Reference

#include <TrimmingAgent.h>

Collaboration diagram for TrimmingAgent:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TrimmingAgent (MsgStream *msgStream, IIncidentSvc *incsvc)
 ~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 Member Functions

DybArchiveList::iterator erase (DybArchiveList &dal, DybArchiveList::iterator &it)

Private Attributes

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

Detailed Description

Definition at line 15 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 92 of file TrimmingAgent.h.


Constructor & Destructor Documentation

TrimmingAgent::TrimmingAgent ( MsgStream *  msgStream,
IIncidentSvc *  incsvc 
)

Definition at line 10 of file TrimmingAgent.cpp.

                                                                       :
  m_window(0),
  m_msgStream(msgStream),
  m_incSvc(incsvc)
{
}
TrimmingAgent::~TrimmingAgent ( )

Definition at line 17 of file TrimmingAgent.cpp.

                              {
  if (m_msgStream) {
    delete m_msgStream;
    m_msgStream = 0;
  }
  if (m_incSvc) {
    m_incSvc->release();
    m_incSvc = 0;
  }
}

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

Definition at line 48 of file TrimmingAgent.cpp.

                                   {
  DataObject* object = pRegistry->object();
  if (0 == object) {
    return true;
  }
  
  DybArchiveList* list = dynamic_cast<DybArchiveList*>(object);
  if (0 == list) {
    return true;
  }

  std::string path = pRegistry->identifier();
  TimeStamp earliest = m_latest;
  earliest.Add(-1.0 * window(path));

  //unsigned int dataCount = 0; 
  //unsigned int temporalCount = 0; 
  DybArchiveList::iterator entry = list->begin();
  while (list->end() != entry) {
    //(*m_msgStream)<< MSG::VERBOSE<< "not end" <<endreq;
    DataObject* dataObject = (*entry);

    // Protect against zero object.
    if ( 0 == dataObject) {
      entry = this->erase(*list,entry);
      continue;
    } 

    TemporalDataObject * temporalObject = dynamic_cast<TemporalDataObject*>(dataObject);
      
    if (0 == temporalObject) {
      entry = this->erase(*list,entry);
      //++dataCount;
      continue;
    } 

    // for debuging
    //(*m_msgStream)<< MSG::VERBOSE<< path<<endreq;
    //(*m_msgStream)<< MSG::VERBOSE<< "pObj "<<temporalObject<<endreq;
    //(*m_msgStream)<< MSG::VERBOSE<< "m_latest "<<m_latest<<endreq;
    //(*m_msgStream)<< MSG::VERBOSE<< "earliest "<<earliest<<endreq;
    //(*m_msgStream)<< MSG::VERBOSE<< "window "<<double(window(path))<< " seconds"<<endreq;
    //(*m_msgStream)<< MSG::VERBOSE<< "obj latest   "<<temporalObject->latest()<<endreq;
    //(*m_msgStream)<< MSG::VERBOSE<< "obj earliest "<<temporalObject->earliest()<<endreq;
    //(*m_msgStream)<< MSG::VERBOSE<< "obj refCount "<<temporalObject->refCount()<<endreq;

    // only earliest time is always in time order.
    // Some event with long delay coincidence might inverse the sequence.
    if (temporalObject->earliest() <= earliest) {
      //(*m_msgStream)
      //  << MSG::DEBUG<< "Erased from AES " << path
      //  << " dt = " << double(earliest - temporalObject->earliest()) << " seconds"
      //  << endreq;
      entry = this->erase(*list, entry);
      //++temporalCount;
    } 

    else {
      ++entry;
    }
  } // end loop over archive list

  //if (!m_msgStream) {
  //  return true;                // can't print, so bail now
  //}

  //if (0 != dataCount) {
    //std::string plural = "";
    //if (1 != dataCount) {
    //  plural == "s";
    //}
    //(*m_msgStream) << MSG::DEBUG
    //              << "Removed "
    //               << dataCount
    //               << " DataObject"
    //               << plural
    //               << " from the \""
    //               << path
    //               << "\" node in the archive."
    //               << endreq;    
  //}
  
  //if (0 != temporalCount) {
    //std::string plural = "";
    //if (1 != dataCount) {
    //  plural == "s";
    //}
    //(*m_msgStream) << MSG::DEBUG
    //               << "Removed "
    //               << temporalCount
    //               << " ITemporal object"
    //               << plural
    //               << " from the \""
    //               << path
    //               << "\" node in the archive."
    //               << endreq;
  //}

  return true;
}
const TimeStamp TrimmingAgent::earliest ( )

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

Definition at line 150 of file TrimmingAgent.cpp.

                                        {
  TimeStamp result = m_latest;
  result.Add(m_window);
  return result;
}
const TimeStamp & TrimmingAgent::latest ( )

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

Definition at line 156 of file TrimmingAgent.cpp.

                                       {
  return m_latest;
}
const TimeStamp & TrimmingAgent::window ( )

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

Definition at line 160 of file TrimmingAgent.cpp.

                                       {
  return m_window;
}
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 164 of file TrimmingAgent.cpp.

                                                            {
    WindowMap_t::iterator wit = m_windows.find(path);
    if (wit == m_windows.end()) {
        return m_window;
    }
    return wit->second;
}
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 172 of file TrimmingAgent.cpp.

                                                     {
  m_latest = latest;
}
void TrimmingAgent::setWindow ( const TimeStamp window)

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

Definition at line 176 of file TrimmingAgent.cpp.

                                                     {
  m_window = window;
}
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 180 of file TrimmingAgent.cpp.

                                                       {
  m_windows[path] = window;
}
DybArchiveList::iterator TrimmingAgent::erase ( DybArchiveList dal,
DybArchiveList::iterator it 
) [private]

Definition at line 28 of file TrimmingAgent.cpp.

{
  m_incSvc->fireIncident(EventStoreIncident(*it,false,"TrimmingAgent"));
  if (m_msgStream) {
    *m_msgStream << MSG::DEBUG 
                 << "Trimming " << (*it)->name() 
                 << " with refCount: " << (*it)->refCount()
                 << endreq;
    TemporalDataObject *to = dynamic_cast<TemporalDataObject*>(*it);
    if (to) {
      *m_msgStream << MSG::DEBUG 
                   << "\n\tearliest:" << to->earliest() 
                   << "\n\tlatest:  " << to->latest()
                   << endreq;
    }
  }
  return dal.erase(it);
}

Member Data Documentation

The latest time for an object not to be trimmed.

Definition at line 77 of file TrimmingAgent.h.

The default window size.

Definition at line 82 of file TrimmingAgent.h.

MsgStream* TrimmingAgent::m_msgStream [private]

Stream through which to output messages.

Definition at line 87 of file TrimmingAgent.h.

Definition at line 93 of file TrimmingAgent.h.

IIncidentSvc* TrimmingAgent::m_incSvc [private]

Definition at line 97 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 Fri May 16 2014 10:09:08 for DybEventMgr by doxygen 1.7.4