Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

I try to use element and exchange data between TrigML and actor.

I have read TrigML reference guide and BREW forums.

http://brewforums.qualcomm.com/showthread.php?t=17034

The thread explaina how to use (static widget) with part of sample code.
I understand ValueModel is created in actor code. But not sure how to associate
with static widget's ValueModel.

I did not get the timing of "pass the IModel pointer when trig asks for the data"
I guess some callback is called when Trig asks for the data.

I am confused the relation of VfsCacheModel and ValueModel.
I guess these 2 model is totally different concept of model . Vfs model and Widget Model. Please correct me if my understanding is wrong.

Thanks,

Hi,
The element has to have a model associated with it, to provide the underlying widget with data. The model must implement the IModel interface in order for the widget to be able to use it. This model is usually created by an actor, and the interface to the model is stored in a node in the virtual file system. Trigplayer then sets the model provided by the actor to be the widget s model.
Your actor basically has three steps to perform: create the VFS node that will contain the IModel*, create the model in memory, store the IModel* in the VFS node.
When you write your TrigML, you tell Trigplayer the class ID (name= ) of your widget, and also the location of the IModel* (res= ). For example:
When your actor is instantiated, you create its node in the VFS ( exampleactor ). You then create the MyModel node using IACTORCONTEXT_CreateInterface() (as you are creating a VFS node to contain a Brew interface), and you add this node as a child of your actor node. For example, if your actor node is a struct container, you would use IVFSSTRUCTCONTAINER_AddChild(). You then create a model and attach its IModel* to the MyModel node using IVFSNODE_SetData().
Once your actor has returned, Trigplayer retrieves the IModel* from the /actor/exampleactor/MyModel node and associates it with the widget for you (you do not have to do it yourself).
The widget then uses the IModel interface to retrieve its data from the model.
==========
Regarding models:
An IVfsCacheModel (used with TrigML) is used to provide a VFS cache container node with data. An IVfsCacheContainer must have an IVfsCacheModel associated with it in order to function.
An IVfsNodeModel (used with TrigML) can be used to extend the functionality of a standard IVfsNode. A VFS node may, but does not have to, have an IVfsNodeModel attached to it (it has default behaviour if a model is not attached, or if the attached model cannot handle a particular request made of it).
An IValueModel (used with Brew User Interface Widgets) is a model associated with a widget, used to get and set the widget s data.
==========
I hope this helps.

Hi,
The element has to have a model associated with it, to provide the underlying widget with data. The model must implement the IModel interface in order for the widget to be able to use it. This model is usually created by an actor, and the interface to the model is stored in a node in the virtual file system. Trigplayer then sets the model provided by the actor to be the widget s model.
Your actor basically has three steps to perform: create the VFS node that will contain the IModel*, create the model in memory, store the IModel* in the VFS node.
When you write your TrigML, you tell Trigplayer the class ID (name= ) of your widget, and also the location of the IModel* (res= ). For example:
When your actor is instantiated, you create its node in the VFS ( exampleactor ). You then create the MyModel node using IACTORCONTEXT_CreateInterface() (as you are creating a VFS node to contain a Brew interface), and you add this node as a child of your actor node. For example, if your actor node is a struct container, you would use IVFSSTRUCTCONTAINER_AddChild(). You then create a model and attach its IModel* to the MyModel node using IVFSNODE_SetData().
Once your actor has returned, Trigplayer retrieves the IModel* from the /actor/exampleactor/MyModel node and associates it with the widget for you (you do not have to do it yourself).
The widget then uses the IModel interface to retrieve its data from the model.
==========
Regarding models:
An IVfsCacheModel (used with TrigML) is used to provide a VFS cache container node with data. An IVfsCacheContainer must have an IVfsCacheModel associated with it in order to function.
An IVfsNodeModel (used with TrigML) can be used to extend the functionality of a standard IVfsNode. A VFS node may, but does not have to, have an IVfsNodeModel attached to it (it has default behaviour if a model is not attached, or if the attached model cannot handle a particular request made of it).
An IValueModel (used with Brew User Interface Widgets) is a model associated with a widget, used to get and set the widget s data.
==========
I hope this helps.

I modified circle actor sample code for element with static widget.
I think I call all API you mentioned. It still does not work. The widget only displays empty frame. I can set breakpoint in my actor code. Please correct my source code.
Thanks,
In TrigML

On actor side, _CreateChild(pObj,contaner,name,node), using cache container.
CircleModel* self = OBJECTFROMINTERFACE(CircleModel, pObj, IVfsCacheModel);
IACTORCONTEXT_CreateInterface(self->m_context, KModelNode, AEECLSID_ValueModel,
(IVfsContainer*)container, 0, &self->m_pIModelNode);
IVFSCONTAINER_AddChild(container, self->m_pIModelNode);
IVFSNODE_Release(self->m_pIModelNode);
ISHELL_CreateInstance(self->m_pIShell, AEECLSID_ValueModel,
(void **)&self->m_pIValModel);
IVALUEMODEL_SetText(self->m_pIValModel, KMyStr, WSTRLEN(KMyStr));
IVFSNODE_SetData(self->m_pIModelNode, 0, AEECLSID_ValueModel, (void*)self->m_pIValModel, sizeof(IValueModel*));
IVFSNODE_Notify(self->m_pIModelNode);
*node = self->m_pIModelNode;

I modified circle actor sample code for element with static widget.
I think I call all API you mentioned. It still does not work. The widget only displays empty frame. I can set breakpoint in my actor code. Please correct my source code.
Thanks,
In TrigML

