/*
 * Copyright (C) 2008-2012 Delft University of Technology - All rights reserved.
 *
 * Author: Reijer Idema
 */

/**
 * @file LogEvents.h
 * PETSc Log Events class header.
 */
#ifndef PowerFlower_LogEvents_h
#define PowerFlower_LogEvents_h

//#include "../PetscUtils/PetscUtils.h"	// USES PetscUtils
#include "petsclog.h"					// HASA PetscLogEvent
#include "PowerFlower.def"

POWERFLOWER_NAMESPACE_BEGIN

/**
 * Log Events class.
 * Stores the PETSc log event ids for PowerFlower log events.
 */
class LogEvents
{
public:
	// LIFECYCLE
	LogEvents(void);

	// OPERATIONS
	bool Register(void);
	bool Begin(PetscLogEvent event) const;
	bool End(PetscLogEvent event) const;

	// ACCESS

	// PowerSystemExt
	inline PetscLogEvent GetPSReadEventId(void) const { return mPSRead; }
	inline PetscLogEvent GetPSWriteEventId(void) const { return mPSWrite; }
	inline PetscLogEvent GetPSIsConnectedEventId(void) const { return mPSIsConnected; }

	// AdmittanceMatrix
	inline PetscLogEvent GetAMBuildEventId(void) const { return mAMBuild; }
	inline PetscLogEvent GetAMAddBranchEventId(void) const { return mAMAddBranch; }
	inline PetscLogEvent GetAMRemBranchEventId(void) const { return mAMRemBranch; }

	// PowerFlowProblem
	inline PetscLogEvent GetPFPCreateJacobianSystemEventId(void) const { return mPFPCreateJacobianSystem; }
	inline PetscLogEvent GetPFPCalculateJacobianSystemEventId(void) const { return mPFPCalculateJacobianSystem; }

	// PowerFlower
	inline PetscLogEvent GetPFSolveEventId(void) const { return mPFSolve; }
	inline PetscLogEvent GetPowerFlowEventId(void) const { return mPowerFlow; }
	inline PetscLogEvent GetContingencyAnalysisEventId(void) const { return mContingencyAnalysis; }

private:

	// PowerSystemExt
	PetscLogEvent mPSRead;			///< Read power system.
	PetscLogEvent mPSWrite;			///< Write power system.
	PetscLogEvent mPSIsConnected;	///< Check if power system is connected.

	// AdmittanceMatrix
	PetscLogEvent mAMBuild;			///< Build admittance matrix.
	PetscLogEvent mAMAddBranch;		///< Add branch to admittance matrix.
	PetscLogEvent mAMRemBranch;		///< Remove branch from admittance matrix.

	// PowerFlowProblem
	PetscLogEvent mPFPCreateJacobianSystem;		///< Create the Jacobian system.
	PetscLogEvent mPFPCalculateJacobianSystem;	///< Calculate the Jacobian system.

	// PowerFlower
	PetscLogEvent mPFSolve;				///< Solve power flow problem.
	PetscLogEvent mPowerFlow;			///< Power flow.
	PetscLogEvent mContingencyAnalysis;	///< Contingency Analysis.
};

POWERFLOWER_NAMESPACE_END

#endif // PowerFlower_LogEvents_h
