Experimental Physics and Industrial Control System
If you don't use the GDD library, relax.
I have found two GDD features that were not quite obvious to me and
might cause serious trouble.
Both qualities show up when using gddContainer objects. These containers
are used to represent the Channel Access complex DBR types. They
consist of a container object (derived from gdd) and a linked list of
member gdds.
1) For easy-to-use and fast gdd assignments, the operator = is
overloaded in gddI.h to use memcpy().
(I thought memcpy() was the default for operator =, but anyway.)
When this operator is used to assign gdds that are container
members, the pointer to the next element is included in the memcpy()
and screws up the member lists of both containers.
| Do not use operator = for gdds that are located inside containers. |
| Use the target gdd's put() method instead, which only copies the |
| data. It is less efficient, but works. |
2) gddContainer has an overloaded operator [] that is designed to make
the container members available as if the container was an array of
gdds.
This "addressing mode" for container members looks very efficient,
but is isn't, as it creates an iterator and walks through the
container list to find the addressed member. (This fact is mentioned
in the header file, but not in the docs.)
If you nevertheless try to use this operator, be careful: you don't.
The frequently used gddApplicationTypeTable function to create
standard gdds returns a gdd*. So using operator [] will do regular
pointer arithmetics and not use the overloaded operator.
Even if you use a gddContainer* (through a dangerous cast) the
overloaded operator [] takes an unsigned int as index argument
whereas the constants defined in gddApps.h are signed.
New standard gddContainer objects (created using the AppTypeTable)
are always malloc'd as one contiguous block, so pointer arithmetics
will work. By chance.
| If you set up a gddContainer yourself or change/insert/remove |
| member gdds, using operator [] will screw up your container. |
| Using an iterator in a loop and switching on the member's appType |
| seems the only safe way to access member gdds. |
Ralph (... live from the coding dungeon)
- Replies:
- RE: Fatal GDD deficiencies Jeff Hill
- Navigate by Date:
- Prev:
Re: VXI Kinetic Systems V151 cpu - PowerPC Andrew Johnson
- Next:
Channel Access for Macintosh? Steve Lewis
- Index:
1994
1995
1996
1997
1998
1999
<2000>
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Re: VXI Kinetic Systems V151 cpu - PowerPC Andrew Johnson
- Next:
RE: Fatal GDD deficiencies Jeff Hill
- Index:
1994
1995
1996
1997
1998
1999
<2000>
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024