Caffa  1.1.0
C++ Application Framework for Embedded Systems with introspection
cafChildArrayFieldAccessor.h
1 // ##################################################################################################
2 //
3 // Caffa
4 // Copyright (C) 2022- 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 #pragma once
20 
21 #include "cafAssert.h"
22 #include "cafObjectHandle.h"
23 
24 #include <algorithm>
25 #include <memory>
26 #include <optional>
27 #include <vector>
28 
29 namespace caffa
30 {
31 class FieldHandle;
32 class ObjectHandle;
33 
35 {
36 public:
38  : m_field( field )
39  {
40  }
41  virtual ~ChildArrayFieldAccessor() = default;
42  virtual size_t size() const = 0;
43  virtual void clear() = 0;
44  virtual std::vector<ObjectHandle::Ptr> objects() = 0;
45  virtual std::vector<ObjectHandle::ConstPtr> objects() const = 0;
46 
47  virtual ObjectHandle::Ptr at( size_t index ) const = 0;
48  virtual void insert( size_t index, ObjectHandle::Ptr pointer ) = 0;
49  virtual void push_back( ObjectHandle::Ptr pointer ) = 0;
50  virtual size_t index( ObjectHandle::ConstPtr pointer ) const = 0;
51  virtual void remove( size_t index ) = 0;
52 
53 protected:
54  FieldHandle* m_field;
55 };
56 
58 {
59 public:
62 
63  size_t size() const override;
64  void clear() override;
65  std::vector<ObjectHandle::Ptr> objects() override;
66  std::vector<ObjectHandle::ConstPtr> objects() const override;
67  ObjectHandle::Ptr at( size_t index ) const override;
68  void insert( size_t index, ObjectHandle::Ptr pointer ) override;
69  void push_back( ObjectHandle::Ptr pointer ) override;
70  size_t index( ObjectHandle::ConstPtr object ) const override;
71  virtual void remove( size_t index ) override;
72 
73 private:
74  std::vector<ObjectHandle::Ptr> m_pointers;
75 };
76 
77 } // namespace caffa
Definition: cafChildArrayFieldAccessor.h:35
Definition: cafChildArrayFieldAccessor.h:58
Base class for all fields, making it possible to handle them generically.
Definition: cafFieldHandle.h:23
Main Caffa namespace.
Definition: __init__.py:1