我目前正在我的游戏和渲染引擎之间编写一个抽象层.不幸的是,我遇到了一个问题:我似乎无法将超类(抽象接口)强制转换为子类(具体引擎的实现).这是我的代码:
IInitationSettings.h
class IInitationSettings {};
Run Code Online (Sandbox Code Playgroud)
OxygineInitiationSettings.h
#include "IInitiationSettings.h"
#include "core/oxygine.h"
class OxygineInitiationSettings : public IInitationSettings, public oxygine::core::init_desc {
public:
OxygineInitiationSettings(const char* title, bool vsync, bool fullscreen, int width, int height);
};
Run Code Online (Sandbox Code Playgroud)
OxygineInitiationSettings.cpp
#include "OxygineInitiationSettings.h"
OxygineInitiationSettings::OxygineInitiationSettings(const char* title, bool vsync, bool fullscreen, int width, int height) : oxygine::core::init_desc() {
this->title = title;
this->vsync = vsync;
this->fullscreen = fullscreen;
this->w = width;
this->h = height;
}
Run Code Online (Sandbox Code Playgroud)
抽象的init方法:
static void init(IInitiationSettings& initSettings);
void GraphicsFactory::init(IInitiationSettings& initSettings){
#ifdef USE_OXYGINE_RENDERING
OxygineInitiationSettings settings = initSettings; //Does not …
Run Code Online (Sandbox Code Playgroud) 在我目前的项目中,我使用javascripts localStorage来存储一些数据.由于此数据之后被解析,我需要将其设置为默认值(如果尚未存在).为此,我使用简单的if-check:不幸的是,它不起作用.这是我的代码:
localStorage.setItem("myItem", null); //Test for the if-check. But even without it isnt working.
if(localStorage.getItem("myItem") == undefined || localStorage.getItem("myItem") == null || localStorage.getItem("myItem") == ""){
console.log("is null");
localStorage.setItem("myItem", "myDefaultContent");
}
console.log(localStorage.getItem("myItem")); //null!
Run Code Online (Sandbox Code Playgroud)
我怎么解决这个问题?
我听说手动选择colums更快("col1,col2,col3等"),而不是用"*"查询它们.
但是如果我甚至不想查询表的所有列呢?查询是否更快,例如,"col1,col2,col3,col4"的"col1,col2"insteaf?
根据我的理解,SQL必须搜索所有列,只返回结果更改.我想知道我是否可以通过选择合适的列来获得性能提升.
(无论如何,我正在这样做,但我的一个应用程序的后端API返回的频率高于非所有列,因此我正在考虑让用户手动选择他想要的列)
abstraction ×1
c++ ×1
if-statement ×1
inheritance ×1
javascript ×1
mysql ×1
null ×1
performance ×1
rendering ×1
select ×1
sql ×1