libcrn  3.9.5
A document image processing library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CRNDefaultAction.h
Go to the documentation of this file.
1 /* Copyright 2010-2016 CoReNum, INSA-Lyon, ENS-Lyon
2  *
3  * This file is part of libcrn.
4  *
5  * libcrn is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU Lesser General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * libcrn is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with libcrn. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * file: CRNDefaultAction.h
19  * \author Yann LEYDIER
20  */
21 
22 #ifndef CRNDefaultAction_HEADER
23 #define CRNDefaultAction_HEADER
24 
25 #include <CRNData/CRNMap.h>
26 
27 namespace crn
28 {
40  class Action: public Object
41  {
42  public:
44  virtual ~Action() override { }
45  virtual StringUTF8 GetClassName() const = 0;
46 
47  void Deserialize(xml::Element &el);
48  xml::Element Serialize(xml::Element &parent) const;
49 
51  protected:
52  virtual void deserialize(xml::Element &el);
53  virtual xml::Element serialize(xml::Element &parent) const;
54  };
58 }
59 
60 namespace crn
61 {
68  {
69  public:
71  static SAction GetAction(const String &name);
73  static void SetAction(const String &name, SAction action);
75  static void Load(const Path &filename);
77  static void Save(const Path &filename);
78 
80  static std::vector<String> GetActionList();
81 
82  private:
84  DefaultAction():actions() {}
85  Map actions;
87  static DefaultAction& getInstance();
88  };
89 }
90 
91 #endif
XML element.
Definition: CRNXml.h:135
virtual ~Action() override
Destructor.
void Deserialize(xml::Element &el)
xml::Element Serialize(xml::Element &parent) const
A UTF32 character string class.
Definition: CRNString.h:61
static void Load(const Path &filename)
Loads a set of default actions.
Base functor class.
static SAction GetAction(const String &name)
Gets a default action.
A convenience class for file paths.
Definition: CRNPath.h:39
virtual xml::Element serialize(xml::Element &parent) const
virtual StringUTF8 GetClassName() const =0
virtual void deserialize(xml::Element &el)
static void Save(const Path &filename)
Saves the set of default actions.
static std::vector< String > GetActionList()
Gets the list of default actions.
A class containing functors.
Data map class.
Definition: CRNMap.h:42
CRN_ALIAS_SMART_PTR(ImageBW)
A character string class.
Definition: CRNStringUTF8.h:49
crn::Map UserData
static void SetAction(const String &name, SAction action)
Sets a default action.