Click here to Skip to main content
15,939,733 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: CWinthread Pin
Mark Salsbery6-Mar-08 5:14
Mark Salsbery6-Mar-08 5:14 
GeneralService or Singleton COM exe or DLL Pin
act_x5-Mar-08 11:13
act_x5-Mar-08 11:13 
GeneralRe: Service or Singleton COM exe or DLL Pin
Matthew Faithfull5-Mar-08 12:23
Matthew Faithfull5-Mar-08 12:23 
Generalusing New Opperator for object pointers ( Polymorphism ) Pin
ScotDolan5-Mar-08 10:07
ScotDolan5-Mar-08 10:07 
GeneralRe: using New Opperator for object pointers ( Polymorphism ) Pin
led mike5-Mar-08 11:34
led mike5-Mar-08 11:34 
GeneralRe: using New Opperator for object pointers ( Polymorphism ) Pin
ScotDolan5-Mar-08 12:18
ScotDolan5-Mar-08 12:18 
GeneralRe: using New Opperator for object pointers ( Polymorphism ) Pin
Randor 5-Mar-08 13:06
professional Randor 5-Mar-08 13:06 
GeneralRe: using New Opperator for object pointers ( Polymorphism ) Pin
Mark Salsbery5-Mar-08 14:16
Mark Salsbery5-Mar-08 14:16 
A shorter smaple of code would certainly make it easier for those of us not familiar
with it to study Smile | :)

I get the feeling that the CLX_xxxx_POLLING classes should have a common interface base class
(a class with just the common methods pure virtual).

These polling classes should only derive from this common polling base class.

Instead of being derived from the thread and four invertor classes, the polling classes
should contain objects of these classes.

Ack maybe pseudo-code makes more sense...I just think you're over-naming yourself right out of
object oriented potential here Wink | ;) ...
// classes shortened for brevity...

class CLX_COMMON_INVERTER
{
   //Common inverter data
   ClxSafeQue<char> m_sqCmdQue;
   CRITICAL_SECTION m_csLock; 

   // Common inverter methods
   virtual bool IsConnected( void ) = 0;
   virtual bool IsInhibited( void ) = 0;
   virtual bool IsActiveFault( void ) = 0;
   virtual bool IsBootMode( void ) = 0;
};


class CLX_COMMON_POLLING
{
   // Common data
   CLX_COMMON_INVERTER *pPitchInverter;
   CLX_COMMON_INVERTER *pRollInverter;
   CLX_COMMON_INVERTER *pLiftInverter;
   CLX_COMMON_INVERTER *pCounterweightInverter;
   unsigned short m_BaudRate;
   int m_CommPort;
   int m_SerialPortHandlePolling;

   // Common methods
   virtual bool mvInitComm( int comm_port, int baud_rate ) = 0;
   virtual bool mvCloseComm( void ) = 0;
   virtual bool mvRestartComm( void ) = 0;
   virtual void mvSetBaudRate(int value) = 0;
   virtual unsigned short mvGetBaudRate(void) = 0;

}


class CLX_MITSUBISHI_POLLING : public CLX_COMMON_POLLING
{
   // Data specific to this derived class

   // Implement Common methods
   virtual bool mvInitComm( int comm_port, int baud_rate );
   virtual bool mvCloseComm( void );
   virtual bool mvRestartComm( void );
   virtual void mvSetBaudRate(int value);
   virtual unsigned short mvGetBaudRate(void);
}


class CLX_LENZE_POLLING : public CLX_COMMON_POLLING
{
   // Data specific to this derived class

   // Implement Common methods
   virtual bool mvInitComm( int comm_port, int baud_rate );
   virtual bool mvCloseComm( void );
   virtual bool mvRestartComm( void );
   virtual void mvSetBaudRate(int value);
   virtual unsigned short mvGetBaudRate(void);
}



// example usage...

CLX_COMMON_POLLING *Invertors;

if( inverter_type == MITSUBISHI )
   Invertors = new CLX_MITSUBISHI_POLLING;
else
   Invertors = new CLX_LENZE_POLLING;

See what I've done here? 

You can use the common inverter class to make any specific inverter
subclass.  Note I changed the method names and removed the class-specific part of
the name (lift, pitch, roll, counterweight).

You can make any polling class from the common polling class.

Any given polling class can have any type of inverter objects for the four inverters.

Also note how the object names read well when you use the inverter objects
from the polling class.  eg  if (pPitchInverter->IsConnected())...

If not a solution, hopefully at least adifferent way to look at the issue Smile | :)

Mark






Mark Salsbery
Microsoft MVP - Visual C++

Java | [Coffee]

GeneralRe: using New Opperator for object pointers ( Polymorphism ) Pin
led mike6-Mar-08 6:09
led mike6-Mar-08 6:09 
GeneralRe: using New Opperator for object pointers ( Polymorphism ) Pin
Mark Salsbery6-Mar-08 6:12
Mark Salsbery6-Mar-08 6:12 
GeneralRe: using New Opperator for object pointers ( Polymorphism ) Pin
led mike6-Mar-08 6:31
led mike6-Mar-08 6:31 
GeneralKnowing if the Application is already beeing executed (Previnstance) Pin
marcio kovags5-Mar-08 7:44
marcio kovags5-Mar-08 7:44 
GeneralRe: Knowing if the Application is already beeing executed (Previnstance) Pin
Randor 5-Mar-08 7:57
professional Randor 5-Mar-08 7:57 
GeneralRe: Knowing if the Application is already beeing executed (Previnstance) Pin
Joan M5-Mar-08 7:59
professionalJoan M5-Mar-08 7:59 
GeneralRe: Knowing if the Application is already beeing executed (Previnstance) Pin
CPallini5-Mar-08 8:04
mveCPallini5-Mar-08 8:04 
AnswerRe: Knowing if the Application is already beeing executed (Previnstance) Pin
Roger Stoltz5-Mar-08 21:12
Roger Stoltz5-Mar-08 21:12 
GeneralWindows Service Pin
act_x5-Mar-08 6:59
act_x5-Mar-08 6:59 
GeneralRe: Windows Service Pin
Joan M5-Mar-08 7:19
professionalJoan M5-Mar-08 7:19 
GeneralRe: Windows Service Pin
Mark Salsbery5-Mar-08 11:53
Mark Salsbery5-Mar-08 11:53 
GeneralRe: Windows Service Pin
Randor 5-Mar-08 8:13
professional Randor 5-Mar-08 8:13 
QuestionSelf-registered edit control class crashes because of wrong GetWindowTextLength return value Pin
Skarrin5-Mar-08 6:50
Skarrin5-Mar-08 6:50 
QuestionRe: Self-registered edit control class crashes because of wrong GetWindowTextLength return value Pin
CPallini5-Mar-08 8:27
mveCPallini5-Mar-08 8:27 
GeneralRe: Self-registered edit control class crashes because of wrong GetWindowTextLength return value Pin
Skarrin5-Mar-08 21:28
Skarrin5-Mar-08 21:28 
GeneralRe: Self-registered edit control class crashes because of wrong GetWindowTextLength return value Pin
Randor 5-Mar-08 8:56
professional Randor 5-Mar-08 8:56 
GeneralRe: Self-registered edit control class crashes because of wrong GetWindowTextLength return value Pin
Skarrin5-Mar-08 21:52
Skarrin5-Mar-08 21:52 

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.