Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

action.h

Go to the documentation of this file.
00001 /*
00002   svas_server -- virtual World Server of Svas
00003   Copyright (c) 2001, 2002 David Moreno Montero
00004  
00005  
00006   This program is free software; you can redistribute it and/or modify
00007   it under the terms of the GNU General Public License as published by
00008   the Free Software Foundation; either version 2 of the License, or
00009   (at your option) any later version.
00010  
00011   This program is distributed in the hope that it will be useful, but
00012   WITHOUT ANY WARRANTY; without even the implied warranty of
00013   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014   General Public License for more details.
00015  
00016   You should have received a copy of the GNU General Public License
00017   along with this program; if not, write to the Free Software
00018   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00019   02111-1307, USA.  
00020 
00021 */
00022 
00023 #ifndef __ACTION__
00024 #define __ACTION__
00025 
00026 /** 
00027  * type of grow (horizontal is radius grow) 
00028  * @see Action, Cylinder, Agent, Client::grow
00029  */
00030 typedef enum{
00031   growVertical=0,
00032   growHorizontal=1
00033 }GrowType;
00034 
00035 /**
00036  * Type of movement that the cylinder can do. CW is clockwise, CCW is
00037  * counterclockwise 
00038  * @see Action, Cylinder, Agent, Client::move
00039  */
00040 typedef enum{
00041   moveVerticalCW=0,
00042   moveHorizontalCW=1,
00043   moveVerticalCCW=2,
00044   moveHorizontalCCW=3,
00045   moveUnknown=0xFF
00046 }MoveType;
00047 
00048 /** 
00049  * Actions that a cylinder may want to perform 
00050  * @see Cylinder
00051  */
00052 typedef enum{
00053   none=0,
00054   newCylinder=1,
00055   growTo=2,
00056   belittle=3,
00057   moveCylinder=4,
00058   dropCylinder=5,
00059   sendEnergy=6,
00060   sendMessageAction=7
00061 }ActionList;
00062 
00063 /**
00064  * The action (and related variables) that a cylinder may want to
00065  * perform, if any.
00066  *
00067  * Some variables are in unions, in order to save some memory
00068  *
00069  * @see Cylinder
00070  */
00071 struct Action{
00072   ActionList action;
00073   short int energy;
00074   union {
00075     char type;
00076     GrowType growType;
00077     MoveType moveType;
00078   };
00079   unsigned char cylinder;
00080   unsigned long int agentId;
00081   union{
00082     double angle;
00083     char *message;
00084   };
00085   union{
00086     double height;
00087     unsigned long int messageSize;
00088   };
00089 
00090   /// Minimal impersonal constructor
00091   Action(){ action=none; }
00092   ~Action();
00093 
00094   /// Full, impersonal, ugly constructor
00095   Action(ActionList _action, unsigned short int _energy, 
00096      char _type, unsigned char _cylinder);
00097 
00098   /// Personalized for new cylinder
00099   Action(double angle, double height, unsigned short int _energy);
00100   /// Personalized edition to grow
00101   Action(unsigned short int _energy, GrowType type);
00102   /// Personalized edition to move
00103   Action(unsigned short int _energy, MoveType type);
00104   /// Personalized edition to send energy
00105   Action(unsigned char son, unsigned short int _energy);
00106   // Personalized edition to drop son
00107   Action(unsigned char son, const  char *creationMessage, unsigned long int messageSize);
00108   // Personalized edition to send Message
00109   Action(unsigned long int agentId, unsigned long int messageSize, const  char *message);
00110 };
00111 
00112 
00113 
00114 #endif

Generated on Mon Jun 17 19:53:43 2002 for Svas Server by doxygen1.2.16