vsg: include/vsg/commands/Commands.h Source File

vsg 1.1.10 VulkanSceneGraph library |

Loading...
Searching...
No Matches
Commands.h
1#pragma once
2
3/* <editor-fold desc="MIT License">
4
5Copyright(c) 2018 Robert Osfield
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
8
9The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
10
11THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
13</editor-fold> */
14
15#include <vsg/core/ref_ptr.h>
16
17#include <vsg/commands/Command.h>
18#include <vsg/nodes/Node.h>
19
20#include <vector>
21
22namespace vsg
23{
24
28 class VSG_DECLSPEC Commands : public Inherit<Command, Commands>
29 {
30 public:
31 explicit Commands(size_t numChildren = 0);
32
33 template<class N, class V>
34 static void t_traverse(N& node, V& visitor)
35 {
36 for (auto& child : node.children) child->accept(visitor);
37 }
38
39 void traverse(Visitor& visitor) override { t_traverse(*this, visitor); }
40 void traverse(ConstVisitor& visitor) const override { t_traverse(*this, visitor); }
41 void traverse(RecordTraversal& visitor) const override { t_traverse(*this, visitor); }
42
43 int compare(const Object& rhs) const override;
44
45 void read(Input& input) override;
46 void write(Output& output) const override;
47
48 using Children = std::vector<ref_ptr<vsg::Command>>;
49 Children children;
50
51 void addChild(vsg::ref_ptr<Command> child)
52 {
53 children.push_back(child);
54 }
55
56 void compile(Context& context) override;
57 void record(CommandBuffer& commandBuffer) const override;
58
59 protected:
60 virtual ~Commands();
61 };
62 VSG_type_name(vsg::Commands);
63
64} // namespace vsg
vsg::CommandBuffer
CommandBuffer encapsulates VkCommandBuffer.
Definition CommandBuffer.h:27
vsg::Commands
Definition Commands.h:29
vsg::Commands::compare
int compare(const Object &rhs) const override
compare two objects, return -1 if this object is less than rhs, return 0 if it's equal,...
vsg::ConstVisitor
Definition ConstVisitor.h:175
vsg::Context
Definition Context.h:67
vsg::Input
Definition Input.h:44
vsg::Object
Definition Object.h:60
vsg::Output
Definition Output.h:41
vsg::RecordTraversal
RecordTraversal traverses a scene graph doing view frustum culling and invoking state/commands to rec...
Definition RecordTraversal.h:70
vsg::Visitor
Definition Visitor.h:175
vsg::ref_ptr
Definition ref_ptr.h:22