FV3 Bundle
ModelFactory.py
Go to the documentation of this file.
1 # (C) Copyright 2009-2016 ECMWF.
2 #
3 # This software is licensed under the terms of the Apache Licence Version 2.0
4 # which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
5 # In applying this licence, ECMWF does not waive the privileges and immunities
6 # granted to it by virtue of its status as an intergovernmental organisation nor
7 # does it submit to any jurisdiction.
8 
9 
10 #===============================================================================
11 # ModelFactory
12 # A class responsible for the instantiation of objects from the right OOPS's model
13 #===============================================================================
15  __factories = {}
16 
17  #===========================================================================
18  # createPlot
19  # Instatiate a new plot
20  #===========================================================================
21  def createPlot(id):
22  return ModelFactory.__factories[id].createPlot()
23 
24  #===========================================================================
25  # createFdb
26  # Instantiate a new states manager
27  #===========================================================================
28  def createFdb(id, dir):
29  return ModelFactory.__factories[id].createFdb(dir)
30 
31  #===========================================================================
32  # createOdb
33  # Instantiate a new Odb
34  #===========================================================================
35  def createOdb(id, file):
36  return ModelFactory.__factories[id].createOdb(file)
37 
38  #===========================================================================
39  # title
40  # the title
41  #===========================================================================
42  def title(id):
43  return ModelFactory.__factories[id].title()
44 
45  #===========================================================================
46  # addFactory
47  # Adds a new factory in the builder
48  #===========================================================================
49  def addFactory(factory):
50  ModelFactory.__factories[factory.id()] = factory
51 
52  #===========================================================================
53  # List of static methods
54  #===========================================================================
55  addFactory = staticmethod(addFactory)
56  createPlot = staticmethod(createPlot)
57  createFdb = staticmethod(createFdb)
58  createOdb = staticmethod(createOdb)
59  title = staticmethod(title)