-
Notifications
You must be signed in to change notification settings - Fork 5
Coding style
kochol edited this page May 14, 2012
·
1 revision
This page describes KGE coding style that every developers have to know these rules and obey them.
Use const keyword right.For more info about const read this or this
You have to use KGE_NEW and KGE_DELETE macros instead of new and delete. When you use these macros KGE can track memory for memory leakage and it uses nedmalloc to allocate memory which is very faster than normal new and delete.int main() { kge::io::Logger log; test* t = KGE_NEW(test)(5); test* r = KGE_NEW(test)(57); KGE_DELETE(t, test); KGE_DELETE(r, test); getchar(); return 0; }use ProtoTyping of classes whenever is possible Don't include them use ProtoTyping instead. See io::Window class in this sample.
#ifndef KGE_DEVICE_H #define KGE_DEVICE_H #include "kgedef.h" namespace kge { namespace io { class Window; } class KGE_API Device { public: //! Constructor Device(); //! Destructor ~Device(); //! Returns the Device object pointer. static Device* GetSingletonPtr(); /** Initialize KGE with given parameters. return: Returns true on success param params: Initialize parameters */ bool Init(InitParameters params); //! Run the KGE bool Run(); protected: io::Window * m_pWindow; }; // Device } // kge #endif // KGE_DEVICE_H
namespace kge { //------------------------------------------------------------------------------------ // Constructor //------------------------------------------------------------------------------------ Device::Device() { } // Constructor //------------------------------------------------------------------------------------ // Destructor //------------------------------------------------------------------------------------ Device::~Device() { } // Destructor //------------------------------------------------------------------------------------ // Returns the Device object pointer. //------------------------------------------------------------------------------------ Device* Device::GetSingletonPtr() { static Device me; return &me; } // GetSingletonPtr //------------------------------------------------------------------------------------ // Initialize KGE with given parameters //------------------------------------------------------------------------------------ bool Device::Init(InitParameters params) { return false; } // Init //------------------------------------------------------------------------------------ // Run the KGE //------------------------------------------------------------------------------------ bool Device::Run() { return false; } // Run } // kge