本文整理汇总了C++中ObjectFactory类的典型用法代码示例。如果您正苦于以下问题:C++ ObjectFactory类的具体用法?C++ ObjectFactory怎么用?C++ ObjectFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ObjectFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: lua_getref
Object* ObjectManager::createInstance(lua_State* L, const String& className, const String& name)
{
int luaReference = ScriptManager::getSingleton().getLuaClass(className);
if (luaReference == 0)
{
throw new Ogre::Exception(0, "Lua class '" + className + "' not found", __FILE__);
}
// põe a classe da pilha
lua_getref(L, luaReference);
int idx = lua_gettop(L);
const String type(LuaHelper::getTableStringField(L, idx, "type"));
ObjectFactory* factory = this->getObjectFactory(type);
if (factory == NULL)
{
throw new Ogre::Exception(0, "no factory registered for type '" + type + "'", __FILE__);
}
Object* obj = factory->createInstance(L, luaReference, name);
obj->setClassName(className);
// register the object
objects[name] = obj;
return obj;
}
示例2: init
void SuifEnv::init() {
ObjectFactory* of = new SuifEnvObjectFactory;
set_object_factory( of );
of -> init( this );
AggregateMetaClass*
suifObjectMC = of->create_object_meta_class(
SuifObject::get_class_name(),
sizeof( SuifObject ),
SuifObject::constructorFunction,
(AggregateMetaClass*)of->lookupMetaClass( Object::get_class_name() ) );
PointerMetaClass* pointerToSuifObjectR = of->get_pointer_meta_class( suifObjectMC, false );
suifObjectMC -> add_field_description( "parent", pointerToSuifObjectR, OFFSETOF( SuifObject, parent ) );
// Brick::init_meta_class(this);
input_sub_system = new InputSubSystemDefaultImplementation( this );
output_subsystem = new OutputSubSystemDefaultImplementation( this );
cloneSubSystem = new CloneSubSystemDefaultImplementation( this );
_dll_subsystem = new DLLSubSystem( this );
_module_subsystem = new ModuleSubSystem( this );
_error_subsystem = new ErrorSubSystem( this );
_print_subsystem = new PrintSubSystem( this );
}
示例3: assert
GeometryShader::GeometryShader(const CompiledShaderByteCode& compiledShader, const StreamOutputInitializers& soInitializers)
{
if (compiledShader.GetStage() != ShaderStage::Null) {
assert(compiledShader.GetStage() == ShaderStage::Geometry);
auto byteCode = compiledShader.GetByteCode();
intrusive_ptr<ID3D::GeometryShader> underlying;
if (soInitializers._outputBufferCount == 0) {
underlying = ObjectFactory().CreateGeometryShader(byteCode.first, byteCode.second);
} else {
assert(soInitializers._outputBufferCount <= D3D11_SO_BUFFER_SLOT_COUNT);
D3D11_SO_DECLARATION_ENTRY nativeDeclaration[D3D11_SO_STREAM_COUNT * D3D11_SO_OUTPUT_COMPONENT_COUNT];
auto delcCount = BuildNativeDeclaration(nativeDeclaration, dimof(nativeDeclaration), soInitializers);
ObjectFactory objFactory;
auto featureLevel = objFactory.GetUnderlying()->GetFeatureLevel();
underlying = objFactory.CreateGeometryShaderWithStreamOutput(
byteCode.first, byteCode.second,
nativeDeclaration, delcCount,
soInitializers._outputBufferStrides, soInitializers._outputBufferCount,
// Note -- "NO_RASTERIZED_STREAM" is only supported on feature level 11. For other feature levels
// we must disable the rasterization step some other way
(featureLevel>=D3D_FEATURE_LEVEL_11_0)?D3D11_SO_NO_RASTERIZED_STREAM:0);
}
_underlying = std::move(underlying);
}
}
示例4: v
void Display::displayRequirements(CmdParser c)
{
try
{
Verbose v(true);
Verbose::show("******** REQUIREMENT 4 ********");
Verbose::show("Refer to files Message.h and Message.cpp\n");
Verbose::show("******** REQUIREMENT 6 ********");
Verbose::show("Refer to files Communiation.h and Communication.cpp\n");
Verbose::show("******** REQUIREMENT 8 ********");
Verbose::show("Refer to files Executive.h, Display.h, Display.cpp and Executive.cpp\n");
Verbose::show("******** DEMONSTRATING REQUIREMENT 3, 5 & 7 ********\n");
ObjectFactory of;
IRecvr *recv = of.createRecvr(stoi(c.getSelfPortNo()));
ISendr *sender = of.createSendr();
IMessage *msg = of.createMessage();
Peer *peer_ = new Peer(sender,recv,msg);
peer_->start();
std::cout.flush();
Verbose::show("\n\n Press Enter to Exit.");
std::cin.get();
peer_->stop();
}
catch (exception ex)
{
string s = ex.what();
Verbose::show("Exception thrown: "+s);
}
}
示例5: DoInstall
EnergySourceContainer
EnergySourceHelper::Install (NodeContainer c) const
{
EnergySourceContainer container;
for (NodeContainer::Iterator i = c.Begin (); i != c.End (); ++i)
{
Ptr<EnergySource> src = DoInstall (*i);
container.Add (src);
/*
* Check if EnergySourceContainer is already aggregated to target node. If
* not, create a new EnergySourceContainer and aggregate it to node.
*/
Ptr<EnergySourceContainer> EnergySourceContrainerOnNode =
(*i)->GetObject<EnergySourceContainer> ();
if (EnergySourceContrainerOnNode == NULL)
{
ObjectFactory fac;
fac.SetTypeId ("ns3::EnergySourceContainer");
EnergySourceContrainerOnNode = fac.Create<EnergySourceContainer> ();
EnergySourceContrainerOnNode->Add (src);
(*i)->AggregateObject (EnergySourceContrainerOnNode);
}
else
{
EnergySourceContrainerOnNode->Add (src); // append new EnergySource
}
}
return container;
}
示例6: while
bool ObjectManager::frameEnded(const Ogre::FrameEvent& evt)
{
// Step the world and then synchronise the scene nodes with it,
// we could get this to do this automatically, but we
// can't be sure of what order the frame listeners will fire in
if (mStepper->step(evt.timeSinceLastFrame))
{
std::vector<Object*>::iterator eraseIter = eraseQueue.begin();
while (eraseIter != eraseQueue.end())
{
ObjectFactory* factory = this->getObjectFactory((*eraseIter)->getTypeName());
assert(factory != NULL);
factory->destroyInstance(*eraseIter);
eraseIter++;
}
eraseQueue.clear();
mWorld->synchronise();
std::map<std::string, Object*>::iterator iter = objects.begin();
while (iter != objects.end())
{
if (iter->second != NULL)
{
iter->second->update(evt.timeSinceLastFrame);
}
iter++;
}
}
return true;
}
示例7: TestObjectSerialization3
void TestObjectSerialization3()
{
ObjectFactory<Serializable> factory;
//factory.Register("ObjectA", new ObjectCreator<ObjectA, Serializable>());
factory.Register("ObjectD", new ObjectCreator<ObjectD, Serializable>());
ObjectD d = ObjectD();
d.Set(6, 7, 8, "ObjectD baby");
d.AccessA().Set(1, 2, 3, "ObjectA baby");
BinaryFileStream stream;
stream.StartWrite("test3.txt");
d.Save(stream);
stream.SerializeQueue();
stream.Close();
std::vector<Serializable *> load;
stream.StartRead("test3.txt", factory);
ObjectD * loaded = stream.GetNext<ObjectD*>();
stream.Close();
loaded->Print();
delete loaded;
}
示例8: freePlugIn
void freePlugIn(ExecutableAgent* pPlugin)
{
ObjectFactory* pFact = Service<ApplicationServices>()->getObjectFactory();
if (pFact != NULL)
{
pFact->destroyObject(pPlugin, TypeConverter::toString<ExecutableAgent>());
}
}
示例9: freeWizard
void freeWizard(WizardObject* pWizard)
{
ObjectFactory* pFact = Service<ApplicationServices>()->getObjectFactory();
if (pFact != NULL)
{
pFact->destroyObject(pWizard, TypeConverter::toString<WizardObject>());
}
}
示例10: ctkAbstractLibraryFactoryTest1
//-----------------------------------------------------------------------------
int ctkAbstractLibraryFactoryTest1(int argc, char * argv [] )
{
QApplication app(argc, argv);
ObjectFactory factory;
factory.registerItems();
return EXIT_SUCCESS;
}
示例11: CreateObjectFactory
ObjectFactory * CreateObjectFactory()
{
ObjectFactory * factory = new ObjectFactory();
factory->RegisterObject(new WallObject());
factory->RegisterObject(new HeatObject());
factory->RegisterObject(new WindowObject());
factory->RegisterObject(new Probe());
factory->RegisterObject(new StoneWallObject());
return factory;
}
示例12: Uninitialize
void Uninitialize()
{
ObjectFactory *instance = ObjectFactory::getInstance();
if (instance == NULL)
{
VMF_EXCEPTION(InternalErrorException, "Can't get Object factory instance");
}
std::shared_ptr<IDataSourceFactory> emptyDataSourceFactoryPtr;
instance->setDataSourceFactory(emptyDataSourceFactoryPtr);
}
示例13: TestObjectSerialization
void TestObjectSerialization()
{
ObjectFactory<Serializable> factory;
factory.Register("ObjectA", new ObjectCreator<ObjectA, Serializable>());
factory.Register("ObjectB", new ObjectCreator<ObjectB, Serializable>());
factory.Register("ObjectC", new ObjectCreator<ObjectC, Serializable>());
factory.Register("STLVectorObjectIO", new ObjectCreator<STLVectorObjectIO<ObjectA>, Serializable>());
ObjectA a = ObjectA();
a.Set(1, 2, 3, "ObjectA baby");
ObjectB b = ObjectB();
b.Set(6, 7, 8, "ObjectB baby");
ObjectC c = ObjectC();
c.Set(3, 4, 5, "ObjectC baby");
b.data4 = &c;
c.data4 = &b;
BinaryFileStream stream;
stream.StartWrite("test.txt");
a.Save(stream);
b.Save(stream);
//c.Save(stream, true);
stream.SerializeQueue();
stream.Close();
std::vector<Serializable *> load;
stream.StartRead("test.txt", factory);
//stream.LoadObjects(factory);
ObjectA * loaded_a = stream.GetNext<ObjectA*>();
ObjectB * loaded_b = stream.GetNext<ObjectB*>();
ObjectC * loaded_c = stream.GetNext<ObjectC*>();
stream.Close();
loaded_a->Print();
loaded_b->Print();
loaded_c->Print();
delete loaded_a;
delete loaded_b;
delete loaded_c;
}
示例14: Initialize
void Initialize(std::shared_ptr<IDataSourceFactory> &dataSourceFactory)
{
if (!dataSourceFactory)
{
VMF_EXCEPTION(IncorrectParamException, "Unable to initialize by empty DataSourceFactory instance");
}
ObjectFactory *instance = ObjectFactory::getInstance();
if (instance == NULL)
{
VMF_EXCEPTION(InternalErrorException, "Can't get Object factory instance");
}
instance->setDataSourceFactory(dataSourceFactory);
}
示例15: CancelEventHandler
WPFCppCliDemo::WPFCppCliDemo()
{
// set up channel
ObjectFactory* pObjFact = new ObjectFactory;
pSendr_ = pObjFact->createSendr();
pRecvr_ = pObjFact->createRecvr();
pChann_ = pObjFact->createMockChannel(pSendr_, pRecvr_);
pChann_->start();
delete pObjFact;
// client's receive thread
recvThread = gcnew Thread(gcnew ThreadStart(this, &WPFCppCliDemo::getMessage));
recvThread->Start();
// set event handlers
this->Loaded +=
gcnew System::Windows::RoutedEventHandler(this, &WPFCppCliDemo::OnLoaded);
this->Closing +=
gcnew CancelEventHandler(this, &WPFCppCliDemo::Unloading);
hSendButton->Click += gcnew RoutedEventHandler(this, &WPFCppCliDemo::sendMessage);
hClearButton->Click += gcnew RoutedEventHandler(this, &WPFCppCliDemo::clear);
hFolderBrowseButton->Click += gcnew RoutedEventHandler(this, &WPFCppCliDemo::browseForFolder);
hConnectButton->Click += gcnew RoutedEventHandler(this, &WPFCppCliDemo::connect);
hUploadBrowseButton->Click += gcnew RoutedEventHandler(this, &WPFCppCliDemo::uploadBrowseFolder);
hUploadFileButton->Click += gcnew RoutedEventHandler(this, &WPFCppCliDemo::uploadFile);
hDownloadBrowseButton->Click += gcnew RoutedEventHandler(this, &WPFCppCliDemo::downloadBrowseFolder);
hDownloadFileButton->Click += gcnew RoutedEventHandler(this, &WPFCppCliDemo::downloadFile);
hTextSearchButton->Click += gcnew RoutedEventHandler(this, &WPFCppCliDemo::textSearch);
// set Window properties
this->Title = "WPF C++/CLI Demo";
this->Width = 800;
this->Height = 600;
// attach dock panel to Window
this->Content = hDockPanel;
hDockPanel->Children->Add(hStatusBar);
hDockPanel->SetDock(hStatusBar, Dock::Bottom);
hDockPanel->Children->Add(hGrid);
// setup Window controls and views
setUpTabControl();
setUpStatusBar();
setUpSendMessageView();
setUpConnectionView();
setUpFileUploadView();
setUpFileDownloadView();
setUpTextSearchView();
setUpFileSearchView();
}