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 <memory>
22 #include <vector>
23 
24 namespace caffa
25 {
26 class FieldHandle;
27 class ObjectHandle;
28 
30 {
31 public:
33  : m_field( field )
34  {
35  }
36  virtual ~ChildArrayFieldAccessor() = default;
37  virtual size_t size() const = 0;
38  virtual void clear() = 0;
39  virtual std::vector<std::shared_ptr<ObjectHandle>> objects() = 0;
40  virtual std::vector<std::shared_ptr<const ObjectHandle>> objects() const = 0;
41 
42  virtual std::shared_ptr<ObjectHandle> at( size_t index ) const = 0;
43  virtual void insert( size_t index, std::shared_ptr<ObjectHandle> pointer ) = 0;
44  virtual void push_back( std::shared_ptr<ObjectHandle> pointer ) = 0;
45  virtual size_t index( std::shared_ptr<const ObjectHandle> pointer ) const = 0;
46  virtual void remove( size_t index ) = 0;
47 
52  virtual bool hasSetter() const = 0;
53 
58  virtual bool hasGetter() const = 0;
59 
60 protected:
61  FieldHandle* m_field;
62 };
63 
65 {
66 public:
69 
70  size_t size() const override;
71  void clear() override;
72  std::vector<std::shared_ptr<ObjectHandle>> objects() override;
73  std::vector<std::shared_ptr<const ObjectHandle>> objects() const override;
74  std::shared_ptr<ObjectHandle> at( size_t index ) const override;
75  void insert( size_t index, std::shared_ptr<ObjectHandle> pointer ) override;
76  void push_back( std::shared_ptr<ObjectHandle> pointer ) override;
77  size_t index( std::shared_ptr<const ObjectHandle> object ) const override;
78  virtual void remove( size_t index ) override;
79  bool hasGetter() const override { return true; }
80  bool hasSetter() const override { return true; }
81 
82 private:
83  std::vector<std::shared_ptr<ObjectHandle>> m_pointers;
84 };
85 
86 } // namespace caffa
virtual bool hasSetter() const =0
bool hasGetter() const override
Definition: cafChildArrayFieldAccessor.h:79
virtual bool hasGetter() const =0
Base class for all fields, making it possible to handle them generically.
Definition: cafFieldHandle.h:19
Definition: cafChildArrayFieldAccessor.h:64
bool hasSetter() const override
Definition: cafChildArrayFieldAccessor.h:80
Main Caffa namespace.
Definition: cafApplication.h:30
Definition: cafChildArrayFieldAccessor.h:29