State manager generic data

This is a discussion on State manager generic data within the Game Programming forums, part of the General Programming Boards category; Read: Code: /* * GameSystem.h * * Manages system states. * Copyright (C) 2006 The Elements of Form */ #pragma ...

  1. #1
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709

    State manager generic data

    Read:

    Code:
    /*
     * GameSystem.h
     *
     * Manages system states.
     * Copyright (C) 2006 The Elements of Form                                                
     */
    
    #pragma once
    #include "Singleton.h"
    
    /* FIXME: I don't really like the way this works. I have considered using 'Dators' in a similar
     * way to matey who wrote the "Enginuity" series @ GameDev. I need to be able to represent generic
     * data that the GameSystem can hold on to. unions can suck my ass.
     *
     * It's not *that* important, but it makes me feel all dirty :-(
     */
    
    // See I could have an array and use some neat const's like STATE_WINDOW_HANDLE which is
    // an index into said array.
    
    //const int STATE_WINDOW_HANDLE = 0;
    //const int STATE_GAME_INSTANCE = 1;
    
    class GameSystem :public Singleton<GameSystem>
    {
    public:
        GameSystem();
        ~GameSystem();
    
        inline void         SetWindowHandle(HWND hWnd) { m_hGameWindowHandle = hWnd; }
        inline void         SetGameInstance(HINSTANCE hInst) { m_hGameInstance = hInst; }
    
        inline HWND         GetWindowHandle() { return m_hGameWindowHandle; }
        inline HINSTANCE    GetGameInstance() { return m_hGameInstance; }
    
    private:
        HWND        m_hGameWindowHandle;
        HINSTANCE   m_hGameInstance;
    
    };
    Feedback for poor, tired me?

    Mentioned this: http://www.gamedev.net/reference/art...rticle1959.asp

    Any other suggestions?
    EDIT: In case you were wondering, "The Elements of Form" is me and my brother. We've decided to go into hobbyist game developement together

    EDIT2: Why? It makes the most sense to me to have a globally accessible singleton which keeps track of what otherwise would be global data. Horrible, global data.
    Last edited by cboard_member; 06-06-2006 at 08:51 AM.
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  2. #2
    Registered User
    Join Date
    May 2006
    Posts
    903
    Global variables are horrible only if you make horrible use of them I would let them be global. An array would be slower and you'd need to change its size everytime you add a new constant. In the worst-case scenario you could put them in a namespace to prevent yourself from messing with the global namespace but that's all I can think of.

  3. #3
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    Meh.

    I've decided to go with Dators for now. If I have any trouble with them I'll be back.
    Moaning probably

    EDIT: And Bubba, if you're out there, I need to have speaks with you about initialising D3D.
    Last edited by cboard_member; 06-06-2006 at 11:29 AM.
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  4. #4
    Registered User
    Join Date
    May 2006
    Posts
    903
    You should PM him instead. He will receive an e-mail notification.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Generic data structures
    By rzcodeman in forum C++ Programming
    Replies: 1
    Last Post: 04-25-2005, 09:58 AM
  2. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 04:00 PM
  3. Function pointer question
    By sbayeta in forum C Programming
    Replies: 9
    Last Post: 08-06-2004, 09:15 AM
  4. All u wanted to know about data types&more
    By SAMSAM in forum Windows Programming
    Replies: 6
    Last Post: 03-11-2003, 03:22 PM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 07:51 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21