Caffa  1.1.0
C++ Application Framework for Embedded Systems with introspection
cafChildArrayFieldHandle.h
1 // ##################################################################################################
2 //
3 // Caffa
4 // Copyright (C) 2011-2013 Ceetron AS
5 // Copyright (C) 2013- Ceetron Solutions AS
6 // Copyright (C) 2022- Kontur AS
7 //
8 // GNU Lesser General Public License Usage
9 // This library is free software; you can redistribute it and/or modify
10 // it under the terms of the GNU Lesser General Public License as published by
11 // the Free Software Foundation; either version 2.1 of the License, or
12 // (at your option) any later version.
13 //
14 // This library is distributed in the hope that it will be useful, but WITHOUT ANY
15 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 // FITNESS FOR A PARTICULAR PURPOSE.
17 //
18 // See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
19 // for more details.
20 //
21 // ##################################################################################################
22 #pragma once
23 
24 #include "cafChildFieldHandle.h"
25 
26 #include <memory>
27 
28 namespace caffa
29 {
30 class ChildArrayFieldAccessor;
31 class ObjectHandle;
32 
39 {
40 public:
42  ~ChildArrayFieldHandle() override {}
43 
49  virtual size_t size() const = 0;
56  bool empty() const override { return this->size() == 0u; }
57 
61  virtual void clear() = 0;
62 
68  virtual void erase( size_t index ) = 0;
69 
76  virtual std::shared_ptr<ObjectHandle> at( size_t index ) = 0;
77 
84  virtual void insertAt( size_t index, std::shared_ptr<ObjectHandle> obj ) = 0;
85 
91  virtual void push_back_obj( std::shared_ptr<ObjectHandle> obj ) = 0;
92 
98  virtual void setAccessor( std::unique_ptr<ChildArrayFieldAccessor> accessor ) = 0;
99 };
100 
101 } // namespace caffa
virtual size_t size() const =0
Get the number of child objects.
virtual void push_back_obj(std::shared_ptr< ObjectHandle > obj)=0
push back and object taking over ownership.
Definition: cafChildFieldHandle.h:36
A non-templated base interface for ChildArrayField<DataType*> Used so we can have pointers to any Chi...
Definition: cafChildArrayFieldHandle.h:38
virtual std::shared_ptr< ObjectHandle > at(size_t index)=0
Get a raw pointer to the object at a particular index.
bool empty() const override
Check if the child array field is empty.
Definition: cafChildArrayFieldHandle.h:56
virtual void insertAt(size_t index, std::shared_ptr< ObjectHandle > obj)=0
Insert an object at a particular index. Ownership will be taken.
virtual void clear()=0
Clear all content.
virtual void erase(size_t index)=0
Erase a particular child object by index.
virtual void setAccessor(std::unique_ptr< ChildArrayFieldAccessor > accessor)=0
Set a new accessor.
Main Caffa namespace.
Definition: cafApplication.h:30