KiCad PCB EDA Suite
project.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2014-2017 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 #ifndef PROJECT_H_
24 #define PROJECT_H_
25 
30 #include <vector>
31 #include <wx/string.h>
32 #include <wx/filename.h>
33 
36 #define PROJECT_VAR_NAME wxT( "KIPRJMOD" )
37 
38 
39 class wxConfigBase;
40 class PARAM_CFG_ARRAY;
41 class FP_LIB_TABLE;
42 class PART_LIBS;
43 class SEARCH_STACK;
44 class S3D_CACHE;
45 class KIWAY;
46 class SYMBOL_LIB_TABLE;
47 
48 #define VTBL_ENTRY virtual
49 
56 class PROJECT
57 {
58 public:
59 
66  class _ELEM
67  {
68  public:
69  virtual ~_ELEM() {}
70  };
71 
72  PROJECT();
73  ~PROJECT();
74 
75  //-----<Cross Module API>----------------------------------------------------
76 
77  // VTBL_ENTRY bool MaybeLoadProjectSettings( const std::vector<wxString>& aFileSet );
78 
87  VTBL_ENTRY void SetProjectFullName( const wxString& aFullPathAndName );
88 
94  VTBL_ENTRY const wxString GetProjectFullName() const;
95 
101  VTBL_ENTRY const wxString GetProjectPath() const;
102 
108  VTBL_ENTRY const wxString GetProjectName() const;
109 
115  VTBL_ENTRY const wxString FootprintLibTblName() const;
116 
120  VTBL_ENTRY const wxString SymbolLibTableName() const;
121 
135  VTBL_ENTRY void ConfigSave( const SEARCH_STACK& aSList, const wxString& aGroupName,
136  const PARAM_CFG_ARRAY& aParams, const wxString& aFileName = wxEmptyString );
137 
156  VTBL_ENTRY bool ConfigLoad( const SEARCH_STACK& aSearchS, const wxString& aGroupName,
157  const PARAM_CFG_ARRAY& aParams, const wxString& aForeignConfigFileName = wxEmptyString );
158 
161  {
164  SCH_LIB_SELECT, // eeschema/selpart.cpp
166  SCH_LIBEDIT_CUR_PART, // eeschema/libeditframe.cpp
167 
170 
175 
177  };
178 
185  VTBL_ENTRY const wxString& GetRString( RSTRING_T aStringId );
186 
193  VTBL_ENTRY void SetRString( RSTRING_T aStringId, const wxString& aString );
194 
199  enum ELEM_T
200  {
202 
207 
209  };
210 
220  VTBL_ENTRY _ELEM* GetElem( ELEM_T aIndex );
221  VTBL_ENTRY void SetElem( ELEM_T aIndex, _ELEM* aElem );
222 
227  VTBL_ENTRY void ElemsClear();
228 
233  void Clear() // inline not virtual
234  {
235  ElemsClear();
236 
237  for( unsigned i = 0; i<RSTRING_COUNT; ++i )
238  SetRString( RSTRING_T( i ), wxEmptyString );
239  }
240 
247  VTBL_ENTRY const wxString AbsolutePath( const wxString& aFileName ) const;
248 
254 
255  //-----</Cross Module API>---------------------------------------------------
256 
257  //-----<KIFACE Specific APIs>------------------------------------------------
258 
259  // These are the non-virtual DATA LOAD ON DEMAND members. They load project related
260  // data on demand, and do so typicallly into m_elems[] at a particular index using
261  // SetElem() & GetElem(). That is, they wrap SetElem() and GetElem().
262  // To get the data to reload on demand, first SetProjectFullName(),
263  // then call SetElem( ELEM_T, NULL ) from client code.
264 
265  // non-virtuals resident in PCBNEW link image(s). By being non-virtual, these
266  // functions can get linked into the KIFACE that needs them, and only there.
267  // In fact, the other KIFACEs don't even know they exist.
268 #if defined(PCBNEW) || defined(CVPCB)
269 
274 
282  S3D_CACHE* Get3DCacheManager( bool updateProjDir = false );
283 #endif
284 
285 
286 #if defined(EESCHEMA)
287  // These are all prefaced with "Sch"
288  PART_LIBS* SchLibs();
289 
291  SEARCH_STACK* SchSearchS();
292 
294  SYMBOL_LIB_TABLE* SchSymbolLibTable();
295 #endif
296 
297  //-----</KIFACE Specific APIs>-----------------------------------------------
298 
299 private:
300 
309  wxConfigBase* configCreate( const SEARCH_STACK& aSList,
310  const wxString& aGroupName, const wxString& aProjectFileName = wxEmptyString );
311 
315  const wxString libTableName( const wxString& aLibTableName ) const;
316 
317  wxFileName m_project_name;
319 
322 
325 };
326 
327 
328 //-----<possible futures>---------------------------------------------------------
329 
330 #if 0
331 
342  VTBL_ENTRY bool Value( const wxString& aVariable, wxString* aFetchedValue = NULL );
343 
350  VTBL_ENTRY const wxString Substitute( const wxString& aString );
351 
359  VTBL_ENTRY const wxString SubstituteAndEvaluate( const wxString& aString );
360 #endif
361 
362 #endif // PROJECT_H_
wxConfigBase * configCreate(const SEARCH_STACK &aSList, const wxString &aGroupName, const wxString &aProjectFileName=wxEmptyString)
Function configCreate loads a *.pro file and returns a wxConfigBase.
Definition: project.cpp:291
_ELEM * m_elems[ELEM_COUNT]
Definition: project.h:324
A list of parameters type.
void Clear()
Function Clear clears the _ELEMs and RSTRINGs.
Definition: project.h:233
VTBL_ENTRY void ConfigSave(const SEARCH_STACK &aSList, const wxString &aGroupName, const PARAM_CFG_ARRAY &aParams, const wxString &aFileName=wxEmptyString)
Function ConfigSave saves the current "project" parameters into the wxConfigBase* derivative...
Definition: project.cpp:318
Class PROJECT holds project specific data.
Definition: project.h:56
VTBL_ENTRY const wxString GetProjectFullName() const
Function GetProjectFullName returns the full path and name of the project.
Definition: project.cpp:96
Class SEARCH_STACK looks for files in a number of places.
Definition: search_stack.h:41
VTBL_ENTRY _ELEM * GetElem(ELEM_T aIndex)
Typically wrapped somewhere else in a more meaningful function wrapper.
Definition: project.cpp:207
VTBL_ENTRY void SetElem(ELEM_T aIndex, _ELEM *aElem)
Definition: project.cpp:219
VTBL_ENTRY const wxString SymbolLibTableName() const
Return the path and file name of this projects symbol library table.
Definition: project.cpp:114
wxFileName m_project_name
/.pro
Definition: project.h:317
VTBL_ENTRY const wxString AbsolutePath(const wxString &aFileName) const
Function AbsolutePath fixes up aFileName if it is relative to the project's directory to be an absolu...
Definition: project.cpp:382
Class KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within...
Definition: kiway.h:257
VTBL_ENTRY const wxString FootprintLibTblName() const
Function FootprintLibTblName returns the path and filename of this project's fp-lib-table, i.e.
Definition: project.cpp:120
VTBL_ENTRY void SetProjectFullName(const wxString &aFullPathAndName)
Function SetProjectFullName sets the: 1) full directory, 2) basename, and 3) extension of the project...
Definition: project.cpp:65
VTBL_ENTRY void ElemsClear()
Function ElemsClear deletes all the _ELEMs and set their pointers to NULL.
Definition: project.cpp:46
PROJECT()
Definition: project.cpp:40
VTBL_ENTRY void SetRString(RSTRING_T aStringId, const wxString &aString)
Function SetRString stores a "retained string", which is any session and project specific string iden...
Definition: project.cpp:173
VTBL_ENTRY FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
A collection of PART_LIB objects.
VTBL_ENTRY const wxString & GetRString(RSTRING_T aStringId)
Function GetRString returns a "retained string", which is any session and project specific string ide...
Definition: project.cpp:188
ELEM_T
Enum ELEM_T is the set of _ELEMs that a PROJECT can hold.
Definition: project.h:199
#define VTBL_ENTRY
Definition: project.h:48
RSTRING_T
Retain a number of project specific wxStrings, enumerated here:
Definition: project.h:160
wxString m_rstrings[RSTRING_COUNT]
Definition: project.h:321
VTBL_ENTRY const wxString GetProjectPath() const
Function GetProjectPath returns the full path of the project.
Definition: project.cpp:102
A PROJECT can hold stuff it knows nothing about, in the form of _ELEM derivatives.
Definition: project.h:66
VTBL_ENTRY bool ConfigLoad(const SEARCH_STACK &aSearchS, const wxString &aGroupName, const PARAM_CFG_ARRAY &aParams, const wxString &aForeignConfigFileName=wxEmptyString)
Function ConfigLoad reads a subset of parameters from the "project" file.
Definition: project.cpp:353
wxString m_pro_date_and_time
Definition: project.h:318
virtual ~_ELEM()
Definition: project.h:69
~PROJECT()
Definition: project.cpp:59
const wxString libTableName(const wxString &aLibTableName) const
Return the full path and file name of the project specific library table aLibTableName.
Definition: project.cpp:126
VTBL_ENTRY const wxString GetProjectName() const
Function GetProjectName returns the short name of the project.
Definition: project.cpp:108