Antares Simulator
Power System Simulator
finder.h
1 /*
2  * Copyright 2007-2025, 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 
34 namespace Antares::Data
35 {
40 {
41 public:
42  enum
43  {
45  defaultTimeout = 10000, // 10s
46  };
47 
49  using FolderVector = std::vector<Yuni::String::Ptr>;
50 
51 public:
53 
54 
57  StudyFinder();
59  StudyFinder(const StudyFinder&);
63  virtual ~StudyFinder();
65 
72  void lookup(const Yuni::String& folder);
73 
80  void lookup(const Yuni::String::Vector& folders);
87  void lookup(const Yuni::String::List& folders);
88 
92  void stop(uint timeout = defaultTimeout);
93 
97  void wait();
98 
102  void wait(uint timeout);
103 
104 public: // Events
108  virtual void onStudyFound(const Yuni::String& folder, const StudyVersion& version) = 0;
109 
115  virtual void onLookupFinished()
116  {
117  }
118 
124  virtual void onLookupAborted()
125  {
126  }
127 
128 protected:
129  std::mutex mutex;
130 
131 private:
132  Yuni::IO::Directory::IIterator<true>* pLycos;
133 
134 }; // class StudyFinder
135 
136 } // namespace Antares::Data
137 
138 #endif // __ANTARES_LIB_FINDER_FINDER_H__
Look for study folders asynchronously.
Definition: finder.h:40
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:115
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:49
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:124
@ defaultTimeout
The default value for the timeout.
Definition: finder.h:45
Version of a study.
Definition: version.h:36