File: UmlCom.h

package info (click to toggle)
bouml 4.21-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 73,336 kB
  • ctags: 55,459
  • sloc: cpp: 290,644; makefile: 228; sh: 13
file content (154 lines) | stat: -rw-r--r-- 5,091 bytes parent folder | download
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#ifndef _UMLCOM_H
#define _UMLCOM_H


#include <qsocketdevice.h>
#include "CmdFamily.h"
#include "OnInstanceCmd.h"
#include "anItemKind.h"
#include "aRelationKind.h"
#include <qcstring.h>

#include <qvector.h>
#include <qstring.h>

class UmlItem;
class UmlTypeSpec;

class QSocketDevice;
class UmlItem;
class UmlTypeSpec;
class UmlClass;
// This class manages the communications
//
// This class may be defined as a 'singleton', but I prefer to use static 
// members allowing to just write 'UmlCom::member' rather than
// 'UmlCom::instance()->member' or other long sentence like this.
//
// The operation you can use yourself are :
//
// - connect()
//
// - targetItem()
//
// - trace()
//
// - showTrace()
//
// - traceAutoRaise()
//
// - message()
//
// - bye()
//
// - close()
// 
// you must NOT call the others

class UmlCom {
  public:
    // does the connexion
    // 
    // On error return FALSE in C++, produce a RuntimeException in Java
    static bool connect(unsigned int port);
    //  returns the item on which the tool is applied
    static UmlItem * targetItem();

    // to write messages in the tool window,
    // use Qt rich text : allows HTML like formatting
    static void trace(const char * s);
    //to show the trace window
    
    static void showTrace();

    //to automatically raise the trace window
    //each time trace() is called
    
    static void traceAutoRaise(bool y);

    // to write a message in the status bar line
    // does not use Qt rich text
    static void message(const char * s);
    // must be called just before the disconnexion
    static void bye(int v);
    // disconnexion
    static void close();

  private:
    static QSocketDevice * sock;

    static char * buffer_in;

    static unsigned int buffer_in_size;

    static char * p_buffer_in;

    static char * buffer_in_end;

    static char * buffer_out;

    static char * p_buffer_out;

    static unsigned int buffer_out_size;


  protected:
    static void check_size_out(unsigned int len);
    static void read_if_needed();
    static void read_buffer(unsigned int len);
    static void write_bool(bool b);
    static void write_char(char c);
    static void write_unsigned(unsigned int u);
    static void write_id(const void * id);
    static void write_string(const char * p);

  public:
    // do NOT call the followings yourself !!!!
    static void send_cmd(CmdFamily f, unsigned int cmd);
    //internal, do NOT use it
    
    static void send_cmd(CmdFamily f, unsigned int cmd, const char * s, bool b);

    static void send_cmd(CmdFamily f, unsigned int cmd, char arg);
    //internal, do NOT use it
    
    static void send_cmd(CmdFamily f, unsigned int cmd, int arg, const char * dummy);

    static void send_cmd(CmdFamily f, unsigned int cmd, void * id);
    static void send_cmd(CmdFamily f, unsigned int cmd, const char * s);
    static void send_cmd(CmdFamily f, unsigned int cmd, void * id, const char * n);
    static void send_cmd(CmdFamily f, unsigned int cmd, const char * s, const char * v);

    static void send_cmd(CmdFamily f, unsigned int cmd, bool b, const char * s, const char * v);

    static void send_cmd(const void * id, OnInstanceCmd cmd);
    static void send_cmd(const void * id, OnInstanceCmd cmd, const char * arg);
    static void send_cmd(const void * id, OnInstanceCmd cmd, char arg);
    static void send_cmd(const void * id, OnInstanceCmd cmd, unsigned int arg);
    static void send_cmd(const void * id, OnInstanceCmd cmd, const UmlTypeSpec & arg);
    static void send_cmd(const void * id, OnInstanceCmd cmd, const char * arg1, const char * arg2);
    static void send_cmd(const void * id, OnInstanceCmd cmd, anItemKind arg1, const char * arg2);
    static void send_cmd(const void * id, OnInstanceCmd cmd, anItemKind arg1, aRelationKind arg2, const void * id2);
    static void send_cmd(const void * id, OnInstanceCmd cmd, const void * id1);
    static void send_cmd(const void * id, OnInstanceCmd cmd, const void * id1, const char * arg2);
    static void send_cmd(const void * id, OnInstanceCmd cmd, unsigned int arg1, const UmlTypeSpec & arg2);
    static void send_cmd(const void * id, OnInstanceCmd cmd, unsigned int arg1, const char * arg2, const char * arg3, const UmlTypeSpec & arg4, const UmlTypeSpec & arg5);
    static void send_cmd(const void * id, OnInstanceCmd cmd, unsigned int arg1, char arg2, const char * arg3, const char * arg4, const UmlTypeSpec & arg5);
    static void send_cmd(const void * id, OnInstanceCmd cmd, const QVector<UmlItem> & l);
    //internal, do NOT use it
    
    static void send_cmd(const void * id, OnInstanceCmd cmd, anItemKind arg, const void * id2);

    static void * read_id();
    static const char * read_string();
    static bool read_bool();
    static char read_char();
    static unsigned int read_unsigned();
    // reads the selected items when the tool is called
    // you MUST call it only one time after the connexion
    static void read_item_list(QVector<UmlItem> & v);
    static void fatal_error(const QCString & msg);
    static void flush();
};

#endif