Code Search for Developers
 
 
  

kmission.h from Spatial Knowledge Experiments at Krugle


Show kmission.h syntax highlighted

/*
    Copyright (C) 2003, 2004, 2005 by Luca Cappa
    Written by Luca Cappa groton@users.sourceforge.net
  
    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.
  
    This library 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
    Library General Public License for more details.
  
    You should have received a copy of the GNU Library General Public
    License along with this library; if not, write to the Free
    Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/

#ifndef __KMISSION_H__
#define __KMISSION_H__

#include "ikmission.h"
#include "kdata.h"
#include "kdatalist.h"
#include "kpathfollower.h"
#include "csutil/schedule.h"

class scfString;
class csVector3;
struct iString;
class csSchedule;
struct iDocumentNode;

class KLandmark;
class KData;
class KDataList;
class KPathFollower;
class KMissionType;


#ifndef NEW_MISSION_DESIGN

//constants definition.


//----------------------------------------------------
//KMission
//----------------------------------------------------
class KMission : public iKMission
{
protected:
  csRef<iString> m_name;
  
  int m_missionType;
  
  KDataList m_dataList;//created inside.
  csSchedule m_scheduler;//created inside.
  
  bool m_collectingData;
  
  csRef<KPlayer> m_player;//comes from the external.
  csRef<KMap> m_map;//comes from the external.
  csRef<KLandmarkList> m_landmarks;//comes from the external.
  csRef<KPosition> m_position;//comes from the external.
  
public:
  SCF_DECLARE_IBASE;
  
  KMission::KMission (const char* p_name, KPosition* p_position,
    KPlayer* p_player, KMap* p_wM, KLandmarkList* p_lL, 
    bool p_collectData = true);
  KMission ();
  virtual ~KMission ();
  
  //
  //methods.
  
  /*
  
    INPUT
    
  */
  virtual const char* GetName() ;
  virtual void SetName (const char* p_name);
  
  virtual  KPosition* GetInitPosition () ;
  virtual void SetInitPosition ( KPosition* p_pos);
  
  virtual  KMap* GetMap () ;
  virtual void SetMap (KMap*);
  
  virtual  KLandmarkList* GetLandmarks ();
  virtual void SetLandmarks (KLandmarkList *);
  
  
  /*
  
    OUTPUT
    
  */
  virtual float GetMinutes ();
  virtual float GetMeters ();
  virtual KDataList* GetDataList ();
  
  
  
  
  virtual KMissionType const& GetMissionType () ;
  virtual bool GetCollectingData() ;  
  
  virtual bool SaveMissionInfo (iDocumentNode* p_node) ;
  virtual bool LoadMissionInfo (iDocumentNode* p_node) ;
  
  int m_currentTime;//msecs
  
  //
  //
  static void MissionCallback (void *p_arg);
  
  //
  //Data recording methods.
  virtual void StartRecording (int p_intervalMs);
  virtual void Record (int p_elapsedTimeMs);
  virtual void StopRecording ();
  
};

//----------------------------------------------------
//KFreeWalkingMission
//----------------------------------------------------
class KFreeWalkingMission : public KMission, public iKFreeWalkingMission
{
protected:
/**
A value of -1 means unlimited time.
  */
  float m_allowedMinutes;
public:
  
  KFreeWalkingMission::KFreeWalkingMission (char* p_name, 
    KPosition* p_pos,
    KPlayer* p_player,
    float p_allowedMinutes,
    KMap* p_wM,  KLandmarkList* p_lL, bool p_collectingData = true);
  KFreeWalkingMission ();
  virtual KFreeWalkingMission::~KFreeWalkingMission ();
  
  /*
  
    INPUT
    
  */
  virtual float GetAllowedMinutes ();
  virtual void SetAllowedMinutes (float);
  
  virtual bool WriteAdditionalInfo (iDocumentNode* p_parent);
  virtual bool ReadAdditionalInfo (iDocumentNode* p_parent);
  
  SCF_DECLARE_IBASE_EXT (KMission);
};


//----------------------------------------------------
//NotKFreeWalkingMission
//----------------------------------------------------
class KNotFreeWalkingMission : public KMission, public iKNotFreeWalkingMission
{
protected:
  csRef<KPath> m_path;
public:
  
