summaryrefslogtreecommitdiff
path: root/i
diff options
context:
space:
mode:
Diffstat (limited to 'i')
-rwxr-xr-xi/siroco/src/pg_test/Makefile14
-rw-r--r--i/siroco/src/pg_test/message.cc49
-rw-r--r--i/siroco/src/pg_test/message.h69
-rw-r--r--i/siroco/src/pg_test/message_test.cc5
4 files changed, 131 insertions, 6 deletions
diff --git a/i/siroco/src/pg_test/Makefile b/i/siroco/src/pg_test/Makefile
index 51078ad..50e0d3d 100755
--- a/i/siroco/src/pg_test/Makefile
+++ b/i/siroco/src/pg_test/Makefile
@@ -1,6 +1,6 @@
# Mon Makefile
TARGET_A = message_test
-OBJECTS_A = ../message.o
+OBJECTS_A = message_test.o message.o
# TARGET_B =
# OBJECTS_B =
@@ -11,10 +11,14 @@ CFLAGS = -O2 -Wall -g
CC = g++
-all: $(TARGET_A) $(TARGET_B)
+all: $(TARGET_A)
+# $(TARGET_B)
$(TARGET_A): $(OBJECTS_A)
- $(CC) $(CFLAGS) -o $@ $^ $(LIB)
+ $(CC) $(CFLAGS) -o $@ $^
+
-$(TARGET_B): $(OBJECTS_B)
- $(CC) $(CFLAGS) -o $@ $^ $(LIB)
+#$(LIB)
+
+# $(TARGET_B): $(OBJECTS_B)
+# $(CC) $(CFLAGS) -o $@ $^ $(LIB)
diff --git a/i/siroco/src/pg_test/message.cc b/i/siroco/src/pg_test/message.cc
new file mode 100644
index 0000000..d92a1dc
--- /dev/null
+++ b/i/siroco/src/pg_test/message.cc
@@ -0,0 +1,49 @@
+// message.cc
+// {{{
+//
+// Copyright (C) 2003 Nicolas Schodet et Pierre-André Galmes
+//
+// Robot APB Team/Efrei 2004.
+// Web: http://assos.efrei.fr/robot/
+// Email: robot AT efrei DOT fr
+//
+// 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.
+//
+// This program 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 program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+// }}}
+#include "message.h"
+
+namespace Siroco
+{
+
+// Constructeur.
+Message::Message (Type type)
+{
+ type_ = type;
+}
+
+// Destructeur et Big 3.
+Message::~Message (void)
+{
+}
+
+// Récupère le type du message.
+//int
+Type
+Message::getType (void) const
+{
+ return type_;
+}
+
+} // namespace Siroco
diff --git a/i/siroco/src/pg_test/message.h b/i/siroco/src/pg_test/message.h
new file mode 100644
index 0000000..0c6943b
--- /dev/null
+++ b/i/siroco/src/pg_test/message.h
@@ -0,0 +1,69 @@
+#ifndef message_h
+#define message_h
+// message.h
+// {{{
+//
+// Copyright (C) 2003 Nicolas Schodet et Pierre-André Galmes
+//
+// Robot APB Team/Efrei 2004.
+// Web: http://assos.efrei.fr/robot/
+// Email: robot AT efrei DOT fr
+//
+// 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.
+//
+// This program 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 program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+//
+// }}}
+
+namespace Siroco
+{
+
+class Message
+{
+ // Type du message contenu.
+ enum Type
+ {
+ typeAsservissementData,
+ typeAsservissementControl,
+ typeAsservissementGetInfo,
+ typeAsservissementInfo,
+ typeMax
+ };
+ private:
+ Type type_;
+ public:
+ // Constructeur.
+ Message (Type type);
+ // Destructeur et Big 3.
+ virtual ~Message (void);
+ // Récupère le type du message.
+ Type getType (void) const;
+ // Récupère le message.
+ template<typename T>
+ const T &get (void) const;
+ private:
+ // Méthodes interdites.
+ Message (const Message &);
+ Message &operator= (const Message &);
+};
+
+// Récupère le message.
+template<typename T>
+const T &Message::get (void) const
+{
+ return dynamic_cast<T> (*this);
+}
+
+} // namespace Siroco
+
+#endif // message_h
diff --git a/i/siroco/src/pg_test/message_test.cc b/i/siroco/src/pg_test/message_test.cc
index d17ad2b..6e5989b 100644
--- a/i/siroco/src/pg_test/message_test.cc
+++ b/i/siroco/src/pg_test/message_test.cc
@@ -28,7 +28,10 @@
int main ()
{
- Type mt = typeAsservissementData;
+ Type mt;
+
+ mt = typeAsservissementData;
+
Message m (mt);
switch (m.getType ())