Caffa  1.1.0
C++ Application Framework for Embedded Systems with introspection
cafVisitor.h
1 // ##################################################################################################
2 //
3 // CAFFA
4 // Copyright (C) 2023- Kontur AS
5 //
6 // GNU Lesser General Public License Usage
7 // This library is free software; you can redistribute it and/or modify
8 // it under the terms of the GNU Lesser General Public License as published by
9 // the Free Software Foundation; either version 2.1 of the License, or
10 // (at your option) any later version.
11 //
12 // This library is distributed in the hope that it will be useful, but WITHOUT ANY
13 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 // FITNESS FOR A PARTICULAR PURPOSE.
15 //
16 // See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
17 // for more details.
18 //
19 // ##################################################################################################
20 #pragma once
21 
22 namespace caffa
23 {
24 class ChildFieldBaseHandle;
25 class DataField;
26 class FieldHandle;
27 class ObjectHandle;
28 
32 class Inspector
33 {
34 public:
35  void visit( const ObjectHandle* object );
36  void visit( const ChildFieldBaseHandle* field );
37  void visit( const DataField* field );
38 
39 private:
40  virtual void visitObject( const ObjectHandle* object ) = 0;
41  virtual void visitField( const FieldHandle* field ) = 0;
42  virtual void leaveObject( const ObjectHandle* object ) {}
43  virtual void leaveField( const FieldHandle* field ) {}
44 };
45 
49 class Editor
50 {
51 public:
52  void visit( ObjectHandle* object );
53  void visit( ChildFieldBaseHandle* field );
54  void visit( DataField* field );
55 
56 private:
57  virtual void visitObject( ObjectHandle* object ) = 0;
58  virtual void visitField( FieldHandle* field ) = 0;
59  virtual void leaveObject( ObjectHandle* object ) {}
60  virtual void leaveField( FieldHandle* field ) {}
61 };
62 
63 } // namespace caffa
Definition: cafChildFieldHandle.h:36
Definition: cafVisitor.h:49
Definition: cafObjectHandle.h:47
Base class for all fields, making it possible to handle them generically.
Definition: cafFieldHandle.h:19
Definition: cafDataField.h:30
Definition: cafVisitor.h:32
Main Caffa namespace.
Definition: cafApplication.h:30