My Project
ClientReceiverConsoleDriver.h
1 // Copyright 2023 DreamWorks Animation LLC
2 // SPDX-License-Identifier: Apache-2.0
3 #pragma once
4 
5 #include "ClientReceiverFb.h"
6 
7 #include <scene_rdl2/common/grid_util/DebugConsoleDriver.h>
8 
9 namespace mcrt_dataio {
10 
11 //
12 // This class provides debug console features to the clientReceiverFb and we can connect console
13 // via telnet connection and execute several different command line commands by hand.
14 // This functionality is a big help to test the back-end engine via clientReceiverFb.
15 //
16 // This class boots an independent thread in order to run a debug console operation inside
17 // the initialize() function (See scene_rdl2/lib/common/grid_util/DebugConsoleDriver.h).
18 // If we don't have any incoming socket connection, this debug console threads
19 // almost always asleep and minimizes the CPU overhead. This debug console thread is automatically
20 // shut down inside the destructor.
21 //
22 class ClientReceiverConsoleDriver : public scene_rdl2::grid_util::DebugConsoleDriver
23 {
24 public:
25  using MessageContentConstPtr = arras4::api::MessageContentConstPtr;
26  using MessageSendFunc = std::function<bool(const MessageContentConstPtr msg)>;
27  using MessageGenFunc = std::function<const MessageContentConstPtr()>;
28 
30  DebugConsoleDriver(),
31  mParserMcrtRankId(0), // only send mcrt command to rankId=0
32  mFbReceiver(nullptr)
33  {}
35 
36  void set(const MessageSendFunc &messageSendCallBack,
37  ClientReceiverFb *fbReceiver)
38  {
39  mMessageSend = messageSendCallBack;
40  mFbReceiver = fbReceiver;
41  }
42 
43  bool sendMessage(const MessageContentConstPtr msg) const
44  {
45  return (mMessageSend) ? (mMessageSend)(msg) : false;
46  }
47  bool sendMessage(const MessageGenFunc &func) const { return sendMessage(func()); }
48 
49 private:
50  using Parser = scene_rdl2::grid_util::Parser;
51  using Arg = scene_rdl2::grid_util::Arg;
52 
53  void parserConfigure(Parser &parser) override;
54 
55  bool cmdAovLs(Arg &arg);
56  bool cmdAovPix(Arg &arg);
57  bool cmdPick(Arg &arg, int mode) const;
58  bool cmdFeedback(Arg& arg);
59  bool cmdFeedbackInterval(Arg& arg);
60  void sendCommandToAllMcrtAndMerge(const std::string& cmd);
61 
62  std::string showRankInfo() const;
63 
64  //------------------------------
65 
66  Parser mParserAov;
67  Parser mParserInvalidate;
68  Parser mParserDispatch;
69  Parser mParserMcrt;
70  int mParserMcrtRankId; // mcrt debug command destination rankId. -1 indicates all mcrt
71  Parser mParserMerge;
72  Parser mParserPick;
73 
74  MessageSendFunc mMessageSend;
75  ClientReceiverFb *mFbReceiver;
76 };
77 
78 } // namespace mcrt_dataio
Definition: ClientReceiverConsoleDriver.h:22
Definition: ClientReceiverConsoleDriver.cc:9
– ProgressiveFrame message decoder for frontend client –
Definition: ClientReceiverFb.h:29