GSM library clarification

Hi!
I am studying GSM module library from hwkitchen.com.

I am a bit confuse with the function "GetCommLineStatus" is it trying to create like a virtual status?

I have traced to:

in h file

enum comm_line_status_enum 
{
  // CLS like CommunicationLineStatus
  CLS_FREE,   // line is free - not used by the communication and can be used
  CLS_ATCMD,  // line is used by AT commands, includes also time for response
  CLS_DATA,   // for the future - line is used in the CSD or GPRS communication  
  CLS_LAST_ITEM
};

inline byte GetCommLineStatus(void) {return comm_line_status;};

.cpp file in like 1544

char GSM::IsSMSPresent(byte required_status) 
{
  char ret_val = -1;
  char *p_char;
  byte status;

  if (CLS_FREE != GetCommLineStatus()) return (ret_val);
  SetCommLineStatus(CLS_ATCMD);
  ret_val = 0; // still not present

  switch (required_status) {
    case SMS_UNREAD:
      mySerial.print("AT+CMGL=\"REC UNREAD\"\r");
      break;
    case SMS_READ:
      mySerial.print("AT+CMGL=\"REC READ\"\r");
      break;
    case SMS_ALL:
      mySerial.print("AT+CMGL=\"ALL\"\r");
      break;
  }
............
..........
...

You can get the library here

ftp://imall.iteadstudio.com/IM120417009_IComSat/Lib_GSM_Shield.zip

is it trying to create like a virtual status?

No. It's simply a public function to get a private member value that is otherwise inaccessible.

But where is the function? I can see the declaration and use but I cannot see the actual function.

Peter2013:
But where is the function? I can see the declaration and use but I cannot see the actual function.

Would it make it easier to see if:

inline byte GetCommLineStatus(void) {return comm_line_status;};

had been written:

inline byte GetCommLineStatus(void)
{
    return comm_line_status;
};

:slight_smile: It does.

It's just used to read the possible "enum comm_line_status_enum " values, right?

Also why not make "comm_line_status" variable global and just evaluate the variable value?

It's just used to read the possible "enum comm_line_status_enum " values, right?

Not the possible values; the one currently assigned to the instance.

Also why not make "comm_line_status" variable global and just evaluate the variable value?

That would violate the concept of encapsulation. Never expose internal members. Provide getters and setters when appropriate. Providing a setter makes it easy to control what is assigned to a member.

Suppose a class has a date member. If you make day, month and year public, one could set the date to the 47th day of 140th month of the year 32750. Would that make sense? By proving a setter that took the values to assign, you could ignore any invalid input BEFORE it screwed your program up.