[ogs-changes] dist/c++/ogs/support Utility.h,NONE,1.1 Makefile.am,1.4,1.5 Observer.h,1.1,1.2
Status: Alpha
Brought to you by:
elemings
|
From: <ele...@us...> - 2003-04-13 05:28:49
|
Update of /cvsroot/ogs/dist/c++/ogs/support
In directory sc8-pr-cvs1:/tmp/cvs-serv9867/support
Modified Files:
Makefile.am Observer.h
Added Files:
Utility.h
Log Message:
See C++ ChangeLog (Apr 13) for details.
--- NEW FILE: Utility.h ---
/*
* Utility.h -- class interface for utilities
* Copyright (C) 2003 Eric Lemings <ele...@us...>
*
* This software 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.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA
*
* RCS: $Id: Utility.h,v 1.1 2003/04/13 05:28:46 elemings Exp $
*/
#ifdef __cplusplus
# ifndef OGS_SUPPORT_UTILITY_H
# define OGS_SUPPORT_UTILITY_H
# include <ogs/support/Namespace.h>
OGS_BEGIN_SUPPORT_NAMESPACE
/**
* A function object that destroys allocated memory. A Destroy object
* destroys allocated memory by calling the delete operator on pointers.
* These objects can be used conveniently with standard containers and
* algorithms.
*/
struct Destroy {
template <typename T>
void operator() (const T* t) const;
};
/**
* Destroy allocated memory. The allocated memory is destroyed by
* calling the delete operator on a pointer of type T. The type T is
* specified by the template parameter.
*
* @param t A pointer to allocated memory of type T.
*/
template <typename T>
void Destroy::operator() (const T* t) const {
delete t;
}
OGS_END_SUPPORT_NAMESPACE
# endif /* !defined OGS_SUPPORT_UTILITY_H */
#endif /* defined __cplusplus */
Index: Makefile.am
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/support/Makefile.am,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Makefile.am 29 Mar 2003 02:10:40 -0000 1.4
--- Makefile.am 13 Apr 2003 05:28:46 -0000 1.5
***************
*** 29,33 ****
Namespace.h \
Object.h \
! Observer.h
INCLUDES = \
--- 29,34 ----
Namespace.h \
Object.h \
! Observer.h \
! Utility.h
INCLUDES = \
Index: Observer.h
===================================================================
RCS file: /cvsroot/ogs/dist/c++/ogs/support/Observer.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Observer.h 7 Jan 2003 07:41:34 -0000 1.1
--- Observer.h 13 Apr 2003 05:28:46 -0000 1.2
***************
*** 31,34 ****
--- 31,35 ----
class Event;
+ //class Object;
/**
***************
*** 41,45 ****
--- 42,56 ----
public:
virtual ~Observer () { }
+
+ protected:
+ /**
+ * Handle an event. Observers must implement this function. No
+ * default event handler is provided by the Observer class.
+ *
+ * @param event An event from an observed object.
+ */
virtual void handleEvent (Event& event) = 0;
+
+ friend void Object::notifyObservers (Event& event);
};
|