NCBI C++ ToolKit
fasta_format_load_manager.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: fasta_format_load_manager.cpp 38522 2017-05-22 18:19:49Z evgeniev $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Andrey Yazhuk
27  *
28  */
29 
30 #include <ncbi_pch.hpp>
31 
33 
36 
39 
40 #include <wx/filename.h>
41 
43 
45 {
46  return m_Manager.x_GetParamsPanel();
47 }
48 
50 {
51  CFASTAFormatParamsPanel* panel = m_Manager.x_GetParamsPanel();
52  if (panel) {
53  if (!panel->TransferDataFromWindow())
54  return false;
55  m_Manager.m_Params = panel->GetData();
56  }
57 
58  return true;
59 }
60 
61 ///////////////////////////////////////////////////////////////////////////////
62 /// CFASTAFormatLoadManager
64  : m_Descr("FASTA Sequence files", "")
67  , m_State(eInvalid)
69  , m_OptionsPage(*this)
70 {
71  m_Descr.SetLogEvent("loaders");
72 }
73 
74 //
75 // IFileLoadPanelClient implementation
76 //
77 
79 {
80  return m_Descr.GetLabel();
81 }
82 
84 {
87 }
88 
89 //
90 // IUILoadManager implementation
91 //
92 
94 {
95  m_SrvLocator = srv_locator;
96 }
97 
98 
100 {
101  m_ParentWindow = parent;
102 }
103 
104 
106 {
107  return m_Descr;
108 }
109 
110 
112 {
113  m_State = eParams;
114 }
115 
116 
118 {
119  m_State = eInvalid;
120  m_ParamsPanel = NULL; // window is destroyed by the system
121 }
122 
123 
125 {
126  return (m_State == eParams) ? x_GetParamsPanel() : NULL;
127 }
128 
130 {
131  if (m_ParamsPanel == NULL) {
135  }
136  return m_ParamsPanel;
137 }
138 
140 {
141  switch(m_State) {
142  case eParams:
143  return action == eNext;
144  case eCompleted:
145  return action == eBack;
146  default:
147  _ASSERT(false);
148  return false;
149  }
150 }
151 
152 
154 {
155  return m_State == eParams;
156 }
157 
158 
160 {
161  return m_State == eCompleted; // does not matter
162 }
163 
164 
166 {
167  if(m_State == eParams && action == eNext) {
169  //TODO validate
172  return true;
173  }
174  return false;
175  } else if(m_State == eCompleted && action == eBack) {
176  m_State = eParams;
177  return true;
178  }
179  _ASSERT(false);
180  return false;
181 }
182 
183 
185 {
186  return nullptr;
187 }
188 
190 {
192 }
193 
195 {
198 }
199 
200 
201 bool CFASTAFormatLoadManager::ValidateFilenames(const vector<wxString>& /*filenames*/)
202 {
203  // not implemented
204  return true;
205 }
206 
207 
209 {
211 }
212 
214 {
215  filenames = m_FileNames;
216 }
217 
219 {
220  return m_State == eParams;
221 }
222 
223 
224 bool CFASTAFormatLoadManager::RecognizeFormat(const wxString& filename)
225 {
226  wxString ext;
227  wxFileName::SplitPath(filename, 0, 0, &ext);
229 }
230 
232 {
233  return fmt == CFormatGuess::eFasta;
234 }
235 
237 {
238  static string sid("fasta_format_load_manager");
239  return sid;
240 }
241 
242 
244 {
245  static string slabel("FASTA Format Load Manager");
246  return slabel;
247 }
248 
250 {
251  m_RegPath = path; // store for later use
252  m_Params.SetRegistryPath(m_RegPath + ".FASTAParams");
253 }
254 
256 {
258 }
259 
260 
262 {
264 }
265 
CFastaObjectLoader.
virtual void GetFilenames(vector< wxString > &filenames) const
get actual filenames that will be opened
virtual void SetServiceLocator(IServiceLocator *srv_locator)
Sets / unsets Service Locator.
virtual void SetLogEvent(const string &log_event)
Definition: ui_object.cpp:118
void SetData(const CFastaLoadParams &data)
CFASTAFormatParamsPanel * x_GetParamsPanel()
IAppTask.
Definition: app_task.hpp:82
CFASTAFormatParamsPanel * m_ParamsPanel
IUIObject - object that provides basic properties often required in a UI object.
Definition: ui_object.hpp:62
virtual void SetRegistryPath(const string &path)
virtual void SaveSettings() const
IRegSettings.
virtual bool ValidateFilenames(const vector< wxString > &filenames)
checks given filenames and returns true if the manager can handle them, otherwise - shows an error me...
virtual const IUIObject & GetDescriptor() const
Returns the object describing this tool (UI meta data).
#define NULL
Definition: ncbistd.hpp:225
CFastaLoadParams & GetData()
Data access.
virtual void LoadSettings()
virtual bool CanDo(EAction action)
Indicates whether given transition is possible in the current state.
virtual const string & GetLabel() const
Definition: ui_object.cpp:124
virtual string GetExtensionIdentifier() const
returns the unique human-readable identifier for the extension the id should use lowercase letters se...
virtual string GetLabel() const
virtual IAppTask * GetTask()
Once parameters are gathered and validated this function is called to produce the final Task object t...
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:101
virtual bool RecognizeFormat(const wxString &filename)
return true if the given file format is supported by this manager
virtual void InitUI()
Initializes the Manager before using it in UI.
virtual bool IsInitialState()
return true if the current state of the loader UI is the first valid state (first step in a wizard-li...
virtual bool DoTransition(EAction action)
Performs transition if possible and returns true, otherwise the function shall warn the user about th...
static wxString GetDialogFilter(EFileType fileType)
virtual void SetRegistryPath(const string &path)
IRegSettings.
virtual IExecuteUnit * GetExecuteUnit()
static int filenames
Definition: pcregrep.c:157
IServiceLocator - an abstract mechanism for locating services.
Definition: service.hpp:70
virtual wxString GetFormatWildcard() const
return file wildcard for the format (example - "*.txt;*.tab" )
virtual void SetFilenames(const vector< wxString > &filenames)
initilize the manager with the given filenames
CFASTAFormatParamsPanel.
virtual bool IsCompletedState()
Manager goes into "Complete" state when "Finish" button is pressed and all input data is gatherred an...
#define wxT(x)
Definition: muParser.cpp:41
virtual void SetParentWindow(wxWindow *parent)
virtual string GetExtensionLabel() const
returns a displayable label for this extension ( please capitalize the key words - "My Extension" ) ...
#define _ASSERT
virtual bool IsFinalState()
True if Tool Manager has reached its final state, i.e.
virtual wxPanel * GetCurrentPanel()
Return the panel corresponding to the current state of Tool Manager.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:98
CFASTAFormatLoadManager()
CFASTAFormatLoadManager.
virtual void CleanUI()
CleanUI() is called after the host finished using the manager.
static bool RecognizeExtension(EFileType fileType, const wxString &extension)
EFormat
The formats are checked in the same order as declared here.
FASTA format sequence record, CFastaReader.
Modified on Mon Oct 16 16:21:02 2017 by modify_doxy.py rev. 546573