~ubuntu-branches/ubuntu/trusty/hugin/trusty-proposed

« back to all changes in this revision

Viewing changes to src/hugin_base/makefilelib/MakefileItem.h

  • Committer: Bazaar Package Importer
  • Author(s): Andreas Metzler
  • Date: 2011-01-06 14:28:24 UTC
  • mfrom: (1.1.9 upstream) (0.1.21 experimental)
  • Revision ID: james.westby@ubuntu.com-20110106142824-zn9lxylg5z44dynn
* Drop Cyril Brulebois from Uploaders. Thank you very much for your work.
* Bump package version. (rc3 was re-released as 2010.4.0).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
This file is part of hugin.
 
3
 
 
4
hugin is free software: you can redistribute it and/or modify
 
5
it under the terms of the GNU General Public License as published by
 
6
the Free Software Foundation, either version 2 of the License, or
 
7
(at your option) any later version.
 
8
 
 
9
hugin is distributed in the hope that it will be useful,
 
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
GNU General Public License for more details.
 
13
 
 
14
You should have received a copy of the GNU General Public License
 
15
along with hugin.  If not, see <http://www.gnu.org/licenses/>.
 
16
*/
 
17
 
 
18
/**
 
19
 * @file MakefileItem.h
 
20
 * @brief
 
21
 *  Created on: May 25, 2010
 
22
 * @author Florian Achleitner <florian.achleitner.2.6.31@gmail.com>
 
23
 */
 
24
 
 
25
#ifndef MAKEFILEITEM_H_
 
26
#define MAKEFILEITEM_H_
 
27
 
 
28
#include "Makefile.h"
 
29
#include "Manageable.h"
 
30
 
 
31
namespace makefile
 
32
{
 
33
 
 
34
/**
 
35
 * The virtual baseclass for all objects that appear in the Makefile.
 
36
 * Subclasses must implement \ref print which allows us to write them to
 
37
 * an ostream, like a string, nice :).
 
38
 * The various implementations of \ref print have to take care of proper
 
39
 * makefile compatible output.
 
40
 */
 
41
class MAKEIMPEX MakefileItem
 
42
{
 
43
        bool added;
 
44
public:
 
45
        MakefileItem()
 
46
        :added(false)
 
47
        {
 
48
        }
 
49
 
 
50
        /// Removes the item from the Makefile
 
51
        virtual ~MakefileItem()
 
52
        {
 
53
                if(added)
 
54
                        Makefile::remove(this);
 
55
        }
 
56
 
 
57
        /// @return A string representation of the MakefileItem.
 
58
        virtual string toString()=0;
 
59
        /// Write the items representation to an ostream in a makefile compatible way.
 
60
        void print(ostream& os)
 
61
        {
 
62
                os << toString();
 
63
        }
 
64
        /// Allow casts to string, very nice!
 
65
        operator string()
 
66
        {
 
67
                return toString();
 
68
        }
 
69
 
 
70
        /// Adds this to the Makefile item list.
 
71
        virtual void add()
 
72
        {
 
73
                Makefile::getSingleton().add(this);
 
74
                added = true;
 
75
        }
 
76
 
 
77
};
 
78
 
 
79
/// Allows writing to ostreams.
 
80
MAKEIMPEX ostream& operator<<(ostream& stream, MakefileItem& item);
 
81
 
 
82
/// Allows adding strings an MakefileItems
 
83
MAKEIMPEX string operator+(const string& str, MakefileItem& item);
 
84
/// Allows adding strings an MakefileItems
 
85
MAKEIMPEX string operator+(MakefileItem& item, const string& str);
 
86
 
 
87
/**
 
88
 * This class is used to mark MakefileItems that can be used directly, like most can.
 
89
 * The only exception is currently VariableDef and VariableRef, they can only be used
 
90
 * together with their parent Variable.
 
91
 */
 
92
class MAKEIMPEX PrimaryMakefileItem : public MakefileItem, public Manageable
 
93
{
 
94
public:
 
95
        PrimaryMakefileItem() {}
 
96
        virtual ~PrimaryMakefileItem() {}
 
97
};
 
98
 
 
99
}
 
100
#endif /* MAKEFILEITEM_H_ */