VISH
0.2
|
Generic base class for all VObjects. More...
#include </home/werner/origo/vish/ocean/plankton/VObject.hpp>
output objects.
An VObject may serve as input parameter of another VObject; if so, the VObject serves as a VParameter of certain type. Even more, a VObject may incorporate multiple types, and even many types of the same kind which are distinguished by a textual description name.
Use function iterateOutputs() to query information on which types are supported under which names. Function implements() is a simpler, limited but equivalent shortcut function. A certain parameter can be retrieved via the getImplementation() function.
Generic base class for all VObjects.
The relationships among VObjects, VRenderObjects and VInputs are as follows:
Use VObject::iterateInputs(VCreatorIterator&) to iterate through all VObject's.
Input parameters are ordered in a hierarchy of two levels. These two levels are parameterized by an integer (called the "expert level") and a textual description.
typedef void Wizt::VObject::AcceptableInputTypes |
Each VObject may define a set of possible input types, which are types that are provided by some other objects to be used as inputs of this object.
The default is void, meaning this object will not require any input types, thus being a data source.
Multiple types may be defined by creating a type list via META::LIST, for instance:
using namespace META; typedef LIST<int, LIST<float> > AcceptableInputTypes;
This input type will allow to use int's and float's .
Reimplemented in Wizt::MovieRecorder.
Parameter types for the help() function which may provide information about the current object.
Wizt::VObject::VObject | ( | const string & | name, |
int | p, | ||
const RefPtr< VCreationPreferences > & | VP | ||
) |
VAcceptInfoList_t Wizt::VObject::accept | ( | const RefPtr< VObject > & | vobj | ) | [static] |
bool Wizt::VObject::AddAction | ( | const Slot & | ActionSlot, |
bool(DerivedObject::*)(const RefPtr< VValueBase > &value) | Action | ||
) | [inline] |
Connect the change of a parameter with the invocation of an object's member function.
We assume that this is a member function of the derived VObject and it belongs to the same object. Otherwise, we will get a very cryptic error message here.
Slot Wizt::VObject::addFloatParam | ( | double | init, |
const ParameterID & | param, | ||
double | min, | ||
double | max, | ||
const RefPtr< VCreationPreferences > & | IP = NullPtr() , |
||
int | expertLevel = 0 |
||
) | [inline] |
Shortcut function to add a floating point parameter.
This is a convenience function.
Slot Wizt::VObject::addParam | ( | const ParameterID & | name, |
const Type & | init, | ||
const RefPtr< VCreationPreferences > & | VP = NullPtr() , |
||
int | expertLevel = 0 , |
||
bool | overwriteExistingSlot = true |
||
) | [inline] |
Add an input parameter to the VObject.
The parameter is initialized with a default value via class VValueParameter.
name | Parameter name. It will be used to reference the parameter through the current object under this name. It will also be created as a global identifier for parameters, as provided by CreateParameterName(). This global name will be unique as long as this (virtual) function returns a unique name. This is true by default, as it involves this object's name, which is unique by construction of the object creation process in the VCreator<>'s. |
init | Initialization value (ONLY used for initialization!) |
IP | Desired input properties |
expertLevel | Visibility of this parameter |
Return | a reference to the newly created parameter. It provides an exclusive local storage place for the parameter's value, which is changed on any modification of possible parameter implementations. |
RefPtr< VSlot > Wizt::VObject::addParameter | ( | const ParameterID & | name, |
int | EL, | ||
const RefPtr< VParameter > & | param, | ||
bool | overwriteExistingSlot | ||
) |
Specify a parameter (type) as input for this VObject.
The parameter may be initialized with a default value. Its implementation may changed any time.
name | The name of this parameter in the context of this VObject. |
EL | The expert level of this parameter, determining its visibility in a GUI |
param | The type of this parameter and its default value |
overwriteExistingSlot | Specify if an existing slot should be overwritten by this operation or not. |
bool Wizt::VObject::allowParameterReplacement | ( | const RefPtr< VParameter > & | NewParam, |
const RefPtr< VParameter > & | OldParam, | ||
const string & | localName, | ||
int | ExpertLevel | ||
) | [virtual] |
Virtual callback function invoked by replaceParameter() when the implementation of a parameter is changed by another one.
This function enables child classes to keep track of VParameters, e.g. to adjust a locally stored VParameter pointer to refer to a new implementation instead of an old one. This is not required when parameters are always accessed through the getParameter() interface, but since getParameter() requires a table lookup, it might me (slightly) less performant than storing a local copy.
NewParam | The new parameter instance |
OldParam | The old parameter instance, which will be destroyed shortly after this function call if not referenced by other means than through the current VObject's internals. |
localName | The local name under which this parameter appears; this is unchanged |
ExpertLevel | The associated ExpertLevel |
VObject::AttachErrorCode Wizt::VObject::attach | ( | const ParameterID & | whichone, |
VObject & | sourceObject, | ||
const ParameterID & | sourceName | ||
) |
Share a parameter with another one.
The current parameter input implementation is destroyed.
VObject::AttachErrorCode Wizt::VObject::attach | ( | const RefPtr< VParameter > & | OldParam, |
const RefPtr< VParameter > & | NewParam, | ||
const string & | Member = "" |
||
) |
Replace a given parameter of the current object with another parameter.
OldParam | The old parameter, which is currently an input to this object. |
NewParam | The new parameter, which may be newly created, part of another object's input or output, or even already belong to this object itself. |
Member | An optional member of this parameter in case its type is a compound type |
const char * Wizt::VObject::AttachErrorCodeMessage | ( | AttachErrorCode | AEC | ) | [static] |
VObject::AttachErrorCode Wizt::VObject::attachNewObject | ( | const RefPtr< VSlot > & | slot, |
const string & | name, | ||
const Intercube & | CreationContext, | ||
const RefPtr< VCreationPreferences > & | VCP = NullPtr() |
||
) |
Create a new object with the type of the specified slot, whatever that is, but using the creation preferences.
CreationContext | context information for this call. |
AttachErrorCode Wizt::VObject::attachNewObject | ( | const RefPtr< VSlot > & | slot, |
const string & | name, | ||
const RefPtr< VCreationPreferences > & | VCP = NullPtr() |
||
) | [inline] |
Create a new object with the type of the specified slot, whatever that is, but using the creation preferences.
The CreationContext implicitly is this object itself.
bool Wizt::VObject::attachParameter | ( | const RefPtr< VParameter > & | ProvidedParam, |
const WeakPtr< VSlot > & | DestSlot, | ||
const string & | Member | ||
) | [static] |
Need to verify whether the Member parameter is necessary...
This function basically does:
DestSlot->param = ProvidedParam;
and includes some notification requests. It is assumed that the DestSlot is member of VObjDst.
static bool Wizt::VObject::attachSlot | ( | const WeakPtr< VSlot > & | DestSlot, |
const RefPtr< VParameter > & | ProvidedParam, | ||
const string & | Member = "" |
||
) | [inline, static] |
Attach a given parameter to a slot of the current object.
DestSlot | A slot of the current object. |
ProvidedParam | The new parameter to be used, an output of some other object. |
VObject::AttachErrorCode Wizt::VObject::attachUniqueObject | ( | const RefPtr< VParameter > & | param, |
const RefPtr< VCreationPreferences > & | VCP = NullPtr() , |
||
bool | ReallyUnique = true |
||
) |
Try to find an existing object that matches its type with the specified parameter.
ReallyUnique | Set this value to try if the existence of multiple objects implementing the same type are to be regarded as error. |
VObject::AttachErrorCode Wizt::VObject::attachUniqueObject | ( | const RefPtr< VSlot > & | slot, |
const RefPtr< VCreationPreferences > & | VCP = NullPtr() , |
||
bool | ReallyUnique = true |
||
) |
Try to find an existing object that matches its type with the specified parameter.
ReallyUnique | Set this value to try if the existence of multiple objects implementing the same type are to be regarded as error. |
VObject::Slot Wizt::VObject::Connect | ( | const RefPtr< VParameter > & | SourceParam | ) |
Given a certain parameter, overload a parameter of the same type in the current object with this one.
Note that the first parameter found that has a compatible type will be overloaded, so the result might be slightly random if there are multiple types provided. For better control, use the attach() functions, this one here is mostly convenience.
VObject::CreateConnectionResult_t Wizt::VObject::connectChild | ( | const RefPtr< VObject > & | ChildObject, |
const RefPtr< VAcceptInfo > & | VA | ||
) |
Connect an existing object as a child to the current object.
The current object will become its parent, and changes in this parent objects will trigger an update in the child object. The parent object is the source of the data flow, the child object the destination of the data.
This object is seeking a connection to an interface Thus, need to find an input slot in the new object that is suitable to accept such an interface.
VObject::Slot Wizt::VObject::ConnectInterface | ( | const SelfPtr & | InterfaceProvider, |
const RefPtr< InterfaceBase > & | IB | ||
) |
touching a parameter independent from its value pool this is probably dangerous and does not work as it should
NEW: This following line might just do instead. However, connections to object interfaces are not frequently used in Vish anyway.
const Ageable & Wizt::VObject::ConnectionAge | ( | ) | const |
Return the age when connections had last been modified.
Note that when changing connections, the object might be out of sync with its inputs, even if all inputs are older than the object itself. Most likely the object must then be updated even in case of old inputs.
VObject::CreateConnectionResult_t Wizt::VObject::createChild | ( | const VAcception & | VA, |
const Intercube & | CreationContext | ||
) |
A static function that is used to create an object's name of this type, when it is created from some parent object.
This function may be redefined in some child class. A VCreator instantiated over this child class will then call the derived function. By default, the name of a new child is the name of its VCreator, unrelated to the parent's name.
Reimplemented in RangeHUD.
bool Wizt::VObject::CreatedFilteredConnection | ( | const RefPtr< VParameter > & | SourceParam | ) | [virtual] |
We wish to connect the current object to the given parameter, but it provides an output type that cannot be used by this current object as input type.
Then this virtual function may take care of such issues and create a filter object.
RefPtr<VObject> Wizt::VObject::createInput | ( | const WeakPtrVCreatorBase & | VCrec, |
const VObject::Slot & | what, | ||
const string & | name, | ||
Intercube & | CreationContext | ||
) |
Given a certain VCreatorBase that is supposed to fit to a given slot, create an object that serves as input to this one.
The virtual function InputCreation() is called to adjust any possible connections.
CreationContext | An Intercube that allows specifying additional parameters for the circumstances of creation. It is passed to the VActionNotifier::VObjectCreation() call. |
string Wizt::VObject::CreateParameterName | ( | const ParameterID & | name | ) | const [virtual] |
Creation of global parameter names.
By default the new parameter identifier will be the concatenation of this object's name, a dot, and the given parameter name. This follows the convention of class members in most programming languages. However, this is not mandatory at all.
void Wizt::VObject::enableRequestProcessing | ( | ) |
Enable processing of requests.
Call if once the object has been fully constructed. The VCreator<> template does this automatically.
void Wizt::VObject::findNewlyConnectedOutputs | ( | const RefPtr< ValuePool > & | VP, |
VSlotSet & | WhichOnes | ||
) | const |
Find all output parameters that have been recently connected since the last update() call.
Might be none.
RefPtr< VSlot > Wizt::VObject::findOutputSlot | ( | const RefPtr< VParameter > & | Who | ) | const |
Find an output slot that refers to the given parameter, i.e.
this slot's parameter is identical to the specified one.
RefPtr< VParameter > Wizt::VObject::getImplementation | ( | const type_info & | what, |
const string & | name = "" , |
||
const string & | member = "" |
||
) | const [virtual] |
By querying a type and an optional finer textual description, retrieve an Parameter that is implemented by this VObject.
This parameter is suitable for usage in replaceParameter() in a subsequent child VObject. The returned VParameter should be existent through the lifetime of the current VObject.
RefPtr< VSlot > Wizt::VObject::getImplementationSlot | ( | const type_info & | what, |
const string & | Name = "" , |
||
const string & | Member = "" |
||
) | const |
Query an output slot for the given type.
Name | Optionally return the slot only if found under the given name. |
int Wizt::VObject::getNumberOfParameters | ( | int | expertLevel | ) | const |
Get the number of parameters up to a certain expert level.
All Parameters with an expert level below the specified one are counted.
RefPtr< VParameter > Wizt::VObject::getParameter | ( | const ParameterID & | s | ) | const |
Return the local input parameter slot for a certain parameter name.
References to VInput objects are indirect via VParameter's, because the VInput object itself may change arbitrarily anytime. However, the VParameter referring to the current VInput object stays permanently at the same location during the lifetime of the VInput request. In other words, the result of the getInput() call may be cached in a derived class and is guaranteed to be valid during the lifetime of the current VObject. Still, the dereference of the result may be a NULL pointer, indicating that there is no VInput object available yet at all.
bool Wizt::VObject::getParameterValue | ( | Type & | Variable, |
const ParameterID & | s, | ||
const RefPtr< ValuePool > & | VP | ||
) | const [inline] |
Get a value for a certain parameter.
VObject::Slot Wizt::VObject::getSlot | ( | const ParameterID & | s, |
int & | EL | ||
) | const |
A more verbose version of getParameter() which also provides information about which member of a certain parameter is used here; note that the type of the full parameter will be different from the type of a member of the parameter.
EL | Optional information of associated expert level (output only) |
string Wizt::VObject::getSlotName | ( | const RefPtr< VParameter > & | param | ) | const |
Check whether this object contains the given parameter, and if so, under which slot's name.
const GimpIcon * Wizt::VObject::gimp_icon | ( | ) | const [virtual] |
If this object provides an icon in GIMP C source format, return it here.
If none found, then xpm_icon is tried.
bool Wizt::VObject::hasChanged | ( | const ParameterID & | s, |
const RefPtr< ValuePool > & | Context | ||
) | const |
Check whether a certain input parameter has changed.
Check whether a certain parameter has changed.
bool Wizt::VObject::HasYoungerInput | ( | const RefPtr< ValuePool > & | Context, |
int | RecursionLevel = 0 |
||
) | const |
RecursionLevel | Specify how many levels to look in the child/parent relationship graph. Zero means just look at the input objects of this object (fastest), negative values mean full traversal of the graph, including detection of loops. |
bool Wizt::VObject::isNewlyConnected | ( | const RefPtr< VParameter > & | Who, |
const RefPtr< ValuePool > & | VP | ||
) | const |
Check if an output parameter has been recently connected or modified through external means.
OutputParam | An output parameter of the current VObject, one of those VOutput<>s usually |
This function checks the VSlot::ConnectionAge() of the output slot and is equivalent to:
if (RefPtr<VSlot> mySlot = findOutputSlot(Who) ) { return mySlot->ConnectionAge().isYoungerThan( age(Context) ); }
bool Wizt::VObject::isYounger | ( | const RefPtr< VParameter > & | OutputParam, |
const RefPtr< ValuePool > & | VP | ||
) | const |
Check if an output parameter is of younger age, which might be the case if it has been recently connected or modified through external means.
This function also checks for the value's age, use isNewlyConnected() of only the connection should be checked.
OutputParam | An output parameter of the current VObject, one of those VOutput<>s usually |
int Wizt::VObject::iterateInputs | ( | VObjectInputIterator & | VIIt, |
int | expertLevel = 0 |
||
) | [inline] |
Iterate all inputs with expert level smaller than zero (default), or as specified.
Same as iterateParameters().
int Wizt::VObject::iterateOutputs | ( | VOutputIterator & | VOut, |
const type_info & | just_these = typeid(void) |
||
) | const [virtual] |
Iterate over all the Outputs of this VObject, i.e.
all the functionality which this object provides.
int Wizt::VObject::iterateParameters | ( | int | expertLevel, |
VObjectInputIterator & | VIIt | ||
) |
Iterate over all VInput objects that have an expert level lower or equal to the expertLevel parameter.
expertLevel | The visibility level. All VInputs with an higher expert level will remain invisible. |
VIIt | An user-specified iterator object. |
bool Wizt::VObject::registerOutput | ( | const RefPtr< VParameter > & | P, |
const string & | AsName = "" |
||
) |
Register a certain parameter as being output by this VObject under the given name (optionally).
P | The parameter which is provided by the object. It will be referenced internally, there is no need to keep an extra reference from the providing object. However, a specific reference is useful to assign values to this parameter from the object when it updates, so in practice a VObject will contain explicit references to the parameters that it provides. |
AsName | Optionally, the name under which this parameter is accessed from the VObject, can be specified. By default, the parameter's intrinsic default name will be used. Note that parameter lookup is done mainly on type information, such that the name of the parameter is only of relevance if an object provides the same type (e.g. many integers). |
bool Wizt::VObject::request | ( | VRequest & | request, |
double | precision, | ||
const WeakVObjectPtr & | ImmediateRequestor, | ||
const WeakVObjectPtr & | RootRequestor | ||
) | [virtual] |
Request an action, to be performed with a certain precision.
Its main purpose is to iterate all parameters and forward the request to them. If this all parameters have fullfilled their request(), then the virtual update() function is called.
In rare case, an object might want to overload this function, for instance when request shall be forwarded to input objects only under certain circumstances (e.g. an Viewer object that is not visible at the moment).
VRequest::Incomplete | might occur if a synchroneous request is issued but some operations are still in asynchroneous construction. This is the case when a synchroneous request is issued after an asynchroneous one that has not yet been completed. In such a case, the caller may just repeat the same request. The caller may and should do something else in the meantime, as the async request may still take a while to finish. |
Check the age of the local state
Some parameter has changed, so call object's update().
Reimplemented in CameraNavigator, Wizt::RemoteVish, and CViewer.
const MemCore::Counter& Wizt::VObject::RequestCount | ( | ) | const [inline] |
A read-only counter telling if this object is currently being under a request.
This might be the case in a reentrant or multithreading situation.
Schedule a request for this object for later processing.
The actual request may be issued at a later time, and possibly in another thread.
precision | Indicate what effort shall be undertaken for processing this requestion. A value of 1.0 tells that we want full quality, may it be as slow as whatever it takes. A value of 0.0 means just do the absolute minimum, but return as quickly as possible. Values outside the range 0.0 to 1.0 are undefined. |
Context | Give an optional context relative to which the request shall be executed. This will most likely always be the case. |
bool Wizt::VObject::setObjectAsChild | ( | const RefPtr< VObject > & | childVObject, |
const string & | DependencySlotName | ||
) |
Set a certain object as being a child of the current one.
This creates a new internal parameter that is exported by the current object as output, and used as input by the child object. This functionality allows to set up a dependency relationship among those objects. It is called by createChild(), but would not necessarily exist automatically because createChild() connects existing parameters. If the parent object shares a parameter with another objects, then the child object would have a relationship to that one, not to the parent object. This one would then be bypassed in the execution pipeline. To fix this, this function explicitely creates such a relation.
At the moment, such an explicit parent dependency is unique. Adding more explicit ones may be considered, as well as means to change and break an existing parent/child relationship (which can be done already via explicit access to the object slots).
DependencySlotName | The name under which the dependency slot shall occur |
bool Wizt::VObject::setParameterProperty | ( | const ParameterID & | param, |
const string & | prop, | ||
const RefPtr< VValueBase > & | Value = NullPtr() |
||
) | [inline] |
Set a property of an input parameter, such as the minimum or maximum of a bounded numerical value.
prop | Textual identification of the property; must be understood by the input implementation. |
bool Wizt::VObject::setParameterValue | ( | const Type & | Variable, |
const ParameterID & | s, | ||
const RefPtr< ValuePool > & | VP, | ||
bool | autoCreateLocalValue | ||
) | const [inline] |
Set a value for a parameter, given a ValuePool.
autoCreateLocalValue | Shall the variable be relative to the local value pool? |
bool Wizt::VObject::setParameterValue | ( | const Type & | Variable, |
const ParameterID & | s, | ||
VContext & | C, | ||
bool | autoCreateLocalValue | ||
) | const [inline] |
Set a value for a parameter, given a context.
autoCreateLocalValue | Shall the variable be relative to the local value pool? |
bool Wizt::VObject::setParameterValue | ( | const Type & | Variable, |
const ParameterID & | s, | ||
VRequest & | R, | ||
bool | autoCreateLocalValue = false |
||
) | const [inline] |
Set a value for a parameter, given a context.
autoCreateLocalValue | Shall the variable be relative to the local value pool? |
void Wizt::VObject::setup | ( | const CreationSlots_t & | CreationSlots | ) | [virtual] |
When a VObject is created as a child of an existing VObject, this variant of the setup function is called, telling which slot is the one connected to the object that triggered creation of this one.
If the provided list of slots is empty, then a newly created VObject shall be initialized with some convenience values. In such a case a VObject may create other objects as it sees fit to provide a good initialized default state.
bool Wizt::VObject::update | ( | VRequest & | , |
double | precision = 1.0 |
||
) | [protected, virtual] |
Virtual update function that implements some heavy action on the object.
Update function.
It is called only if any input object is newer than the current object. It must return true on successful completion. However, the object may touch() itself in the update() routine. Then, it will get a newer time than all input objects, which will trigger all dependent objects as well.
Reimplemented in TangVish, ComputeGridStreamLines, ComputeMultiStreamLines, WebVish, ComputeStreamSurfaces, TangVish, Spheres, DataSink, LineEmitter, Wizt::CatchStatus, DataFilter, ComputeStreamLines, GaussField, DataSink, TangVish, Wizt::RemoteVish, CameraNavigator, DataFilter, DataSource, Wizt::RemoteViewer, DataSink, Wizt::VChartSelector, DataFilter, DataSource, LineRenderer, PNGMovie, GLGrid, DataSource, RangeHUD, ShadowGround, RenderExample, CreateStepField, CreateStepFieldUShort, DataSink, UtilityRotor3D, ProtIntersect, Wizt::VScene, FloatsToPoint2D, MultiplyInt, FloatsToTVector, RangedFloat, Absolute, Cal3DMeshRenderer, Wizt::VProxyObject, and WebFileRenderer.
const MemCore::Counter& Wizt::VObject::UpdateCount | ( | ) | const [inline] |
A read-only counter telling if this object is currently being updated.
This might be the case in a reentrant or multithreading situation.
Return the age of the youngest input slot that is not cached.
ignore cached input parameters here
bool CheckIfThereExistNewerOutputs | ( | const VRequest & | request, |
bool | AdjustObjectAge | ||
) | const [related] |
Check if there are outputs in this very object that are newer (more recent) than this object itself.
This can happen if such an output object has been updated by another object. It indicates that this object here is out of sync with the output it provides; but as it is newer, there would be no reason to re-create it. So this may be adjusted by just setting this object's date to the age of the most recent output.
RefPtr< VParameter > Wizt::VObject::findUniqueOutputObject | ( | const type_info & | Type, |
const RefPtr< VCreationPreferences > & | VCP = NullPtr() , |
||
bool | ReallyUnique = true |
||
) | [related] |
Find an existing VObject that implements the specified type, returning exactly that parameter which implements this type.
A result is only given if the query is unique. If there are more implementations of the same type, an invalid pointer is returned.
int Wizt::VObject::iterateChildren | ( | VObjectIterator & | VOI, |
const type_info & | just_these = typeid(void) |
||
) | [related] |
Iterate over all the child objects that depend on this VObject.
()
void Wizt::VObject::iterateParents | ( | VObjectIterator & | VOI, |
int | EL = 0 |
||
) | [related] |
MemCore::Counter Wizt::VObject::RequestCounter [protected] |
A counter telling if this object is currently being under a request.
This might be the case in a reentrant or multithreading situation.
MemCore::Counter Wizt::VObject::UpdateCounter [protected] |
A counter telling if this object is currently being updated.
This might be the case in a reentrant or multithreading situation.
int Wizt::VObject::VERBOSE_REQUEST [static] |
MemCore::getEnvInteger("VERBOSE_REQUEST", "Print internal information about VObject recursive request traversals")