What are the methods and algorithms available to accurately calculate the energy consumption of a C++ code? Please provide a comprehensive explanation including the relevant factors, metrics, and considerations that should be taken into account during the energy consumption calculation process.