On actor side, _CreateChild(pObj,contaner,name,node), using cache container.
CircleModel* self = OBJECTFROMINTERFACE(CircleModel, pObj, IVfsCacheModel);
IACTORCONTEXT_CreateInterface(self->m_context, KModelNode, AEECLSID_ValueModel,
(IVfsContainer*)container, 0, &self->m_pIModelNode);
IVFSCONTAINER_AddChild(container, self->m_pIModelNode);
IVFSNODE_Release(self->m_pIModelNode);
ISHELL_CreateInstance(self->m_pIShell, AEECLSID_ValueModel,
(void **)&self->m_pIValModel);
IVALUEMODEL_SetText(self->m_pIValModel, KMyStr, WSTRLEN(KMyStr));
IVFSNODE_SetData(self->m_pIModelNode, 0, AEECLSID_ValueModel, (void*)self->m_pIValModel, sizeof(IValueModel*));
IVFSNODE_Notify(self->m_pIModelNode);
*node = self->m_pIModelNode;

Once the actor node has been created, you must add your model node as a child (assuming you want the model to be at a VFS location such as /actor/myactor/mymodel). To check your scenario (a widget element using a static widget with a value model), I have written an example actor that creates a struct container as the actor node. In the ExampleActorFactory_CreateNode() function, after the struct container has been created (IACTORCONTEXT_CreateStructContainer()) and the actor has be set as its model (IVFSSTRUCTCONTAINER_SetModel()), I make a call to createValueModelNode() (see below). Please note where class IDs (AEECLSID_*) and interface IDs (AEEIID_*) are used in the example.
The TrigML is:
The C code is:
static LIT(KTextModelName, "ValueModelName");
static LIT(KExampleText, "Some text.");
static int createValueModelNode(ExampleActor* pMe, IActorContext* pActCxt)
{
IVfsNode* pValueModelNode;
// Create a VFS node to contain a model interface
int nErr = IACTORCONTEXT_CreateInterface(pActCxt,
KTextModelName,
AEEIID_MODEL,
IVFSSTRUCTCONTAINER_TO_IVFSCONTAINER(pMe->m_pContainer),
0,
&pValueModelNode);
if (SUCCESS == nErr) {
// Add the model VFS node to the actor node
nErr = IVFSSTRUCTCONTAINER_AddChild(pMe->m_pContainer, pValueModelNode);
if (SUCCESS == nErr) {
// Create the value model and associate it with the model VFS node
IValueModel* pValueModel;
nErr = ISHELL_CreateInstance(pMe->m_pIShell, AEECLSID_VALUEMODEL, (void**)&pValueModel);
if (SUCCESS == nErr) {
// Set text using the value model
(void)IVALUEMODEL_SetText(pValueModel, KExampleText, WSTRLEN(KExampleText));
// Associate the value model with the model VFS node
nErr = IVFSNODE_SetData(pValueModelNode, 0, AEEIID_MODEL, (const void*)pValueModel, sizeof(pValueModel));
(void)IVALUEMODEL_Release(pValueModel);
}
}
(void)IVFSNODE_Release(pValueModelNode);
}
return nErr;

Once the actor node has been created, you must add your model node as a child (assuming you want the model to be at a VFS location such as /actor/myactor/mymodel). To check your scenario (a widget element using a static widget with a value model), I have written an example actor that creates a struct container as the actor node. In the ExampleActorFactory_CreateNode() function, after the struct container has been created (IACTORCONTEXT_CreateStructContainer()) and the actor has be set as its model (IVFSSTRUCTCONTAINER_SetModel()), I make a call to createValueModelNode() (see below). Please note where class IDs (AEECLSID_*) and interface IDs (AEEIID_*) are used in the example.
The TrigML is:
The C code is:
static LIT(KTextModelName, "ValueModelName");
static LIT(KExampleText, "Some text.");
static int createValueModelNode(ExampleActor* pMe, IActorContext* pActCxt)
{
IVfsNode* pValueModelNode;
// Create a VFS node to contain a model interface
int nErr = IACTORCONTEXT_CreateInterface(pActCxt,
KTextModelName,
AEEIID_MODEL,
IVFSSTRUCTCONTAINER_TO_IVFSCONTAINER(pMe->m_pContainer),
0,
&pValueModelNode);
if (SUCCESS == nErr) {
// Add the model VFS node to the actor node
nErr = IVFSSTRUCTCONTAINER_AddChild(pMe->m_pContainer, pValueModelNode);
if (SUCCESS == nErr) {
// Create the value model and associate it with the model VFS node
IValueModel* pValueModel;
nErr = ISHELL_CreateInstance(pMe->m_pIShell, AEECLSID_VALUEMODEL, (void**)&pValueModel);
if (SUCCESS == nErr) {
// Set text using the value model
(void)IVALUEMODEL_SetText(pValueModel, KExampleText, WSTRLEN(KExampleText));
// Associate the value model with the model VFS node
nErr = IVFSNODE_SetData(pValueModelNode, 0, AEEIID_MODEL, (const void*)pValueModel, sizeof(pValueModel));
(void)IVALUEMODEL_Release(pValueModel);
}
}
(void)IVFSNODE_Release(pValueModelNode);
}
return nErr;

Hi,
It works after I modify class id parameter of IACTORCONTEXT_CreateInterface() and IVFSNODE_SetData(). I should use AEEIID_MODEL.
Great Thanks,

Hi,
It works after I modify class id parameter of IACTORCONTEXT_CreateInterface() and IVFSNODE_SetData(). I should use AEEIID_MODEL.
Great Thanks,