EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

2002  2003  2004  <20052006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 2002  2003  2004  <20052006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: data access structures, strings
From: Andrew Johnson <[email protected]>
To: Marty Kraimer <[email protected]>
Cc: [email protected]
Date: Mon, 03 Oct 2005 11:03:43 -0500
Marty Kraimer wrote:

I like the char * pointer for things like record type names, record instance names, etc.(for java a regular String would accomplish the same thing) This would take care of one main use of names It does mean that we can not completely delete anything that has such names because the storage for at least the name will remain. For example we can not completely delete a record instance. I think this is OK.

Record instance names will have to be taken off the heap, and thus can be returned to it when records are deleted. The distinction between the strings that will be in the code segment and those that come from the heap is relatively simple: anything named in a DBD file will be compiled, so these names are not changable; anything named on the command line or in a DB file is read at runtime and will thus have the storage for the string allocated off the heap.

I think this is actually exactly what we want anyway, since items that are compiled in are stongly related to source code and may even come from an extension that might even be linked in from a DLL/shared library; the code will often have some dependency on the string text anyway (field names etc). To change those kinds of things at runtime would mean unloading the DLL/library and reloading a different version, which is probably rather dangerous; these strings would use just char* pointers, and can be wrapped with a ConstString if necessary.

Record names and other things that get configured on the command line are something that we're more likly to want to be able to change at runtime, and thus those items should probably use some kind of mutable string to store them.

In my design any const char* buffer or literal can be wrapped with a ConstString at the point of use if it has to be passed to a routine that takes a StringReader. Ownership would never be passed that way though.

Can we accomplish the same thing without exposing the entire String class?

Why would you want that?

Something like:

interface DbInstance {
   ConstString *getName();
   ...
}

You're better off just returning a const StringReader*, which has fewer methods than ConstString (but doesn't support the c_str() method). Note that even if internally you use a mutable string type to implement the name, you should return a const StringReader* if you're only giving out read access to the string, or even (if you're Jeff) require the caller to pass in a StringEditor which you copy the name into.

In C++ your example might be:

class DbInstance {
    virtual const StringReader* getName() const = 0;
    ...
}

or even:

class DbInstance {
    virtual void getName(StringEditor& name) const = 0;
    ...
}

In Java though, we should use the native String class:

public interface DbInstance {
    public abstract String getName();
    ...
}

or:

public interface DbInstance {
    public abstract void getName(String name);
    ...
}

- Andrew
--
English probably arose from Normans trying to pick up Saxon girls.

References:
RE: data access structures, strings Jeff Hill
Re: data access structures, strings Kay-Uwe Kasemir
Re: data access structures, strings Andrew Johnson
Re: data access structures, strings Kay-Uwe Kasemir
Re: data access structures, strings Marty Kraimer
Re: data access structures, strings Andrew Johnson
Re: data access structures, strings Marty Kraimer

Navigate by Date:
Prev: RE: core meeting possible on wednesday 20:00 Dalesio, Leo `Bob`
Next: Re: strings Benjamin Franksen
Index: 2002  2003  2004  <20052006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: data access structures, strings Marty Kraimer
Next: RE: data access structures, strings Jeff Hill
Index: 2002  2003  2004  <20052006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 02 Feb 2012 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·