1
::mediapipe::Status RunMPPGraph() {
  std::string calculator_graph_config_contents;
  MP_RETURN_IF_ERROR(mediapipe::file::GetContents(
      FLAGS_calculator_graph_config_file, &calculator_graph_config_contents));
  LOG(INFO) << "Get calculator graph config contents: "
            << calculator_graph_config_contents;
  mediapipe::CalculatorGraphConfig config =
      mediapipe::ParseTextProtoOrDie<mediapipe::CalculatorGraphConfig>(
          calculator_graph_config_contents);

This is a small section of a larger code offered by Google's Mediapipe, which uses the scope resolution operator to define RunMPPGraph(). I don't understand anything about this definition. Can someone tell me what is going on?

This looks like a function and I'm pretty sure it is: ::mediapipe::Status RunMPPGraph() ... but the basic way to define a function is ---> ReturnType FunctionName(parameters), and in this program RunMPPGraph is the name, so that means ::mediapipe::Status is the return type. In the main function, RunMPPGraph() is called with this statement ---> ::mediapipe::Status run_status = RunMPPGraph(); so that means ::mediapipe::Status is some form of user defined data type. So I wanted to know if we can break down ::mediapipe::Status into more smaller parts ?

Ted Lyngmo
  • 93,841
  • 5
  • 60
  • 108
  • @JeJo the part " ::mediapipe::Status RunMPPGraph() " . This looks like a function and I'm pretty sure it is, but the basic way to define a function is ---> " ReturnType FunctionName ( parameters ) ", and in this program ---> RunMPPGraph() is the name, so that means ::mediapipe::Status is the return type. In the main function, RunMPPGraph() is called with this statement ---> " ::mediapipe::Status run_status = RunMPPGraph(); " so that means ::mediapipe::Status is some form of user defined data type. So I wanted to know if we can break down ::mediapipe::Status into more smaller parts ? – Aniket Vishwakarma Aug 23 '20 at 07:39

2 Answers2

7

The resolution operator in C++ is used in different ways:

1-Access to class inside another class:

 class A
 {
    ...
    class B
    {
        static int var;
    }
 }
 int x =A::B::var.

2- Access to a global variable when there is a local variable with same name.

int gval = 5;
{
    int gval = 10;
    int y = ::gval;//the value assign for y is 5
}

3- TO access to a static variable inside a class.

 class A
 {
    static int x;
 };
 int y = A::x;

4- When using from multiple inheritance.

class A
{
   protected:
     int l;
}
class B
{
   protected:
     int l;
}
class c: class A, class B
{
   public:
    int f()
    {
       int c1 = A::l;
       int c2 = B::l;
    }
}

5- For namespace.

Your case satisfy in Item 2.

Farhad Sarvari
  • 1,051
  • 7
  • 13
4

It's pretty straigtforward, I guess you're not familiar with namespaces.

::mediapipe::Status RunMPPGraph()

RnuMMPGraph is a function taking zero arguments and returning ::mediapipe::Status. Status is a type defined in the mediapipe namespace which is defined in the global namespace.

john
  • 85,011
  • 4
  • 57
  • 81