2012-10-05 23:28:47 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
"""
|
|
|
|
***************************************************************************
|
|
|
|
ParameterFactory.py
|
|
|
|
---------------------
|
|
|
|
Date : August 2012
|
|
|
|
Copyright : (C) 2012 by Victor Olaya
|
2014-01-17 19:01:08 +01:00
|
|
|
(C) 2013 by CS Systemes d'information (CS SI)
|
2012-10-05 23:28:47 +02:00
|
|
|
Email : volayaf at gmail dot com
|
2014-01-17 19:01:08 +01:00
|
|
|
otb at c-s dot fr (CS SI)
|
2014-04-06 12:27:51 +02:00
|
|
|
Contributors : Victor Olaya
|
2014-01-17 19:01:08 +01:00
|
|
|
Alexia Mondot (CS SI) - managing the new parameter ParameterMultipleExternalInput
|
2012-10-05 23:28:47 +02:00
|
|
|
***************************************************************************
|
|
|
|
* *
|
|
|
|
* This program is free software; you can redistribute it and/or modify *
|
|
|
|
* it under the terms of the GNU General Public License as published by *
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or *
|
|
|
|
* (at your option) any later version. *
|
|
|
|
* *
|
|
|
|
***************************************************************************
|
|
|
|
"""
|
|
|
|
|
|
|
|
__author__ = 'Victor Olaya'
|
|
|
|
__date__ = 'August 2012'
|
|
|
|
__copyright__ = '(C) 2012, Victor Olaya'
|
2013-10-01 20:52:22 +03:00
|
|
|
|
2012-10-05 23:28:47 +02:00
|
|
|
# This will get replaced with a git SHA1 when you do a git archive
|
2013-10-01 20:52:22 +03:00
|
|
|
|
2012-10-05 23:28:47 +02:00
|
|
|
__revision__ = '$Format:%H$'
|
|
|
|
|
2013-08-12 20:44:27 +02:00
|
|
|
from processing.parameters.ParameterBoolean import ParameterBoolean
|
|
|
|
from processing.parameters.ParameterMultipleInput import ParameterMultipleInput
|
|
|
|
from processing.parameters.ParameterNumber import ParameterNumber
|
|
|
|
from processing.parameters.ParameterRaster import ParameterRaster
|
|
|
|
from processing.parameters.ParameterString import ParameterString
|
|
|
|
from processing.parameters.ParameterTable import ParameterTable
|
|
|
|
from processing.parameters.ParameterVector import ParameterVector
|
|
|
|
from processing.parameters.ParameterTableField import ParameterTableField
|
|
|
|
from processing.parameters.ParameterSelection import ParameterSelection
|
|
|
|
from processing.parameters.ParameterRange import ParameterRange
|
|
|
|
from processing.parameters.ParameterFixedTable import ParameterFixedTable
|
|
|
|
from processing.parameters.ParameterExtent import ParameterExtent
|
|
|
|
from processing.parameters.ParameterFile import ParameterFile
|
|
|
|
from processing.parameters.ParameterCrs import ParameterCrs
|
2013-10-01 20:52:22 +03:00
|
|
|
|
|
|
|
class ParameterFactory:
|
2012-09-15 18:25:25 +03:00
|
|
|
|
|
|
|
@staticmethod
|
|
|
|
def getFromString(s):
|
2014-01-17 19:01:08 +01:00
|
|
|
"""
|
|
|
|
In : ParameterNumber|-nodatalabel|Label for the NoData class|None|None|0
|
|
|
|
Out : returns the object from class pointed by s with information extracted from s
|
|
|
|
"""
|
2013-10-01 20:52:22 +03:00
|
|
|
classes = [
|
|
|
|
ParameterBoolean,
|
|
|
|
ParameterMultipleInput,
|
|
|
|
ParameterNumber,
|
|
|
|
ParameterRaster,
|
|
|
|
ParameterString,
|
|
|
|
ParameterVector,
|
|
|
|
ParameterTableField,
|
|
|
|
ParameterTable,
|
|
|
|
ParameterSelection,
|
|
|
|
ParameterRange,
|
|
|
|
ParameterFixedTable,
|
|
|
|
ParameterExtent,
|
|
|
|
ParameterFile,
|
2014-04-13 12:47:34 +02:00
|
|
|
ParameterCrs
|
2013-10-01 20:52:22 +03:00
|
|
|
]
|
2012-09-15 18:25:25 +03:00
|
|
|
for clazz in classes:
|
|
|
|
if s.startswith(clazz().parameterName()):
|
2014-01-17 19:01:08 +01:00
|
|
|
return clazz().deserialize(s)
|