File: Effector.h

package info (click to toggle)
mercator 0.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,008 kB
  • sloc: sh: 10,433; cpp: 4,482; makefile: 115
file content (78 lines) | stat: -rw-r--r-- 1,772 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// This file may be redistributed and modified only under the terms of
// the GNU General Public License (See COPYING for details).
// Copyright (C) 2010 Alistair Riddoch

#ifndef MERCATOR_EFFECTOR_H
#define MERCATOR_EFFECTOR_H

#include <wfmath/axisbox.h>
#include <wfmath/polygon.h>

#include <string>

namespace Mercator
{

class Segment;
class Shader;

/// \brief Device which effects a change in the terrain
///
/// Classes which inherit from this interface change the terrain in
/// some way within the region given by the box member. The exact
/// shape of the area affected and the nature of the change depends
/// on the subclass.
class Effector
{
  public:
    class Context {
      public:
        Context();

        virtual ~Context();

        const std::string & id() { return m_id; }

        void setId(const std::string &);
      protected:
        std::string m_id;
    };

    Context * context() const { return m_context; }

    void setContext(Context *);

    /// Accessor for the bounding box of the geometric shape.
    const WFMath::AxisBox<2> & bbox() const
    {
        return m_box;
    }

    virtual ~Effector() = 0;

    virtual bool checkIntersects(const Segment& s) const = 0;

    virtual int addToSegment(Segment &) const = 0;
    virtual void updateToSegment(Segment &) const = 0;
    virtual void removeFromSegment(Segment &) const = 0;
    
  protected:
    /// \brief Constructor
    Effector();

    /// \brief Copy constructor
    Effector(const Effector &);

    /// \brief Assignment
    Effector & operator=(const Effector &);

    /// The bounding box of the geometric shape.
    WFMath::AxisBox<2> m_box;
    
    /// The application context of this effector
    Context * m_context;
};

}

#endif // of MERCATOR_EFFECTOR_H