KSquare Utilities
Atom.h
Go to the documentation of this file.
1 /* Atom.h -- Experimental class that is not in use; meant to be base class to all other classes.
2  * Copyright (C) 1994-2011 Kurt Kramer
3  * For conditions of distribution and use, see copyright notice in KKB.h
4  */
5 #ifndef _ATOM_
6 #define _ATOM_
7 
8 #include <ostream>
9 
10 
11 #include "KKBaseTypes.h"
12 
13 
14 namespace KKB
15 {
16 #if !defined(_KKSTR_)
17  class KKStr;
18  typedef KKStr* KKStrPtr;
19  typedef KKStr const KKStrConst;
20  typedef KKStrConst* KKStrConstPtr;
21  typedef std::pair<KKStr,KKStr> KKStrPair;
22 #endif
23 
24 #if !defined(_RUNLOG_)
25  class RunLog;
26 #endif
27 
28 #if !defined(_XMLSTREAM_)
29  class XmlStream;
30  typedef XmlStream* XmlStreamPtr;
31  class XmlTag;
32  typedef XmlTag* XmlTagPtr;
33  typedef XmlTag const XmlTagConst;
34  typedef XmlTagConst* XmlTagConstPtr;
35 #endif
36 
37 
38  /**
39  *@class Atom Atom.h
40  *@brief Base class of all other classes that are meant to be managed by 'KKBase'
41  *@details 'Atom' will have a few important virtual methods that all derived classes will be required to implement.
42  * This will allow for the smooth functioning of XML file reading and writing. Ex: 'WriteXML', this method
43  * is to write a XML version of the derived class to a output stream. A registered BuildFromXML function will
44  * be able to create a new instance of the derived class.
45  *
46  * Create on 2010-02-22; primary purpose is to help generate more ideas along these
47  * lines.
48  */
49  class Atom
50  {
51  public:
52  typedef Atom* AtomPtr;
53 
54  typedef AtomPtr (*AtomCreator) (XmlStream& i);
55 
56  Atom ();
57  virtual ~Atom ();
58 
59  virtual const char* ClassName () const = 0;
60 
61  virtual
62  Atom* Duplicate () const = 0;
63 
64  virtual
65  void ReadXML (XmlStream& s,
66  XmlTagConstPtr tag,
67  VolConstBool& cancelFlag,
68  RunLog& log
69  ) = 0;
70 
71  virtual
72  void WriteXML (const KKStr& varName,
73  std::ostream& o
74  ) const = 0;
75 
76  private:
77  static std::vector<AtomCreator> registeredAtomCreators;
78  }; /* Atom */
79 }
80 
81 #endif
XmlTag * XmlTagPtr
Definition: Atom.h:31
XmlTag const XmlTagConst
Definition: Atom.h:33
virtual ~Atom()
Definition: Atom.cpp:29
virtual void WriteXML(const KKStr &varName, std::ostream &o) const =0
virtual const char * ClassName() const =0
KKTHread * KKTHreadPtr
XmlStream * XmlStreamPtr
Definition: Atom.h:29
Manages the reading and writing of objects in a simple XML format. For a class to be supported by Xml...
Definition: XmlStream.h:46
static KKStr Concat(const std::vector< std::string > &values)
Concatenates the list of &#39;std::string&#39; strings.
Definition: KKStr.cpp:1082
Base class of all other classes that are meant to be managed by &#39;KKBase&#39;.
Definition: Atom.h:49
Atom()
Definition: Atom.cpp:25
KKStr const KKStrConst
Definition: Atom.h:19
virtual Atom * Duplicate() const =0
Used for logging messages.
Definition: RunLog.h:49
Atom * AtomPtr
Definition: Atom.h:52
virtual void ReadXML(XmlStream &s, XmlTagConstPtr tag, VolConstBool &cancelFlag, RunLog &log)=0
volatile const bool VolConstBool
Definition: KKBaseTypes.h:163