/* Network-Integrated Multimedia Middleware (NMM)
 * http://www.motama.com/nmm.html
 *  
 * Copyright (C) 2006-2007
 * Motama GmbH, Saarbruecken, Germany
 * http://www.motama.com
 *  
 * This file is part of NMM. 
 * 
 * NMM is free software; you can redistribute it and/or modify it    
 * under the terms of the GNU General Public License as published by 
 * the Free Software Foundation; only version 2 of the License.      
 * 
 * NMM 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. See the GNU General Public 
 * License for more details.  
 * 
 * You should have received a copy of the GNU General Public License 
 * along with NMM; if not, write to the Free Software Foundation,    
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 */

#ifndef NMM_PROCESS_USER_INFO_HPP
#define NMM_PROCESS_USER_INFO_HPP NMM_PROCESS_USER_INFO_HPP

#include "nmm/nmm_prefix.hpp"

#include "nmm/utils/Singleton.hpp"

#include <string>

#include "visibility.hpp"

namespace NMM {
  
  /** This singleton class stores the UserInfo for this process.
   */
  class DLLEXPORT ProcessUserInfo {
	DECLARE_SINGLETON(ProcessUserInfo, CreateUsingNew, DefaultLifetime, MultiThreaded);
  public:
    /** @name Access Methods
     */
    //@{
    /** This method returns the home directory of a user running this process.
     *
     * To determin the home directory the environment variable home is read.
     * If it is not set the home directory is set to /home/username/. If the
     * username is root, it is set to /root/ 
     *
     * @return home directory
     */
    inline const std::string& getHomeDirectory() const { return __home_directory; }
    
    /** This method returns the username of the user running this process.
     *
     * @return username
     */
    inline const std::string& getUsername()   const { return __username; }

    /** This method returns the hostname of the host this process runs on.
     * 
     * @return hostname
     */
    inline const std::string& getHostname()   const { return __hostname; }
    
    /** This method returns the domainname of the host this process runs on.
     *
     * @return domainname
     */
    inline const std::string& getDomainname() const { return __domainname; }
    
    /** This method returns the PID of this process.
     *
     * @return PID
     */
    inline int           getPid()        const { return __pid; }
    //@}
    
  private:
    friend class CreateUsingNew<ProcessUserInfo>;
    
    /** @name Constructor & Destructor
     */
    //@{
    /** Constructor.
     */
    ProcessUserInfo();

    /** Destructor.
     */
    ~ProcessUserInfo();
    //@}
    
  private:
    std::string __username;    ///< Username of user running this process
    std::string __hostname;    ///< Hostname of host this process runs on
    std::string __domainname;  ///< Domainname of host this process runs on
    int   __pid;               ///< PID of this process
    std::string __home_directory;    ///< home direcotry of the user
  };
  
  /** Singleton class for ProcessUserInfo
   */
  typedef ProcessUserInfo::Singleton SProcessUserInfo;
  
}

#include "nmm/nmm_suffix.hpp"

#endif
