EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: how to determine record type given pointer to a record
From: Andrew Johnson <[email protected]>
To: John Dobbins <[email protected]>
Cc: EPICS Tech-Talk <[email protected]>
Date: Tue, 31 Jan 2006 15:45:44 -0600
John Dobbins wrote:

I'm writing a bit of code that has to deal with multiple record types but is only passed a pointer to the record. What is the easiest way to determine the record type (or even just dset type)?


e.g. since I don't the record type I'm being passed I first cast the pointer as (dbCommon *), then precord->rdes->name will give me the record type name as a string which I can compare to say "ai"

but is there a simpler way?

If this is for a device support layer that you're writing and you know that you've already initialized the record, you could arrange to have an enum or other marker in the structure that the DTYP field points to.


Here's the start of the definition of a dpvt structure that I use in my directNetAsyn support; the enum recType field is how I decide which record type this particular record belongs to:

struct dpvtIn {
    struct dbCommon *precord;
    enum recType {AI, AIF, BI, MBBI, MBBID} type;
    ...
};

In my device support's init_record routine I allocate a dpvtIn structure and point to it from the DPVT field, making sure that I initialize the dpvt->type field to the appropriate value.


However if this is more general-purpose and could be any record, your rdes->name may be the best way to determine the type. It really depends what you want to do with the result.


- Andrew
--
* * Matt Santos / / For a Brighter America * *

References:
how to determine record type given pointer to a record John Dobbins

Navigate by Date:
Prev: how to determine record type given pointer to a record John Dobbins
Next: Re: mallocMustSucceed( 0 ) non-portable Benjamin Franksen
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: how to determine record type given pointer to a record John Dobbins
Next: Hytec 8601 Quad Stepper Motor IP Card - EPICS Driver Available Darrell Nineham
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  <20062007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 02 Sep 2010 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·