File: test.h

package info (click to toggle)
ace 6.0.3%2Bdfsg-0.1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 49,368 kB
  • sloc: cpp: 341,826; perl: 30,850; ansic: 20,952; makefile: 10,144; sh: 4,744; python: 828; exp: 787; yacc: 511; xml: 330; lex: 158; lisp: 116; csh: 48; tcl: 5
file content (58 lines) | stat: -rw-r--r-- 1,522 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/* -*- C++ -*- */
// $Id: test.h 80826 2008-03-04 14:51:23Z wotte $

#include "ace/OS_NS_string.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "ace/SV_Message.h"

#define MSGSZ 128
#define SRV_KEY ACE_DEFAULT_SHM_KEY
#define SRV_ID 1

class Message_Data
{
public:
  Message_Data (long p = -1,
                const char user[] = "",
                const char text[] = ""): pid_ (p)
  {
    ACE_OS::strncpy (this->username_, user, 9);
    ACE_OS::strncpy (this->mtext_, text, MSGSZ);
  }

  long pid (void) { return this->pid_; }
  void pid (long p) { this->pid_ = p; }
  char *user (void) { return this->username_; }
  void user (char user[]) { ACE_OS::strncpy (this->username_, user, 9); }
  char *text (void) { return this->mtext_; }
  void text (char text[]) { ACE_OS::strncpy (this->mtext_, text, MSGSZ); }
  int length (void) { return sizeof *this - sizeof this->mtext_ + ACE_OS::strlen (this->mtext_) + 1; }

protected:
  long  pid_;
  char  username_[9];
  char  mtext_[MSGSZ];
};

class Message_Block : public ACE_SV_Message, public Message_Data
{
  // = TITLE
  //   Stores message content.
  // = DESCRIPTION
  //   This may not be 100 percent portable on all C++ compilers since
  //   it relies on inheritance to be "concatenation."
  //
public:
  Message_Block (long t,
                 long p = 0,
                 const char login[] = "",
                 const char message[] = "")
  : ACE_SV_Message (t),
    Message_Data (p, login, message)
  {}
};