SDXFrameWork  0.13
SDXFrameWork
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
Public Member Functions | List of all members
SDX::EnumArray< TType, TEnum > Class Template Reference

列挙型を直接添字に使える配列. More...

#include <EnumArray.h>

Public Member Functions

size_t size () const
 要素数を取得. More...
 
TType & operator[] (const TEnum index)
 []のオペレータ. More...
 
const TType & operator[] (const TEnum index) const
 []のオペレータ. More...
 
auto begin () -> decltype(Array.begin())
 範囲for用. More...
 
auto end () -> decltype(Array.end())
 範囲for用. More...
 
auto begin () const -> decltype(Array.begin())
 範囲for用. More...
 
auto end () const -> decltype(Array.end())
 範囲for用. More...
 

Detailed Description

template<class TType, class TEnum>
class SDX::EnumArray< TType, TEnum >

列挙型を直接添字に使える配列.

//Copyright © 2014 SDXFramework
//[License]GNU Affero General Public License, version 3
//[Contact]http://sourceforge.jp/projects/dxframework/
//EnumArrayの使用例
bool SampleEnumArray()
{
using namespace SDX;
System::Initialise("sample", 640, 480);//ウィンドウタイトルを指定して、初期化する
enum class ANIMAL
{
ねずみ,
ひよこ,
くま,
にわとり,
COUNT,
};
画像[ANIMAL::ねずみ].Load("data/pipo-enemy034.png");
画像[ANIMAL::ひよこ].Load("data/pipo-enemy035.png");
画像[ANIMAL::にわとり].Load("data/pipo-enemy036.png");
画像[ANIMAL::くま].Load("data/pipo-enemy037.png");
ANIMAL type = ANIMAL::ねずみ;
while (System::Update())//ウィンドウの更新や、入力の更新等を行う
{
画像[type].Draw({ 300, 200 });
if (Input::key._1.on) type = ANIMAL::ねずみ;
if (Input::key._2.on) type = ANIMAL::ひよこ;
if (Input::key._3.on) type = ANIMAL::にわとり;
if (Input::key._4.on) type = ANIMAL::くま;
if (Input::key.Return.on){ break;}//Enterで終了
}
System::End();//ライブラリの終了処理を行う
return true;
}
Todo:
エラー処理など未実装

Member Function Documentation

template<class TType, class TEnum>
size_t SDX::EnumArray< TType, TEnum >::size ( ) const
inline

要素数を取得.

template<class TType, class TEnum>
TType& SDX::EnumArray< TType, TEnum >::operator[] ( const TEnum  index)
inline

[]のオペレータ.

template<class TType, class TEnum>
const TType& SDX::EnumArray< TType, TEnum >::operator[] ( const TEnum  index) const
inline

[]のオペレータ.

template<class TType, class TEnum>
auto SDX::EnumArray< TType, TEnum >::begin ( ) -> decltype(Array.begin())
inline

範囲for用.

template<class TType, class TEnum>
auto SDX::EnumArray< TType, TEnum >::end ( ) -> decltype(Array.end())
inline

範囲for用.

template<class TType, class TEnum>
auto SDX::EnumArray< TType, TEnum >::begin ( ) const -> decltype(Array.begin())
inline

範囲for用.

template<class TType, class TEnum>
auto SDX::EnumArray< TType, TEnum >::end ( ) const -> decltype(Array.end())
inline

範囲for用.