Click here to Skip to main content
16,007,277 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Debugging in an activeX control Pin
khan++23-Sep-05 20:40
khan++23-Sep-05 20:40 
Questionglobal buffer or passing by reference? Pin
billiam90423-Sep-05 16:20
billiam90423-Sep-05 16:20 
AnswerRe: global buffer or passing by reference? Pin
khan++23-Sep-05 20:44
khan++23-Sep-05 20:44 
GeneralRe: global buffer or passing by reference? Pin
billiam90423-Sep-05 22:00
billiam90423-Sep-05 22:00 
GeneralRe: global buffer or passing by reference? Pin
khan++23-Sep-05 22:54
khan++23-Sep-05 22:54 
GeneralRe: global buffer or passing by reference? Pin
billiam90424-Sep-05 13:05
billiam90424-Sep-05 13:05 
GeneralRe: global buffer or passing by reference? Pin
Achim Klein25-Sep-05 5:31
Achim Klein25-Sep-05 5:31 
AnswerRe: global buffer or passing by reference? Pin
Achim Klein24-Sep-05 1:32
Achim Klein24-Sep-05 1:32 
Hi,

in my opinion it is always worth an attempt to get around global data.
Maybe this design pattern (Visitor) can help you.

The class that can read wave files:
class IveGotTheData
{
public:

   // add some 'Getter' methods here

   bool ReadWaveFile(const char* Path);

   void UseMyData(IknowTheAlgorithm& Operator)
   {
      Operator.Operate(this);
   }
};

The base class for all algorithms that modify your wave data (the Visitor):
class IknowTheAlgorithm
{
public:

   virtual void Operate(IveGotTheData* Data) = 0;
};

Your first algorithm is encapsulated in this class:
class Algorithm1 : public IknowTheAlgorithm
{
public:

   virtual void Operate(IveGotTheData* Data)
   {
      // your first algorithm goes here
   }
};

Your second algorithm is encapsulated in this class:
class Algorithm2 : public IknowTheAlgorithm
{
public:

   virtual void Operate(IveGotTheData* Data)
   {
      // your second algorithm goes here
   }
};

Using your algorithms looks like this:
void main()
{
   IveGotTheData wav;

   if (wav.ReadWaveFile("Test.wav"))
   {
      Algorithm1 alg1;
      Algorithm2 alg2;

      wav.UseMyData(alg1);
      wav.UseMyData(alg2);
   }
}


Regards
Achim Klein


We can do no great things, only small things with great love. - Mother Theresa
GeneralRe: global buffer or passing by reference? Pin
billiam90424-Sep-05 12:28
billiam90424-Sep-05 12:28 
AnswerRe: global buffer or passing by reference? Pin
Achim Klein25-Sep-05 5:48
Achim Klein25-Sep-05 5:48 
GeneralRe: global buffer or passing by reference? Pin
billiam90425-Sep-05 5:57
billiam90425-Sep-05 5:57 
GeneralRe: global buffer or passing by reference? Pin
Achim Klein25-Sep-05 6:02
Achim Klein25-Sep-05 6:02 
GeneralRe: global buffer or passing by reference? Pin
Achim Klein25-Sep-05 6:50
Achim Klein25-Sep-05 6:50 
GeneralRe: global buffer or passing by reference? Pin
Achim Klein25-Sep-05 6:52
Achim Klein25-Sep-05 6:52 
GeneralRe: global buffer or passing by reference? Pin
billiam90425-Sep-05 7:08
billiam90425-Sep-05 7:08 
GeneralRe: global buffer or passing by reference? Pin
Achim Klein25-Sep-05 7:17
Achim Klein25-Sep-05 7:17 
GeneralRe: global buffer or passing by reference? Pin
billiam90425-Sep-05 7:27
billiam90425-Sep-05 7:27 
GeneralRe: global buffer or passing by reference? Pin
Achim Klein25-Sep-05 7:36
Achim Klein25-Sep-05 7:36 
GeneralRe: global buffer or passing by reference? Pin
billiam90425-Sep-05 7:46
billiam90425-Sep-05 7:46 
GeneralRe: global buffer or passing by reference? Pin
Achim Klein25-Sep-05 8:05
Achim Klein25-Sep-05 8:05 
GeneralRe: global buffer or passing by reference? Pin
billiam90425-Sep-05 8:39
billiam90425-Sep-05 8:39 
GeneralRe: global buffer or passing by reference? Pin
Achim Klein25-Sep-05 9:37
Achim Klein25-Sep-05 9:37 
GeneralRe: global buffer or passing by reference? Pin
billiam90425-Sep-05 10:07
billiam90425-Sep-05 10:07 
Questionrecord Voice Pin
bulgaa23-Sep-05 15:55
bulgaa23-Sep-05 15:55 
AnswerRe: record Voice Pin
billiam90423-Sep-05 16:38
billiam90423-Sep-05 16:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.