ArtMOO
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
G:/dev/qt/MOO/ServerCore/task.h
Go to the documentation of this file.
00001 #ifndef TASK_H
00002 #define TASK_H
00003 
00004 #include <QString>
00005 #include <QList>
00006 #include <QStringList>
00007 
00008 #include "mooglobal.h"
00009 #include <lua.hpp>
00010 #include "taskentry.h"
00011 
00012 class Connection;
00013 
00014 class Task
00015 {
00016 private:
00017         TaskId                           mId;                                   // the task id
00018         qint64                           mTimeStamp;                    // when the task was created
00019         QString                          mCommand;                              // the command
00020         ObjectId                         mPlayer;                               // the player who typed the command
00021         ObjectId                         mObject;                               // the object on which this verb was found
00022         ObjectId                         mCaller;                               // the same as `player'
00023         QString                          mVerb;                                 // the first word of the command
00024         QString                          mArgStr;                               // everything after the first word of the command
00025         QStringList                      mArgs;                                 // the words in `argstr'
00026         QString                          mDirectObjectName;             // the direct object string found during parsing
00027         ObjectId                         mDirectObjectId;               // the direct object value found during matching
00028         QString                          mIndirectObjectName;   // the indirect object string
00029         ObjectId                         mIndirectObjectId;             // the indirect object value
00030         QString                          mPreposition;                  // the prepositional phrase found during parsing
00031         ObjectId                         mProgrammerId;
00032 
00033         const static char       *mPrepositionList[];
00034 
00035         friend class lua_task;
00036 
00037 public:
00038         Task( const QString &pCommand = "" );
00039 
00040         Task( const TaskEntry &pEntry );
00041 
00042         virtual ~Task( void );
00043 
00044         inline TaskId id( void ) const
00045         {
00046                 return( mId );
00047         }
00048 
00049         inline ObjectId player( void ) const
00050         {
00051                 return( mPlayer );
00052         }
00053 
00054         inline ObjectId object( void ) const
00055         {
00056                 return( mObject );
00057         }
00058 
00059         inline ObjectId caller( void ) const
00060         {
00061                 return( mCaller );
00062         }
00063 
00064         inline const QString &verb( void ) const
00065         {
00066                 return( mVerb );
00067         }
00068 
00069         inline const QString argstr( void ) const
00070         {
00071                 return( mArgStr );
00072         }
00073 
00074         inline const QStringList &args( void ) const
00075         {
00076                 return( mArgs );
00077         }
00078 
00079         inline qint64 timestamp( void ) const
00080         {
00081                 return( mTimeStamp );
00082         }
00083 
00084         inline void setId( TaskId pId )
00085         {
00086                 mId = pId;
00087         }
00088 
00089         inline void setPlayer( ObjectId pPlayer )
00090         {
00091                 mPlayer = pPlayer;
00092         }
00093 
00094         inline void setArgStr( const QString &pArgStr )
00095         {
00096                 mArgStr = pArgStr;
00097         }
00098 
00099         inline void setArgs( const QStringList &pArgs )
00100         {
00101                 mArgs = pArgs;
00102         }
00103 
00104         inline void setVerb( const QString &pVerb )
00105         {
00106                 mVerb = pVerb;
00107         }
00108 
00109         void setCaller( ObjectId pId )
00110         {
00111                 mCaller = pId;
00112         }
00113 
00114         inline void setObject( ObjectId pId )
00115         {
00116                 mObject = pId;
00117         }
00118 
00119         inline void setTimeStamp( qint64 pTime )
00120         {
00121                 mTimeStamp = pTime;
00122         }
00123 
00124         inline const QString &command( void ) const
00125         {
00126                 return( mCommand );
00127         }
00128 
00129         inline const QString &directObjectName( void ) const
00130         {
00131                 return( mDirectObjectName );
00132         }
00133 
00134         inline ObjectId directObjectId( void ) const
00135         {
00136                 return( mDirectObjectId );
00137         }
00138 
00139         inline const QString &indirectObjectName( void ) const
00140         {
00141                 return( mIndirectObjectName );
00142         }
00143 
00144         inline ObjectId indirectObjectId( void ) const
00145         {
00146                 return( mIndirectObjectId );
00147         }
00148 
00149         inline const QString &preposition( void ) const
00150         {
00151                 return( mPreposition );
00152         }
00153 
00154         inline void setDirectObjectName( const QString &pName )
00155         {
00156                 mDirectObjectName = pName;
00157         }
00158 
00159         inline void setDirectObjectId( ObjectId pId )
00160         {
00161                 mDirectObjectId = pId;
00162         }
00163 
00164         inline void setIndirectObjectName( const QString &pName )
00165         {
00166                 mIndirectObjectName = pName;
00167         }
00168 
00169         inline void setIndirectObjectId( ObjectId pId )
00170         {
00171                 mIndirectObjectId = pId;
00172         }
00173 
00174         inline void setPreposition( const QString &pName )
00175         {
00176                 mPreposition = pName;
00177         }
00178 
00179         inline ObjectId programmer( void ) const
00180         {
00181                 return( mProgrammerId );
00182         }
00183 
00184         inline void setProgrammer( ObjectId pObjectId )
00185         {
00186                 mProgrammerId = pObjectId;
00187         }
00188 
00189         void findObject( const QString &pName, QList<ObjectId> &pId ) const;
00190 
00191 private:
00192         int findPreposition( const QStringList &pWords );
00193 
00194         void getDirectAndIndirect( const QStringList &pWords, int pPrpIdx );
00195 };
00196 
00197 #endif // TASK_H