void RenderBackend::ResumeRender(POVMS_Message& msg, POVMS_Message& result, int) { if(ValidateFrontendAddress(msg.GetSourceAddress(), result) == false) return; try { ViewId vid = msg.GetInt(kPOVAttrib_ViewId); ViewMap::iterator i(views.find(vid)); if(i == views.end()) throw POV_EXCEPTION_CODE(kInvalidIdentifierErr); if((i->second->IsRendering() == false) && (i->second->IsPaused() == false)) throw POV_EXCEPTION_CODE(kNotNowErr); i->second->ResumeRender(); MakeDoneResult(result); } catch(pov_base::Exception& e) { MakeFailedResult(e, result); } catch(std::runtime_error& e) { MakeFailedResult(e.what(), result); } catch(std::bad_alloc&) { MakeFailedResult(kOutOfMemoryErr, result); } }
void RenderBackend::CloseView(POVMS_Message& msg, POVMS_Message& result, int) { if(ValidateFrontendAddress(msg.GetSourceAddress(), result) == false) return; try { ViewId vid = msg.GetInt(kPOVAttrib_ViewId); ViewMap::iterator i(views.find(vid)); if(i == views.end()) throw POV_EXCEPTION_CODE(kInvalidIdentifierErr); try { views.erase(vid); } catch(pov_base::Exception&) { } try { scene2views[view2scene[vid]].erase(vid); } catch(pov_base::Exception&) { } try { view2scene.erase(vid); } catch(pov_base::Exception&) { } MakeDoneResult(result); } catch(pov_base::Exception& e) { MakeFailedResult(e, result); } catch(std::runtime_error& e) { MakeFailedResult(e.what(), result); } catch(std::bad_alloc&) { MakeFailedResult(kOutOfMemoryErr, result); } }
void RenderBackend::CloseScene(POVMS_Message& msg, POVMS_Message& result, int) { if(ValidateFrontendAddress(msg.GetSourceAddress(), result) == false) return; try { SceneId sid = msg.GetInt(kPOVAttrib_SceneId); SceneMap::iterator i(scenes.find(sid)); if(i == scenes.end()) throw POV_EXCEPTION_CODE(kInvalidIdentifierErr); if(scene2views[sid].size() > 0) throw POV_EXCEPTION_CODE(kNotNowErr); try { scenes.erase(sid); } catch(pov_base::Exception&) { } try { scene2views.erase(sid); } catch(pov_base::Exception&) { } MakeDoneResult(result); } catch(pov_base::Exception& e) { MakeFailedResult(e, result); } catch(std::runtime_error& e) { MakeFailedResult(e.what(), result); } catch(std::bad_alloc&) { MakeFailedResult(kOutOfMemoryErr, result); } }
void RenderBackend::StartRender(POVMS_Message& msg, POVMS_Message&, int) { try { ViewId vid = msg.GetInt(kPOVAttrib_ViewId); try { if(validateFrontendAddress(msg.GetSourceAddress()) == false) throw POV_EXCEPTION_CODE(kAuthorisationErr); ViewMap::iterator i(views.find(vid)); if(i == views.end()) throw POV_EXCEPTION_CODE(kInvalidIdentifierErr); if(i->second->IsRendering() == true) throw POV_EXCEPTION_CODE(kNotNowErr); i->second->StartRender(msg); } catch(pov_base::Exception& e) { SendViewFailedResult(vid, e, msg.GetSourceAddress()); } } catch(pov_base::Exception& e) { SendFailedResult(e, msg.GetSourceAddress()); } catch(std::runtime_error& e) { SendFailedResult(e.what(), msg.GetSourceAddress()); } catch(std::bad_alloc&) { SendFailedResult(kOutOfMemoryErr, msg.GetSourceAddress()); } }
void RenderBackend::CreateView(POVMS_Message& msg, POVMS_Message& result, int) { if(ValidateFrontendAddress(msg.GetSourceAddress(), result) == false) return; try { SceneId sid = msg.GetInt(kPOVAttrib_SceneId); SceneMap::iterator i(scenes.find(sid)); if(i == scenes.end()) throw POV_EXCEPTION_CODE(kInvalidIdentifierErr); shared_ptr<View> view(i->second->NewView(msg.TryGetInt(kPOVAttrib_Width, 160), msg.TryGetInt(kPOVAttrib_Height, 120), viewcounter + 1)); viewcounter++; POVMS_Message newresult(result, result.GetClass(), kPOVMsgIdent_Done); result = newresult; result.SetInt(kPOVAttrib_ViewId, viewcounter); views[viewcounter] = view; try { view2scene[viewcounter] = sid; } catch(std::exception&) { views.erase(viewcounter); throw; } try { scene2views[sid].insert(viewcounter); } catch(std::exception&) { views.erase(viewcounter); view2scene.erase(viewcounter); throw; } } catch(pov_base::Exception& e) { MakeFailedResult(e, result); } catch(std::runtime_error& e) { MakeFailedResult(e.what(), result); } catch(std::bad_alloc&) { MakeFailedResult(kOutOfMemoryErr, result); } }
void RenderBackend::StartParser(POVMS_Message& msg, POVMS_Message&, int) { try { SceneId sid = msg.GetInt(kPOVAttrib_SceneId); try { if(validateFrontendAddress(msg.GetSourceAddress()) == false) throw POV_EXCEPTION_CODE(kAuthorisationErr); SceneMap::iterator i(scenes.find(sid)); if(i == scenes.end()) throw POV_EXCEPTION_CODE(kInvalidIdentifierErr); i->second->StartParser(msg); } catch(pov_base::Exception& e) { SendSceneFailedResult(sid, e, msg.GetSourceAddress()); } } catch(pov_base::Exception& e) { SendFailedResult(e, msg.GetSourceAddress()); } catch(std::runtime_error& e) { SendFailedResult(e.what(), msg.GetSourceAddress()); } catch(std::bad_alloc&) { SendFailedResult(kOutOfMemoryErr, msg.GetSourceAddress()); } }