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: 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: 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: strange compiler message
    ... > even if the programmer were sloppy enough not to check the function signature, ... constructed and bound to a reference to non-const string. ... >>to modify the original object. ... > void foo(const int i) { ...
    (comp.lang.cpp)
  • Re: Emulating lesser shader model
    ... As soon as you get that D3DCAPS9 struct, modify its entries before passing ...
    (microsoft.public.win32.programmer.directx.graphics)
  • Re: Interesting Web Site on Open Source Development
    ... Sorta and sorta not. ... you have to consider the terms of what you modify. ... This naturally impedes any programmer ... Under the BSDL, the programmer is free to do anything, ...
    (alt.lang.asm)