好吧,标题是满口的,我认为这可能是为什么很难通过谷歌或这个网站找到答案.可能只是因为我不知道如何正确表达问题,但这里有:
我在SimpleOpenGLRenderer
类中有一系列方法,它们都采用扩展Model
类的单个参数.因此,根据模型的类型,渲染器将调用知道如何渲染它的正确方法.以下是基于该问题的简化可执行示例:
#include <stdio.h>
class Model {};
class Cube : public Model {};
class Sphere : public Model {};
class Renderer
{
public:
virtual void renderModel(const Model& model) = 0;
};
class SimpleOpenGLRenderer
{
public:
void renderModel(const Cube& model)
{
printf("Render the cube.\n");
}
void renderModel(const Model& model)
{
printf("Throw an exception, my renderer does not support the model type you have provided.\n");
}
void renderModel(const Sphere& model)
{
printf("Render the sphere.\n");
}
};
int
main(int …
Run Code Online (Sandbox Code Playgroud) 我们有一个基于swing的前端用于企业应用程序,现在正在为它实现一个(现在更简单)JSF/Seam/Richfaces前端.
某些页面包含的字段在编辑时应导致其他字段因此而更改.我们需要立即向用户显示此更改(即他们不必按下按钮或任何其他内容).
我已成功使用h:commandButton
并通过添加onchange="submit()"
导致其他字段更改的字段来实现此功能.这样,表单提交在他们编辑字段时发生,其他字段作为结果更新.
这在功能上运行良好,但特别是当服务器处于显着负载(经常发生)时,表单提交可能需要很长时间,并且我们的用户在此期间继续编辑字段,然后在对onchange="submit()"
请求的响应时恢复渲染.
为了解决这个问题,我希望能够实现以下目标:
好吧,我认为首先展示一下我的页面可能是最容易的.请注意,这只是一个摘录,有些页面会有很多字段和许多按钮.
<a4j:form id="mainForm">
...
<a4j:commandButton id="calculateButton" value="Calculate" action="#{illustrationManager.calculatePremium()}" reRender="mainForm" />
...
<h:outputLabel for="firstName" value=" First Name" />
<h:inputText id="firstName" value="#{life.firstName}" />
...
<h:outputLabel for="age" value=" Age" />
<h:inputText id="age" value="#{life.age}">
<f:convertNumber type="number" integerOnly="true" />
<a4j:support event="onchange" ajaxSingle="true" reRender="dob" />
</h:inputText>
<h:outputLabel for="dob" value=" DOB" />
<h:inputText id="dob" value="#{life.dateOfBirth}" styleClass="date">
<f:convertDateTime pattern="dd/MM/yyyy" timeZone="#{userPreference.timeZone}" />
<a4j:support event="onchange" …
Run Code Online (Sandbox Code Playgroud) 我经常使用纯虚拟类(接口)来减少当前项目中不同类的实现之间的依赖关系.我甚至拥有层次结构并不罕见,在这些层次结构中我有纯虚拟和非纯虚拟类来扩展其他纯虚拟类.以下是这种情况的一个例子:
class Engine
{ /* Declares pure virtual methods only */ }
class RunnableEngine : public virtual Engine
{ /* Defines some of the methods declared in Engine */ }
class RenderingEngine : public virtual Engine
{ /* Declares additional pure virtual methods only */ }
class SimpleOpenGLRenderingEngine : public RunnableEngine,
public virtual RenderingEngine
{ /* Defines the methods declared in Engine and RenderingEngine (that are not
already taken care of by RunnableEngine) */ }
Run Code Online (Sandbox Code Playgroud)
双方RunnableEngine
并RenderingEngine
延长 …
我有一个代号为的程序foo
.foo
取决于common.so
并以正常方式与它相关联(抱歉,我不知道技术方式).何时foo
运行它然后bar.so
使用动态加载dlopen()
.到现在为止还挺好.
但是,bar.so
也取决于common.so
.是否会dlopen()
重新加载common.so
(从我读过的内容中递归加载任何所需的依赖项),还是会检测到它已经加载了?如果它重新加载它,是否会导致我的程序出现问题?双方foo
并bar.so
需要看到的变化common.so
,要么他们做出静态变量存在.
也许我的设计需要改变或需要使用-rdynamic
(我还不太了解)?
c++ ×3
ajax4jsf ×1
dlopen ×1
function ×1
gcc ×1
jsf ×1
overloading ×1
polymorphism ×1
pure-virtual ×1
richfaces ×1
seam ×1