selective access to different classes



Hi,
I have asked the question in java programmer newsgroup, but I think
it is better suited here, as it is manly related to design pattern.
Hence a repost (with little modification).
Any help is appreciated.

I have a class which holds different objects and gives selective
access to different operations on this according to interface
specified. All the other operations can use it, but no modification
except those who are allowed. To demonstrate, I am having an example
like below,

public class SoundDataHolder{
private://data
RawSoundData _rawData;
FilteredSoundData _filteredData;
QuantizedData _qData;
...
private: //operators
IDataCollector _dataColector;
IGenericFilter _filter;
IQuantizer _quantizer;
....
public:
void operate() {...}
}

now one can set different concrete class for all of the operators. &
call operate.
operate in turns call each operaion in sequence, passing only those
parameters which they modify. (passing all of the data will be
difficult as it is a long list of data which they use).
now, IDataCollector can modify RawSoundData, thus its operate signature
is void operate(DawSoundData data); while IGenericFilter may have a
operator as, operate(FilteredSoundData) , but it uses RawSoundData
also. Note , none of the data (they are collections) are created by the
operator, they pre-exists, and created by some other classes, gets
recycled, The operators only set the contents of the container.
SoundDataHolder is a singleton, and can return all of its data, and set
all of the operators, and call operate on it.
I want to return all data as const/final reference thus any operator
can use it, but the operator's parameter will take only the data which
it needs to modify. Also note the operator interface knows what data
they are modifying, thus I can put them on the operate method call. But
what data they need for this operation is not known also to the
interface. They are free to take any data from the SoundDataHolder
singleton, but not allowed to modify.

In C++ I was doing this returning all data from SoundDataHolder as
const reference, thus any non const member was not allowed to invoke
(eg any setter methods)
while I was passing a non const reference to the operators which needs
to modify it.

Thus In brief, a singleton class holds the data used by the program
globally.
Operation is performed over the input data's to generate several
intermediate data, by stages through a sequence of operation, and
finally result is obtained. Operations only which allowed, can modify
the data. But any operation is free to access existing data.
Note, making data immutable means nobody can access it. And I can't put
the data in the hierarchy of operator to acces it selectively, as that
is not is-a relationship. I prefer composition model.
My question is,
How to allow such senario will passing data to and fro through a
pattern can be achieved.
If any other common design pattern exists for this kind of selective
access? Any other way to do it (need good secure programming) ? Can you
refer any book/ website having an example?
(basically the operators take the data from the self, modify and place
them on the self, but also allowed to look what other is there in the
self. Also never, the self GIVES the data to operator or TAKES it from
it! )
The requirement is something like this, but class's can be arranged
any way to better suited the problem. Also a generic non-language
specific solution is good for me (C++, Java C# or any pseudocode is OK)

Thanks for any kind of help.
abir

.



Relevant Pages

  • Re: Help a beginner - simple lowercase to uppercase and so on function
    ... Whether you have the right to modify parameters is ... properly a decision for you, the programmer, to make. ... Many runtimes will access local variables faster than parameters ...
    (comp.lang.c)
  • Re: fields or properties
    ... All you have to do is change the name of the (now private) field, ... manipulated _only_ within the owning class, ... one class and find _all places_ where that field is changed, and modify ... I'm a lazy programmer and I don't like cluttering my brain ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Help a beginner - simple lowercase to uppercase and so on
    ... only modify your local variables. ... Standard to find somewhere else other than a stack in which to pass ... Dijkstra said somewhere that a good programmer has good taste, ... because he's "conformed" to the standard is weasel-assed reasoning. ...
    (comp.lang.c)
  • Re: selective access to different classes
    ... in it are set from outsite your SoundDataHolder. ... the system in a sequence of processing steps and data formats for each ... operate in turns call each operaion in sequence, passing only those ... parameters which they modify. ...
    (comp.object)
  • Re: Help a beginner - simple lowercase to uppercase and so on function
    ... A real programmer has a strong idea in his mind of a pure zuivere ... void intcopy(int *s, int *t, int term) ... If their INTENT is to modify s and t neither suck and the first is ... A real programmer doesn't piss on value parameters even though they ...
    (comp.lang.c)