  KNotFreeWalkingMission::KNotFreeWalkingMission (char* p_name,
    KPosition* p_pos,
    KPlayer* p_player,
    KPath* p_path,  KMap* p_wM, 
    KLandmarkList* p_lL, bool p_collectingData = true);
  KNotFreeWalkingMission ();
  virtual KNotFreeWalkingMission::~KNotFreeWalkingMission ();
  
  /*
  
    INPUT
    
  */
  virtual KPath* GetPath ();
  virtual void SetPath (KPath*);
  
  virtual bool WriteAdditionalInfo (iDocumentNode* p_parent);
  virtual bool ReadAdditionalInfo (iDocumentNode* p_parent);
  
  SCF_DECLARE_IBASE_EXT (KMission);
};


//----------------------------------------------------
//KTargetingMission 
//----------------------------------------------------
class KTargetingMission : public KMission, public iKTargetingMission
{
protected:
/*/**
A value of NULL is ILLEGAL!
  KLandmark* m_target;*/
  csRef<scfString> m_targetName;
  
  /**
   * A list of colliders for the target.
   */
  csRefArray<iCollider> m_collidersList;
  
  /**
   * A value of 0 means no path to follow.
   */
  csRef<KPath> m_path;
  KPathFollower* m_pathFollower;
  
  /**
   * A value of -1 means unlimited time.
   */
  float m_allowedMinutes;
  
  /**
   * Init the m_collidersList field.
   */
  void CreateTargetCollider ();
  
public:
  
  KTargetingMission (char const* p_name, 
    KPosition* p_pos,
    KPlayer* p_player,
    char const* p_targetName,
    KPath* p_path, float p_allowedTime,
    KMap* p_wM,  KLandmarkList* p_lL,
    bool p_collectingData = true);
  KTargetingMission ();
  virtual ~KTargetingMission ();
  
  
  /*
  
    INPUT
    
  */
  virtual const char* GetTargetName ();
  virtual void SetTargetName (const char*);
  virtual KPath* GetPath ();
  virtual void SetPath (KPath*);
  virtual float GetAllowedMinutes ();
  virtual void SetAllowedMinutes (float);
  
  
  virtual KPathFollower* GetPathFollower ();
  virtual KLandmark* GetTarget ();
  
  
  virtual bool WriteAdditionalInfo (iDocumentNode* p_parent);
  virtual bool ReadAdditionalInfo (iDocumentNode* p_parent);
  
  virtual csRefArray<iCollider>* GetColliders ();
  
  SCF_DECLARE_IBASE_EXT (KMission);
};


//----------------------------------------------------
//KPointingTargetMission 
//----------------------------------------------------
class KPointingTargetMission : public KMission, public iKPointingTargetMission
{
protected:
  csRef<scfString> m_targetName;
public:
  
  KPointingTargetMission::KPointingTargetMission (char* p_name, 
    KPosition* p_pos,
    KPlayer* p_player,
    /*KLandmark* p_target,*/ char const* p_targetName,
    KMap* p_wM,  KLandmarkList* p_lL, 
    bool p_collectingData = true);
  KPointingTargetMission ();
  
  virtual ~KPointingTargetMission ();
  
  virtual KLandmark* GetTarget ();
  virtual  char* GetTargetName ();
  virtual void SetTargetName (const char*);
  
  virtual float CalculateAngle ();
  
  virtual bool WriteAdditionalInfo (iDocumentNode* p_parent);
  virtual bool ReadAdditionalInfo (iDocumentNode* p_parent);
  
  SCF_DECLARE_IBASE_EXT (KMission);
};


#else //NEW_MISSION_DESIGN








class KMission : public iKMission
{
  SCF_DECLARE_IBASE;
  
  csRefArray<iGeneralTester> m_genTester;
  
  KMission ()
  {
    scfiEventHandler = 0;
    
    SetupEventHandler ();
  }
  
  virtual ~KMission ()
  {
    if (scfiEventHandler)
    {
      csRef<iEventQueue> l_q (CS_QUERY_REGISTRY (g_objReg, iEventQueue));
      if (l_q)
        l_q->RemoveListener (scfiEventHandler);
      scfiEventHandler->DecRef ();
    }//if
  }
  
  bool AddGeneralTester (iGeneralTester* p_gT)
  {
    if (m_genTester.Find (p_gT) == -1)
    {
      m_genTester.Push (p_gT);
      return true;
    }//if
    else
      return false;
  }
  
