text: /**
   * Copyright (2013) JDS Uniphase.  All rights reserved.
   *
   * Author: Jack Ng
   *
   */
  
  #ifndef XTREME_COMMON_IMEASUREMENTENGINE_H_
  #define XTREME_COMMON_IMEASUREMENTENGINE_H_
  
  #include "xtreme/common/job.h"
  #include "xtreme/common/event_frame.h"
  #include "xtreme/common/request_id.h"
  #include "xtreme/common/counter/counter_types.h"
  #include "xtreme/common/pubsub_filter/ifilter.h"
  
  using xtreme::jobm::TranslatedMeasurementSet;
  using xtreme::jobm::MeasurementSet;
  using xtreme::jobm::DimInfoList;
  using xtreme::jobm::DimensionInfo;
  using xtreme::jobm::KpiInfoList;
  using xtreme::jobm::KPIInfo;
  using xtreme::filter::IFilter;
  
  namespace xtreme {
  
  typedef DimensionType DimensionId;
  typedef RawCounterType CounterId;
  
  // Result codes for use by GetFrameResult_XXX functions
  typedef int64_t ResultCode;
  const ResultCode kResult_ResultValid                       = 0;   // Result value can be used.
  const ResultCode kResult_CounterNotSupportedForResultType  = -1;  // Indicates a coding error.
  const ResultCode kResult_NoResultForCurrentFrame           = -2;
  
  namespace aggregator {
  
  // Interface class for measurement engines that help the Common aggregator.
  class IMeasurementEngine {
   public:
    virtual ~IMeasurementEngine() {}
  
    // Filter parameters may not be set as dimensions in the measurement set, so need
    // to be processed here as well.
    virtual void AddMeasurementSet(TranslatedMeasurementSet* p_trans_meas_set,
                                   IFilter* p_filter) = 0;
  
    // TBD: This is temporary until the  record type setting moves to inside measurement set.
    virtual void AddMeasurementSet(TranslatedMeasurementSet* p_trans_meas_set,
                                   IFilter* p_filter, bool flowbased, bool live_datasource) = 0;
  
    // A job ID can have multiple bits enabled - one for each measurement set.
    virtual void RemoveMeasurementSet(const IDMask& job_id) = 0;
  
    // Measurement engines only need to handle frame events.
    virtual void Process(FrameEvent* p_event, size_t& flowkey_hashvalue) = 0;
  
    // Get result for current frame. Call this after calling Process() for each frame.
    // In addition to the result codes defined above, each engine can define its own specific codes.
    // The interpretation of additional result codes is based entirely on the mutual agreement
    // between each Raw Counter and the engine that implements this interface.
    // The same applies for the interpretation of result values (what a boolean result means etc).
    virtual ResultCode GetFrameResult_Integer(CounterId ctr_id, uint64_t& result) = 0;
    virtual ResultCode GetFrameResult_Bool(CounterId ctr_id, bool& result) = 0;
    virtual ResultCode GetFrameResult_Float(CounterId ctr_id, double& result) = 0;
  
    // When ASAP is triggered, memory is low, so appropriate action needs to be taken.
    virtual void set_asap_trigger_status(bool status) = 0;
  };
  
  // Structure to store all the plugin engines interface for common aggregator usage.
  struct EnginesInterface {
      IMeasurementEngine* IDPIEngine_;
      IMeasurementEngine* ITCPEngine_;
  };
  
  enum EngineType {
      DPI_ENGINE
    , TCP_ENGINE
  };
  }  // namespace aggregator
  }  // namespace xtreme
  
  #endif  // XTREME_COMMON_IMEASUREMENTENGINE_H_
  