[rkward-cvs] rkward/rkward/rbackend rcommandreceiver.cpp, NONE, 1.1 Makefile.am, 1.11, 1.12 rcommand.cpp, 1.9, 1.10 rcommandreceiver.h, 1.8, 1.9

Thomas Friedrichsmeier tfry at users.sourceforge.net
Sun Sep 10 18:49:04 UTC 2006


Update of /cvsroot/rkward/rkward/rkward/rbackend
In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv20538

Modified Files:
	Makefile.am rcommand.cpp rcommandreceiver.h 
Added Files:
	rcommandreceiver.cpp 
Log Message:
Move RCommandReceiver functions to a .cpp-file.
Fix a really dumb bug in RCommand::removeReceiver

--- NEW FILE: rcommandreceiver.cpp ---
/***************************************************************************
                          rcommandreceiver  -  description
                             -------------------
    begin                : Thu Aug 19 2004
    copyright            : (C) 2004,2006 by Thomas Friedrichsmeier
    email                : tfry at users.sourceforge.net
 ***************************************************************************/

/***************************************************************************
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 ***************************************************************************/
#include "rcommandreceiver.h"

#include "../debug.h"

RCommandReceiver::RCommandReceiver () {
	RK_TRACE (RBACKEND);
}

RCommandReceiver::~RCommandReceiver () {
	RK_TRACE (RBACKEND);

	for (RCommandList::const_iterator it = outstanding_commands.begin (); it != outstanding_commands.end (); ++it) {
		(*it)->removeReceiver (this);
	}
}

void RCommandReceiver::rCommandDone (RCommand *) {
	RK_TRACE (RBACKEND);
}

void RCommandReceiver::newOutput (RCommand *, ROutput *) {
	RK_TRACE (RBACKEND);
}

void RCommandReceiver::addCommand (RCommand *command) {
	RK_TRACE (RBACKEND);
	outstanding_commands.append (command);
}

void RCommandReceiver::delCommand (RCommand *command) {
	RK_TRACE (RBACKEND);
	outstanding_commands.remove (command);
}

Index: rcommand.cpp
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rbackend/rcommand.cpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** rcommand.cpp	8 Sep 2006 11:17:54 -0000	1.9
--- rcommand.cpp	10 Sep 2006 18:49:01 -0000	1.10
***************
*** 88,92 ****
  	for (int i=0; i < num_receivers; ++i) {
  		if (receivers[i] != receiver) {
! 			newlist[num_new_receivers++] = receiver;
  		}
  	}
--- 88,92 ----
  	for (int i=0; i < num_receivers; ++i) {
  		if (receivers[i] != receiver) {
! 			newlist[num_new_receivers++] = receivers[i];
  		}
  	}
***************
*** 96,99 ****
--- 96,100 ----
  	}
  
+ 	delete receivers;
  	receivers = newlist;
  	num_receivers = num_new_receivers;

Index: Makefile.am
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rbackend/Makefile.am,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** Makefile.am	21 Feb 2006 13:26:19 -0000	1.11
--- Makefile.am	10 Sep 2006 18:49:01 -0000	1.12
***************
*** 5,9 ****
  
  noinst_LIBRARIES =  librbackend.a
! librbackend_a_SOURCES = rembedinternal.cpp rinterface.cpp rthread.cpp rcommand.cpp rcommandstack.cpp \
  rkwindowcatcher.cpp
  noinst_HEADERS = rembedinternal.h rinterface.h rthread.h rcommand.h rcommandreceiver.h rcommandstack.h \
--- 5,9 ----
  
  noinst_LIBRARIES =  librbackend.a
! librbackend_a_SOURCES = rembedinternal.cpp rinterface.cpp rthread.cpp rcommand.cpp rcommandreceiver.cpp rcommandstack.cpp \
  rkwindowcatcher.cpp
  noinst_HEADERS = rembedinternal.h rinterface.h rthread.h rcommand.h rcommandreceiver.h rcommandstack.h \

Index: rcommandreceiver.h
===================================================================
RCS file: /cvsroot/rkward/rkward/rkward/rbackend/rcommandreceiver.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** rcommandreceiver.h	8 Sep 2006 11:17:54 -0000	1.8
--- rcommandreceiver.h	10 Sep 2006 18:49:01 -0000	1.9
***************
*** 3,7 ****
                               -------------------
      begin                : Thu Aug 19 2004
!     copyright            : (C) 2004 by Thomas Friedrichsmeier
      email                : tfry at users.sourceforge.net
   ***************************************************************************/
--- 3,7 ----
                               -------------------
      begin                : Thu Aug 19 2004
!     copyright            : (C) 2004,2006 by Thomas Friedrichsmeier
      email                : tfry at users.sourceforge.net
   ***************************************************************************/
***************
*** 34,48 ****
  class RCommand;
  struct ROutput;
  
  class RCommandReceiver {
  public:
  /** constructor. No args */
!     RCommandReceiver () { };
  /** destructor */
!     virtual ~RCommandReceiver () {
! 		for (QValueList<RCommand*>::const_iterator it = outstanding_commands.begin (); it != outstanding_commands.end (); ++it) {
! 			(*it)->removeReceiver (this);
! 		}
! 	};
  protected:
  	friend class RCommand;
--- 34,45 ----
  class RCommand;
  struct ROutput;
+ typedef QValueList<RCommand*> RCommandList;
  
  class RCommandReceiver {
  public:
  /** constructor. No args */
!     RCommandReceiver ();
  /** destructor */
!     virtual ~RCommandReceiver ();
  protected:
  	friend class RCommand;
***************
*** 50,63 ****
  /** This function is called when a command for this receiver is finished (and before it is deleted). You have to implement it in your subclass to do the actual handling.
  @param command A pointer to the command. The pointer is still valid during this call, but the RCommand will be deleted shortly after! */
! 	virtual void rCommandDone (RCommand *) {};
  /** This function is called when there is new output for a command or this receiver. Default implementation does nothing. Reimplement if you want to get at a command's output immediately (i.e. before the command is fully completed).
  @param command A pointer to the command
  @param output The new output-fragment */
! 	virtual void newOutput (RCommand *, ROutput *) {};
  protected:
! 	QValueList<RCommand*> outstanding_commands;
  private:
! 	void addCommand (RCommand *command) { outstanding_commands.append (command); };
! 	void delCommand (RCommand *command) { outstanding_commands.remove (command); };
  };
  
--- 47,60 ----
  /** This function is called when a command for this receiver is finished (and before it is deleted). You have to implement it in your subclass to do the actual handling.
  @param command A pointer to the command. The pointer is still valid during this call, but the RCommand will be deleted shortly after! */
! 	virtual void rCommandDone (RCommand *);
  /** This function is called when there is new output for a command or this receiver. Default implementation does nothing. Reimplement if you want to get at a command's output immediately (i.e. before the command is fully completed).
  @param command A pointer to the command
  @param output The new output-fragment */
! 	virtual void newOutput (RCommand *, ROutput *);
  protected:
! 	RCommandList outstanding_commands;
  private:
! 	void addCommand (RCommand *command);
! 	void delCommand (RCommand *command);
  };
  





More information about the rkward-tracker mailing list