//------------------------------------------------------------------------------
// Lamp : Open source game middleware
// Copyright (C) 2004  Junpei Ohtani ( Email : junpee@users.sourceforge.jp )
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library 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
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//------------------------------------------------------------------------------

/** @file
 * 参照付き静的名前ヘッダ
 * @author Junpee
 */

#ifndef REFERENCED_STATIC_NAME_H_
#define REFERENCED_STATIC_NAME_H_

#include <Core/BasicObject/StaticName.h>

namespace Lamp{

//------------------------------------------------------------------------------
/**
 * 参照付き静的名前
 */
class ReferencedStaticName : public StaticName{
public:
	/**
	 * コンストラクタ
	 * @param name 初期化する名前
	 */
	ReferencedStaticName(const String& name) :
		StaticName(name), referenceCount_(0){}

	/**
	 * デストラクタ
	 */
	virtual ~ReferencedStaticName(){ Assert(referenceCount_ == 0); }

	//--------------------------------------------------------------------------
	/**
	 * 参照の追加
	 * @return 参照カウント
	 */
	virtual int addReference(){
		referenceCount_++;
		return referenceCount_;
	}

	/**
	 * 参照の削除
	 * @return 参照カウント
	 */
	virtual int removeReference(){
		referenceCount_--;
		Assert(referenceCount_ >= 0);
		return referenceCount_;
	}

	/**
	 * 参照カウントの取得
	 */
	virtual int getReferenceCount() const{ return referenceCount_; }

private:
	//--------------------------------------------------------------------------
	// 参照カウント
	int referenceCount_;

};

//------------------------------------------------------------------------------
} // End of namespace Lamp
#endif // End of REFERENCED_STATIC_NAME_H_
//------------------------------------------------------------------------------
