// ---------------------------------------------------------------------------
// - Physics.hpp                                                             -
// - afnix:phy service - fundamental physical constants class definition     -
// ---------------------------------------------------------------------------
// - This program is free software;  you can redistribute it  and/or  modify -
// - it provided that this copyright notice is kept intact.                  -
// -                                                                         -
// - This program  is  distributed in  the hope  that it will be useful, but -
// - without  any  warranty;  without  even   the   implied    warranty   of -
// - merchantability or fitness for a particular purpose.  In no event shall -
// - the copyright holder be liable for any  direct, indirect, incidental or -
// - special damages arising in any way out of the use of this software.     -
// ---------------------------------------------------------------------------
// - copyright (c) 1999-2011 amaury darsch                                   -
// ---------------------------------------------------------------------------

#ifndef  AFNIX_PHYSICS_HPP
#define  AFNIX_PHYSICS_HPP

#ifndef  AFNIX_PLIST_HPP
#include "Plist.hpp"
#endif

namespace afnix {

  /// The Physics class is a simple class that holds some of the fundamental
  /// physical constants. The class also provides some methods to compute
  /// basic physical values which are part of our daily life.
  /// @author amaury darsch

  class Physics : public Object {
  public:
    /// speed of light in vacuum
    static const t_real UNV_C  = 299792458.0;
    /// magnetic constant
    static const t_real UNV_U0 = 12.566370614E-7;
    // electric constant
    static const t_real UNV_E0 = 8.854187817E-12;
    // constant of gravitation
    static const t_real UNV_G  = 6.67428E-11;
    // planck constant
    static const t_real UNV_H  = 6.62606896E-34;
    // planck constant h/2*PI
    static const t_real UNV_HB = 1.054571628E-34;

  public:
    // boltzmann constant
    static const t_real PCH_K  = 1.3806504E-23;
    // boltzmann constant in ev
    static const t_real PCH_KV = 8.617343E-5;
    // avogadro constant
    static const t_real PCH_NA = 6.02214179E23;
    // absolute temperature offset
    static const t_real PCH_TK = 273.15;

  public:
    // elementary charge
    static const t_real EMT_Q  = 1.602176487E-19;

  private:
    Plist d_plst;

  public:
    /// create a physics object
    Physics (void);

    /// copy construct this object
    /// @param that the object to copy
    Physics (const Physics& that);

    /// assign an object to this one
    /// @param that the object to assign
    Physics& operator = (const Physics& that);

    /// @return the class name
    String repr (void) const;

    /// @return a clone of this object
    Object* clone (void) const;

    /// @return true if the name exists
    bool exists (const String& name) const;

    /// get a physical constant by name
    /// @param name the constant name
    t_real getval (const String& name) const;

    /// @return a copy of the physical constants table
    Plist gettbl (void) const;

  public:
    /// create a new object in a generic way
    /// @param argv the argument vector
    static Object* mknew (Vector* argv);
    
    /// @return true if the given quark is defined
    bool isquark (const long quark, const bool hflg) const;
    
    /// apply this object with a set of arguments and a quark
    /// @param robj  the current runnable
    /// @param nset  the current nameset    
    /// @param quark the quark to apply these arguments
    /// @param argv  the arguments to apply
    Object* apply (Runnable* robj, Nameset* nset, const long quark,
                   Vector* argv);
  };
}

#endif
