Dear Sirs,
I have the cpf file named AreasDescription.cpf with the content listed below.
In my taskContex I defined the following properties:
Property< interactionAreas > _areasDescription;
Property< int > _maxAreas;
Property< int > _maxTimes;
where interactionAreas is defined as follows:
class interactionAreas
{
public:
int numAreas;
vector<areaShape> areas;
interactionAreas()
{
numAreas=0;
}
}
In my configureHook I am trying to read properties from file and to get access to the read values.
To read the file I use wrote the following code
PropertyBag areaDescBag;
PropertyDemarshaller *pArea=new PropertyDemarshaller("AreasDescription.cpf");
result = pArea->deserialize(areaDescBag);
if ( result == false )
{
cout << " error reading AreasDescription.cpf" << endl;
return(false);
}
_maxAreas = areaDescBag.getProperty("maxAreas");
cout << "max number of areas " << _maxAreas << endl;
_maxTimes = areaDescBag.getProperty("maxTimes");
cout << " max times " << _maxTimes << endl;
_areasDescription = areaDescBag.getProperty("areasDescription");
I am able to access the value of the property defined as simple type, but even If I tryed different approach
I was not able to access the properties related to a the complex data type that define the point of a closed shape.
How can I get values of the define areas and the coordinate of the points?
Can anyone give me some suggestion?
Thank you in advance.
Gianpaolo Rizzi.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE properties SYSTEM "cpf.dtd">
<properties>
<struct name="areasDescription" type="/rosetta/interactionAreas">
<description>shape of the interaction areas<description>
<simple name="numAreas" type="long"><description>Part<description><value>1<value><simple>
<struct name="areas" type="/std/vector</rosetta/areaShape>">
<description>Part<description>
<struct name="0" type="/rosetta/areaShape">
<description>Item<description>
<simple name="areaID" type="long"><description>Part<description><value>1<value><simple>
<simple name="areaType" type="long"><description>Part<description><value>1<value><simple>
<struct name="vertex" type="/std/vector</rosetta/rPoint>">
<description>Part<description>
<struct name="0" type="/rosetta/rPoint">
<description>Item<description>
<simple name="x" type="double"><description>Part<description><value>1<value><simple>
<simple name="y" type="double"><description>Part<description><value>0<value><simple>
<struct>
<struct name="1" type="/rosetta/rPoint">
<description>Item<description>
<simple name="x" type="double"><description>Part<description><value>1<value><simple>
<simple name="y" type="double"><description>Part<description><value>0<value><simple>
<struct>
<struct name="2" type="/rosetta/rPoint">
<description>Item<description>
<simple name="x" type="double"><description>Part<description><value>1<value><simple>
<simple name="y" type="double"><description>Part<description><value>0<value><simple>
<struct>
<struct name="3" type="/rosetta/rPoint">
<description>Item<description>
<simple name="x" type="double"><description>Part<description><value>1<value><simple>
<simple name="y" type="double"><description>Part<description><value>0<value><simple>
<struct>
<struct name="4" type="/rosetta/rPoint">
<description>Item<description>
<simple name="x" type="double"><description>Part<description><value>1<value><simple>
<simple name="y" type="double"><description>Part<description><value>0<value><simple>
<struct>
<struct>
<struct>
<struct>
<struct>
<simple name="maxAreas" type="long"><description>maximum number of area of interest<description><value>5<value><simple>
<simple name="maxTimes" type="long"><description>maximum number of instants of time for which the probability of presence can be requested<description><value>4<value><simple>
<properties>
Reading and accessing complex properties from cpf file
On Sunday 13 March 2011 18:51:33 gprizzi [..] ... wrote:
> Dear Sirs,
>
> I have the cpf file named AreasDescription.cpf with the content listed
> below.
>
> In my taskContex I defined the following properties:
>
>
>
> Property< interactionAreas > _areasDescription;
>
> Property< int > _maxAreas;
>
> Property< int > _maxTimes;
>
>
>
> where interactionAreas is defined as follows:
>
> class interactionAreas
> {
> public:
> int numAreas;
> vector<areaShape> areas;
> interactionAreas()
> {
> numAreas=0;
> }
> }
>
>
>
> In my configureHook I am trying to read properties from file and to get
> access to the read values.
>
> To read the file I use wrote the following code
>
> PropertyBag areaDescBag;
>
> PropertyDemarshaller *pArea=new
> PropertyDemarshaller("AreasDescription.cpf"); result =
> pArea->deserialize(areaDescBag);
> if ( result == false )
> {
> cout << " error reading AreasDescription.cpf" << endl;
> return(false);
> }
>
>
> _maxAreas = areaDescBag.getProperty("maxAreas");
> cout << "max number of areas " << _maxAreas << endl;
> _maxTimes = areaDescBag.getProperty("maxTimes");
> cout << " max times " << _maxTimes << endl;
> _areasDescription = areaDescBag.getProperty("areasDescription");
>
> I am able to access the value of the property defined as simple type, but
> even If I tryed different approach I was not able to access the properties
> related to a the complex data type that define the point of a closed
> shape.
>
> How can I get values of the define areas and the coordinate of the points?
> Can anyone give me some suggestion?
You are using a 'low-level' API function. The only thing the
PropertyDemarshaller does is reading the XML file into a property tree, using
'Property<PropertyBag>' each time a 'struct' is seen in the XML. It is advised
that you use a higher level function that converts this PropertyBag into your
vector<areaShape>. The easiest way is to use the marshalling service class,
but this requires that your properties are added to a TaskContext. Otherwise,
use this function to do the composition:
As usual, this requires that your typekits are in your RTT_COMPONENT_PATH and
loaded into the application.
>
> Thank you in advance.
>
> Gianpaolo Rizzi.
>
> <?xml version="1.0" encoding="UTF-8"?>
> <!DOCTYPE properties SYSTEM "cpf.dtd">
> <properties>
> <struct name="areasDescription" type="/rosetta/interactionAreas">
> <description>shape of the interaction areas<description>
> <simple name="numAreas"
> type="long"><description>Part<description><value>1<value><simple>
> <struct name="areas" type="/std/vector</rosetta/areaShape>">
> <description>Part<description>
> <struct name="0" type="/rosetta/areaShape">
> <description>Item<description>
> <simple name="areaID"
> type="long"><description>Part<description><value>1<value><simple>
> <simple name="areaType"
> type="long"><description>Part<description><value>1<value><simple>
> <struct name="vertex" type="/std/vector</rosetta/rPoint>">
> <description>Part<description>
> <struct name="0" type="/rosetta/rPoint">
> <description>Item<description>
> <simple name="x"
> type="double"><description>Part<description><value>1<value><simple>
> <simple name="y"
> type="double"><description>Part<description><value>0<value><simple>
> <struct>
> <struct name="1" type="/rosetta/rPoint">
> <description>Item<description>
> <simple name="x"
> type="double"><description>Part<description><value>1<value><simple>
> <simple name="y"
> type="double"><description>Part<description><value>0<value><simple>
> <struct>
> <struct name="2" type="/rosetta/rPoint">
> <description>Item<description>
> <simple name="x"
> type="double"><description>Part<description><value>1<value><simple>
> <simple name="y"
> type="double"><description>Part<description><value>0<value><simple>
> <struct>
> <struct name="3" type="/rosetta/rPoint">
> <description>Item<description>
> <simple name="x"
> type="double"><description>Part<description><value>1<value><simple>
> <simple name="y"
> type="double"><description>Part<description><value>0<value><simple>
> <struct>
> <struct name="4" type="/rosetta/rPoint">
> <description>Item<description>
> <simple name="x"
> type="double"><description>Part<description><value>1<value><simple>
> <simple name="y"
> type="double"><description>Part<description><value>0<value><simple>
> <struct>
> <struct>
> <struct>
> <struct>
> <struct>
> <simple name="maxAreas" type="long"><description>maximum number of area
> of interest<description><value>5<value><simple> <simple name="maxTimes"
> type="long"><description>maximum number of instants of time for which the
> probability of presence can be
> requested<description><value>4<value><simple> <properties>
Peter