  void SetupEventHandler ()
  {
    if (!scfiEventHandler)
    {
      scfiEventHandler = new EventHandler (this);
    }
    csRef<iEventQueue> l_q (CS_QUERY_REGISTRY (g_objReg, iEventQueue));
    CS_ASSERT (l_q != 0);
    l_q->RemoveListener (scfiEventHandler);
    unsigned int l_trigger = CSMASK_Nothing;
    l_q->RegisterListener (scfiEventHandler, l_trigger);
  }
  
  bool HandleEvent (iEvent& p_ev);
  
  
  // This is not an embedded interface in order to avoid
  // a circular reference between this registered event handler
  // and the parent object.
  class EventHandler : public iEventHandler
  {
  private:
    iKMission* m_parent;
  public:
    EventHandler (KMission* p_parent)
    {
      SCF_CONSTRUCT_IBASE (NULL);
      EventHandler::m_parent = p_parent;
    }
    virtual ~EventHandler () { }
    SCF_DECLARE_IBASE;
    virtual bool HandleEvent (iEvent& ev)
    {
      return m_parent->HandleEvent (ev);
    }
  } *scfiEventHandler;
  
};


SCF_IMPLEMENT_IBASE (KMission)
  SCF_IMPLEMENTS_INTERFACE (iKMission)
SCF_IMPLEMENT_IBASE_END


SCF_IMPLEMENT_IBASE (KMission::EventHandler)
  SCF_IMPLEMENTS_INTERFACE (iEventHandler)
SCF_IMPLEMENT_IBASE_END




#endif //NEW_MISSION_DESIGN









#endif





See more files for this project here

Spatial Knowledge Experiments

A simulation of 3D virtual worlds for psychological experiments

Project homepage: http://sourceforge.net/projects/ske
Programming language(s): C,C++,Perl
License: other

  isense/
  joystick/
  Jamfile
  KImageCardinalDirection.h
  SKE.cpp
  SKE.h
  eulerangles.c
  eulerangles.h
  ikdraggable.cpp
  ikdraggable.h
  ikdraghandler.h
  ikmission.h
  ikxmlreader.h
  ikxmlwriter.h
  kappstate.cpp
  kappstate.h
  kbasedraggable.cpp
  kbasedraggable.h
  kbasedraghandler.cpp
  kbasedraghandler.h
  kblock.cpp
  kblock.h
  kblockId.h
  kblockid.cpp
  kcamera.cpp
  kcamera.h
  kcollision.cpp
  kcommandprocessor.cpp
  kcommandprocessor.h
  kconstant.cpp
  kconstant.h
  kcursor3d.cpp
  kcursor3d.h
  kdata.cpp
  kdata.h
  kdatalist.cpp
  kdatalist.h
  kdragmanager.cpp
  kdragmanager.h
  keventhandlermanager.cpp
  keventhandlermanager.h
  kflags.cpp
  kflags.h
  kimagecardinaldirection.cpp
  kkeys.cpp
  kkeys.h
  kkeystate.cpp
  kkeystate.h
  klandmark.cpp
  klandmark.h
  klandmarklist.cpp
  klandmarklist.h
  klight.cpp
  klight.h
  klightlist.cpp
  klightlist.h
  kmap.cpp
  kmap.h
  kmission.cpp
  kmission.h
  kmissiontype.cpp
  kmissiontype.h
  kmode.cpp
  kmode.h
  kmousemanager.cpp
  kmousemanager.h
  kobject3d.cpp
  kobject3d.h
  korientation.cpp
  korientation.h
  kpath.cpp
  kpath.h
  kpathfollower.cpp
  kpathfollower.h
  kplayer.cpp
  kplayer.h
  kposition.cpp
  kposition.h
  kquaternion.cpp
  kquaternion.h
  ksaveddatamanager.cpp
  ksaveddatamanager.h
  ksegment3.h
  ksign.cpp
  ksign.h
  ksprite3d.cpp
  ksprite3d.h
  ksprite3dlist.cpp
  ksprite3dlist.h
  kterrain.cpp
  kterrain.h
  kthing.cpp
  kthing.h
  kutil.cpp
  kutil.h
  kwireframe.cpp
  kwireframe.h
  kxmlhelper.h
  movement1d.h
  movement3d.h
  quattypes.h