~ubuntu-branches/ubuntu/raring/openwalnut/raring

« back to all changes in this revision

Viewing changes to src/core/kernel/WProjectFile.h

  • Committer: Package Import Robot
  • Author(s): Sebastian Eichelbaum
  • Date: 2012-12-12 11:26:32 UTC
  • mfrom: (3.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20121212112632-xhiuwkxuz5h0idkh
Tags: 1.3.1+hg5849-1
* Minor changes compared to 1.3.0 but included several bug fixes.
* See http://www.openwalnut.org/versions/4

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#include <string>
29
29
#include <vector>
30
30
 
31
 
// Use filesystem version 2 for compatibility with newer boost versions.
32
 
#ifndef BOOST_FILESYSTEM_VERSION
33
 
    #define BOOST_FILESYSTEM_VERSION 2
34
 
#endif
35
31
#include <boost/filesystem.hpp>
36
32
#include <boost/shared_ptr.hpp>
 
33
#include <boost/function.hpp>
 
34
#include <boost/signals2/signal.hpp>
37
35
 
38
36
#include "../common/WProjectFileIO.h"
39
 
#include "WExportKernel.h"
 
37
 
40
38
 
41
39
/**
42
40
 * Class loading project files. This class opens an file and reads it line by line. It delegates the actual parsing to each of the known
43
41
 * WProjectFileIO instances which then do their job.
44
42
 */
45
 
class OWKERNEL_EXPORT WProjectFile: public WThreadedRunner,
46
 
                                      public boost::enable_shared_from_this< WProjectFile >
 
43
class WProjectFile: public WThreadedRunner,
 
44
                    public boost::enable_shared_from_this< WProjectFile >
47
45
{
48
46
public:
49
 
 
50
 
    /**
51
 
     * Default constructor. It does NOT parse the file. Parsing is done by apply().
 
47
    /**
 
48
     * Abbreviation for a shared pointer.
 
49
     */
 
50
    typedef boost::shared_ptr< WProjectFile > SPtr;
 
51
 
 
52
    /**
 
53
     * Abbreviation for const shared pointer.
 
54
     */
 
55
    typedef boost::shared_ptr< const WProjectFile > ConstSPtr;
 
56
 
 
57
    /**
 
58
     * A callback function type reporting bach a finished load job. The given string vector contains a list of errors if any.
 
59
     */
 
60
    typedef boost::function< void( boost::filesystem::path, std::vector< std::string >  ) > ProjectLoadCallback;
 
61
 
 
62
    /**
 
63
     * A callback function signal type reporting bach a finished load job. The given string vector contains a list of errors if any.
 
64
     */
 
65
    typedef boost::signals2::signal< void( boost::filesystem::path, std::vector< std::string >  ) > ProjectLoadCallbackSignal;
 
66
 
 
67
    /**
 
68
     * Default constructor. It does NOT parse the file. Parsing is done by using load.
 
69
     *
 
70
     * \param project the project file to load or save.
 
71
     */
 
72
    explicit WProjectFile( boost::filesystem::path project );
 
73
 
 
74
    /**
 
75
     * Default constructor. It does NOT parse the file. Parsing is done by using load.
52
76
     *
53
77
     * \param project the project file to load.
 
78
     * \param doneCallback gets called whenever the load thread finishes.
54
79
     */
55
 
    explicit WProjectFile( boost::filesystem::path project );
 
80
    WProjectFile( boost::filesystem::path project, ProjectLoadCallback doneCallback );
56
81
 
57
82
    /**
58
83
     * Destructor.
99
124
    static boost::shared_ptr< WProjectFileIO > getROIWriter();
100
125
 
101
126
protected:
102
 
 
103
127
    /**
104
128
     * Function that has to be overwritten for execution. It gets executed in a separate thread after run()
105
129
     * has been called.
116
140
     */
117
141
    std::vector< boost::shared_ptr< WProjectFileIO > > m_parsers;
118
142
 
 
143
    /**
 
144
     * Do custom exception handling.
 
145
     *
 
146
     * \param e the exception
 
147
     */
 
148
    virtual void onThreadException( const WException& e );
119
149
private:
 
150
    /**
 
151
     * Signal used to callback someone that the loader was finished.
 
152
     */
 
153
    ProjectLoadCallbackSignal m_signalLoadDone;
 
154
 
 
155
    /**
 
156
     * Connection managing the signal m_signalLoadDone. This is the one and only connection allowed and will be disconnected upon thread has
 
157
     * finished.
 
158
     */
 
159
    boost::signals2::connection m_signalLoadDoneConnection;
120
160
};
121
161
 
122
162
#endif  // WPROJECTFILE_H