Antares Simulator
Power System Simulator
Loading...
Searching...
No Matches
finder.h
1/*
2** Copyright 2007-2024, RTE (https://www.rte-france.com)
3** See AUTHORS.txt
4** SPDX-License-Identifier: MPL-2.0
5** This file is part of Antares-Simulator,
6** Adequacy and Performance assessment for interconnected energy networks.
7**
8** Antares_Simulator is free software: you can redistribute it and/or modify
9** it under the terms of the Mozilla Public Licence 2.0 as published by
10** the Mozilla Foundation, either version 2 of the License, or
11** (at your option) any later version.
12**
13** Antares_Simulator is distributed in the hope that it will be useful,
14** but WITHOUT ANY WARRANTY; without even the implied warranty of
15** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16** Mozilla Public Licence 2.0 for more details.
17**
18** You should have received a copy of the Mozilla Public Licence 2.0
19** along with Antares_Simulator. If not, see <https://opensource.org/license/mpl-2-0/>.
20*/
21#ifndef __ANTARES_LIB_FINDER_FINDER_H__
22#define __ANTARES_LIB_FINDER_FINDER_H__
23
24#include <mutex>
25
26#include <yuni/yuni.h>
27#include <yuni/core/string.h>
28#include <yuni/io/directory/iterator.h>
29
30#include "antares/study/study.h"
31
32#include "../version.h"
33
34namespace Antares
35{
36namespace Data
37{
42{
43public:
44 enum
45 {
47 defaultTimeout = 10000, // 10s
48 };
49
51 using FolderVector = std::vector<Yuni::String::Ptr>;
52
53public:
55
56
65 virtual ~StudyFinder();
67
74 void lookup(const Yuni::String& folder);
75
82 void lookup(const Yuni::String::Vector& folders);
89 void lookup(const Yuni::String::List& folders);
90
94 void stop(uint timeout = defaultTimeout);
95
99 void wait();
100
104 void wait(uint timeout);
105
106public: // Events
110 virtual void onStudyFound(const Yuni::String& folder, const StudyVersion& version) = 0;
111
117 virtual void onLookupFinished()
118 {
119 }
120
126 virtual void onLookupAborted()
127 {
128 }
129
130protected:
131 std::mutex mutex;
132
133private:
134 Yuni::IO::Directory::IIterator<true>* pLycos;
135
136}; // class StudyFinder
137
138} // namespace Data
139} // namespace Antares
140
141#endif // __ANTARES_LIB_FINDER_FINDER_H__
Look for study folders asynchronously.
Definition finder.h:42
void stop(uint timeout=defaultTimeout)
Stop a lookup currently in progress.
Definition finder.cpp:112
void lookup(const Yuni::String &folder)
Start a new lookup from a single folder.
StudyFinder()
Default Constructor.
Definition finder.cpp:93
virtual void onLookupFinished()
Event triggered when a lookup has finished gracefully.
Definition finder.h:117
void wait()
Wait Indefinitely for the end of the lookup.
Definition finder.cpp:121
virtual ~StudyFinder()
Destructor.
Definition finder.cpp:103
std::vector< Yuni::String::Ptr > FolderVector
List of folders.
Definition finder.h:51
virtual void onStudyFound(const Yuni::String &folder, const StudyVersion &version)=0
Event triggered when a lookup has been found.
virtual void onLookupAborted()
Event triggered when a lookup has been aborted.
Definition finder.h:126
@ defaultTimeout
The default value for the timeout.
Definition finder.h:47
Version of a study.
Definition version.h:36