Last active
January 31, 2020 15:53
-
-
Save javedulu/2d16f049bc104b5a100f0afda92b5ed3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <cstdio> | |
#include <memory> | |
namespace Raygen | |
{ | |
class Object | |
{ | |
public: | |
virtual ~Object() = default; | |
virtual void retain() = 0; | |
virtual void release() = 0; | |
}; | |
class Model : public virtual Object | |
{ | |
public: | |
virtual void init() = 0; | |
virtual void run() = 0; | |
protected: | |
Model() = default; | |
Model(const Model&) = delete; | |
public: | |
virtual ~Model() = default; | |
}; | |
typedef std::shared_ptr<Model> ModelPtr; | |
} | |
namespace Raygen | |
{ | |
namespace Impl | |
{ | |
class Object : public virtual Raygen::Object | |
{ | |
public: | |
Object() | |
{ | |
this->refCount = 1; | |
} | |
virtual ~Object() = default; | |
void retain() override | |
{ | |
++this->refCount; | |
} | |
void release() override | |
{ | |
if (--this->refCount <= 0) | |
delete this; | |
} | |
private: | |
int64_t refCount = 0; | |
}; | |
class Model : public virtual Raygen::Impl::Object, public Raygen::Model | |
{ | |
public: | |
void virtual loadModel(std::string filepath) final ; | |
}; | |
} | |
namespace Optix | |
{ | |
class Model : public virtual Raygen::Impl::Model | |
{ | |
public: | |
Model(); | |
~Model(); | |
public: | |
void init() override; | |
void run() override; | |
public: | |
void precommit(); | |
}; | |
} | |
} | |
namespace Raygen | |
{ | |
namespace Impl | |
{ | |
void Model::loadModel(std::string filename) | |
{ | |
std::cout<<"Loading FBX model file in Implementation -> Should be common for all ENGINES .. "<<filename.c_str()<<std::endl; | |
} | |
} | |
namespace Optix | |
{ | |
Model::Model() | |
{ | |
std::cout<<" Calling Model Constructor from Implementation .."<<std::endl; | |
} | |
Model::~Model() | |
{ | |
std::cout<<" Calling Model Destructor from Implementation .."<<std::endl; | |
} | |
void Model::init() | |
{ | |
loadModel("FILEPATH .. "); | |
std::cout<<" Calling Init from Implementation .."<<std::endl; | |
} | |
void Model::run() | |
{ | |
std::cout<<" Calling Run from Implementation .."<<std::endl; | |
} | |
void Model::precommit() | |
{ | |
std::cout<<" Calling (Protected) Pre-Commit from Implementation .."<<std::endl; | |
} | |
} | |
} | |
Raygen::ModelPtr CreateModel() | |
{ | |
return std::make_shared<Raygen::Optix::Model>(); | |
} | |
int main(int argc , char **argv) | |
{ | |
std::cout<<"Inheritence Test .. "<<std::endl; | |
//std::shared_ptr<Raygen::Model> m = std::make_shared<Raygen::Optix::Model>(); | |
Raygen::ModelPtr m = CreateModel(); | |
m->retain(); | |
m->init(); | |
m->run(); | |
std::dynamic_pointer_cast<Raygen::Optix::Model>(m)->precommit(); | |
m->release(); | |
return 0; | |
} |
Its confusing with Engine, renaming back to engine implementation Optix
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Inheritence model based on NVIDIA/VisRTX ..