A kind of communication packet treatment facility and method based on the class template manager
Technical field
The present invention relates to information processing system, method and converted products thereof, be specifically related to a kind of automatic processing equipment and method of computer communication module message message, more particularly, relate to a kind of communication packet treatment facility and method based on the class template manager.
Background technology
For carrying out communication in the realization system between two or more system modules, need the unified message format of definition usually, message format can be divided into two parts: heading and message body.Information such as the type of heading explanation message, message length; The message body then relates to the particular content of message, and the form of message body is by the type decided of message.Therefore, for the message of communication between the system module in the computer system, exist such characteristics usually: common heading form and different message physique formulas.
In traditional programming, usually define identical heading data structure and different message volume data structures for different messages, when actual when using certain concrete message, normally state a heading variable, in the heading variable, fill in information such as type of message with front definition heading data structure; And with a message body of the message volume data organization definition variable of type of message correspondence, the related content of in message body variable, filling in the message body.Therefore, there are such complex operation, repetition and make mistakes easily in the system design to heading and a large amount of assignment of message body and data copy operation.
And the use Object Oriented method, can make full use of the identical heading of communication packet, the characteristics of different message physique formulas, adopt the method for OO succession, polymorphic, Virtual Function, for the unified object base class of communication packet definition, comprise two member's classes of heading and message body in the base class.Corresponding different messages can define identical heading member class, and define different message body member classes.Because the assign operation to heading and message body adopts the member function of object class to conduct interviews, the bulk properties and the operations such as assignment, data copy of message object have well been encapsulated, simplified data operating interface, improve the utilance of code and the reusability of software, the error probability when having reduced programming.
Adopting OO method is that the processing of computer communication packet brings great convenience, and has become the method for designing that computer communication system generally adopts.But, in the complex communication system, the communication packet number of types of different system intermodule very huge (may have thousands of kinds of type of messages) in the particularly large-scale telecommunication network management software systems, usually each type of message is inherited the object subclass of getting off corresponding to one from message object base class, therefore needs definition and handles so various message object subclass of quantity.Adopt general OO method, can only manage message object class example, and can not these message object subclasses of flexible processing, can not carry out easily and effectively inquiry, visit and processing means to these message subclasses, thereby not only can not make full use of the advantage that OO method is brought, can influence programming efficiency on the contrary, increase the complexity of system design.
Summary of the invention
The technical problem to be solved in the present invention is to utilize OO template characteristic to construct a kind of object class hierarchical structure device, the effective ways that provide for the automatic processing of a large amount of message object class, thereby improve the access efficiency of object, simplify the complexity of network management communication system, improve the reusability of system module, guarantee the reliability of system development.
The above-mentioned technical problem of the present invention solves like this, construct a kind of communication packet processing method and equipment, utilize this method and apparatus, can set up the representation model of a series of object class hierarchical structures and the processing method that these object class are conducted interviews, message object class template and the unified class template manager of handling these object class template institute formation object examples that these object class comprise the object class of describing the message in the computer communication system, all message object class are unified to describe; Make that can use unified, succinct interface to handle thousands of message object class (and being not only object instance) becomes possibility and the invention provides the processing method that the message object class is conducted interviews when programming, thereby reduce the complexity of programming greatly, improve the reusability and the reliability of software.
According to the communication packet treatment facility based on the class template manager provided by the invention, comprise the class template manager, the class template instance objects class unit related with described class template manager, with related message object class unit, described class template instance objects class unit, and the message object base class unit of inheritance is arranged with described message object class unit, wherein, described class template manager comprises the calling mechanism of message object class, the apparatus for initializing of template class object instance, be used to set up the device of template class object instance index, the device that the template class object instance is retrieved, create the device of message object class example by calling the template class object instance, be used to discharge the device of template class object instance.
In the said equipment, described template instances class object class unit comprises the device that is used to create the message object instance and to the device of parameter initialization; Described message object class unit comprises the storage that is used for message data, to the device of the encoding and decoding of the visit of message data and modification, message.
In according to the communication packet processing method based on the class template manager provided by the invention, the class template manager is used for for given type of message, can obtain the object class template of corresponding type of message easily, thereby can generate the example of corresponding message object according to the example of object class template, obtain final required message object instance, be implemented in the communication that realizes dissimilar messages between two or more modules, this method may further comprise the steps: the type of message coding is input to the class template manager, and registration needs the object class of management; According to the message object class of registration, create the example of class template object; Set up type of message that type coding represents and promptly set up the index of class template object instance to the efficient mapping relations of corresponding template example class object instance; According to type of message as call parameters, the example of the class template instance objects by class template manager accesses correspondence; Call the case method of class template instance objects, create the message object instance corresponding with type of message; Call the method for message object instance, the message object is carried out associative operation; After the message Object Operations finished, discharge the message object instance.
In said method, the object class of the described required management of registration in the class template manager, may further comprise the steps: with each type of message coding, definition message object class is that parameter call is added to template list, provide the coding of message object class and the definition of message object class to described class template manager, wherein, the message class is that the message base class is the subclass of parent.
In said method, described object class according to registration, the example of drawing template establishment class object may further comprise the steps: it is the example of the class template object of parameter that the class template manager generates automatically with the message object class, and it is stored in the data field of class template manager.
In said method, the described index of setting up the class template object instance with the type of message coding as the key assignments (Key) of index.
In said method, operational difference to different message objects, be shielded to by OO polymorphism in the member function of object, for the difference in management, operation and the visit of different message object class then by adopting OO class template mechanism to shield.
In said method, when communication system increases type of message X object class, only need in the class template manager, to register such (MsgClassX) and code thereof.
In said method, the communication module of message transmitting party with the type coding that sends message as parameter, that calls the class template manager creates example with coding "; template manager will find the example of class template object with the coding of institute's incoming message type as the value of index; create the example of a message object class by this example; and the method that the communication module that this example returns to the message transmitting party of calling it makes it to call on demand the message example filled in message content; message is carried out encoding operation, and the data flow that generates is sent to message recipient's communication module; Message recipient's communication module is after receiving the data flow that the transmit leg communication module sends over, earlier data stream is carried out decode operation to obtain the type of message, that calls the class template manager creates example with coding, and with type of message coding as among the parameter input method, same class template manager will find the example A of class template object with the coding of type of message A as the value of index, create the example of a message object class by this example, and this example returned to the communication module that calls it, at this moment communication module can call the method for this message example, to insert the message example from the data flow that communication module receives, and by the coding/decoding method of message example data stream is handled, obtain message content from message transmitting party.
Implement communication packet treatment facility and the method based on the class template manager provided by the invention, can be used for the communication interface message processing module (MPM) of network management system, also can be used for other application systems.Compare as seen with traditional OO method, traditional OO method only provides the processing method of object instance, and the management of object class has the program designer manually to finish usually; The present invention has realized the automation of object class processing procedure, and this method comprises the situation of utilizing the polytype message to carry out communication between system module at the applied environment of multi-object class, and the convenient tool of object class management and visit is provided for systems design and development.
Description of drawings
Fig. 1 is the step that adopts the method that the class template manager handles the message object class.
Fig. 2 has described the object class hierarchical structure device that the present invention sets up.
Fig. 3 is that two communication modules use dissimilar messages to carry out the model of communication.
Fig. 4 is the schematic diagram of communication module by class template manager accesses message object of the present invention.
Embodiment
The present invention proposes the method that adopts the class template manager that the message object class is handled automatically, each step is described as follows: step 1 as shown in Figure 1 one by one: the object class of the required management of registration in the class template manager;
As shown in Figure 1, when utilizing the present invention to realize multiple message communication system, the communication module in the system should be registered the message object class that will use earlier in class template manager provided by the invention.When registration message object class, must provide the coding (can define) of message object class and the definition of message object class to the class template manager by the user.The message class must be that the message base class that defines with the present invention is the subclass of parent, be that used message class must be inherited from the message base class, but, because inheritance and polymorphism that object-oriented method provided, this does not influence from the message base class inherits the message class self of the getting off particularity to data storage and access method.In the message base class just unified Definition all messages handle data shared all and to the method for operation of data, and required specific data of inheriting of message subclass and data manipulation method fully can be in the message subclass own the definition.Step 2: according to the object class of registration, the example of drawing template establishment class object;
Automatically the pairing template instances object class of message object class of registration is created the operation of object instance according to the class template manager among step 2 the present invention, step 3: set up the index of template class object instance, and set up the efficient mapping relations of type of message (type coding) to corresponding template example class object instance according to step 3., step 4: according to type of message, the example of the class template instance objects by class template manager accesses correspondence; Step 5: call the case method of class template instance objects, create the message object instance corresponding with type of message; Step 6: call the method for message object instance, the message object is carried out associative operation; Step 7: after the message Object Operations finished, discharge the message object instance;
Adopt the present invention to carry out the system module of communication when using the message of a certain type, only need call the method for class template manager, and with the parameter input as method of the coding of type of message, the message object instance of correspondence just can be provided according to the type of message that is provided according to step 4 and step 5 the class template manager.
At this moment use the system module of class template manager just can conduct interviews and other operation, according to step 7 the message object instance is discharged behind the complete operation according to step 6 pair message object instance.
The hierarchical structure device of object class of the present invention is made of class template manager, template instances object class, message object class, as shown in Figure 2.Function to the important structure in the object class level is described below.
The function that the class template manager provides comprises work such as the registration of message object class, the initialization of template class object instance, the foundation of template class object instance index, the retrieval of template class object instance, the example that calls the method establishment message object class of template class object instance, release template class object instance.
The function that the template instances class provides comprises the example of creating the message object, the work such as initialization of parameter.
The function that the message object class provides comprises the storage of message data, to the work such as encoding and decoding of the visit of message data and modification, message.
With the example that uses message to carry out communication between the communication module in the telecommunication network management system the present invention is described below.
As shown in Figure 3, communication module 1 carries out communication with communication module 2 by type of message A and type of message B in this example, be that communication module 1 is to communication module 2 transmission types A messages, and communication module 2 is to communication module 1 transmission types B message, so communication module 1 and communication module 2 all will be handled type A message and type B message.
Communication module 1 and communication module 2 use class template manager provided by the invention that type A message and type B message are handled.According to step 1, communication module 1 and communication module 2 all need be registered type of message A and type of message B in the class template manager, and this is that (the ADDTOTEMPLATELIST method is finished for the template list that is added to by the class template manager.
When type of message A is registered, need with the pairing type of message of type of message A coding (such as being 0x0001) and for the definition message object class A (such as being defined as MsgClassA) of type of message A as the above-mentioned parameter input class template manager that is added to the template list method, equally when type of message B is registered, need import the class template manager as the parameter that is added to the template list method with the pairing type of message coding of type of message B (such as being 0x0002) with for the definition message object class B (such as being defined as MsgClassB) of type of message B.According to step 2, at this moment will to generate one automatically be that the example A (TemplateInstanceA) of class template object of parameter and one are that the example B (TemplateInstanceB) of the class template object of parameter is stored in the data field of class template manager with message object class B (such as MsgClassB) with message object class A (such as MsgClassA) to the class template manager, according to step 3 class template manager with type of message coding as key assignments (Key) be that the example of class template object is set up index, when having thousands of object instance, this index will improve the inquiry and the access speed of object instance.
As shown in Figure 4, when communication module 1 need be when communication module 2 sends the message of type of message A, 1 need of communication module set by step 4 and step 5 call the class template manager create example (CreateInstanceByCode) method with coding, and with the coding (such as being 0x0001) of type of message A as among the parameter input method, at this moment the class template manager will find the example A (TemplateInstanceA) of class template object with the coding of type of message A as the value of index, create the example 1 (MsgAInstancel) of a message object class A by this example, and this example returned to the communication module 1 that calls it, at this moment communication module 1 can be filled in message content according to the method that step 6 is called the message example on demand, message is carried out encoding operation, and the data flow that generates is sent to communication module 2.
Communication module 2 is after receiving the data flow that communication module 1 sends over, earlier data stream is carried out decode operation, to obtain the type of message, in this example type of message A, what communication module 2 only need call the class template manager this moment creates case method with coding, and with the coding (such as being 0x0001) of type of message A as among the parameter input method, same class template manager will find the example A of class template object with the coding of type of message A as the value of index, create the example 2 (MsgAInstance2) of a message object class A by this example, and this example returned to the communication module 2 that calls it, at this moment communication module 2 can call the method for this message example, to insert the message example from the data flow that communication module 1 receives, and by the coding/decoding method of message example data stream is handled, finally obtain the message content that sends from communication module 1.
According to step 7 needs after it is carried out releasing operation to the EO of message example.
When the processing that communication module 2 need be when communication module 1 sends the message of type of message B identical with said process.
In the present embodiment, if adopt traditional Object Oriented method, can only realize management to type of message object instance 1 and 2 (MsgAInstancel and MsgAInstance2), and the managerial demand of message object class A and B (MsgClassA and MsgClassB) is manually finished, promptly the management process to type of message A and type of message B object must be described respectively in handling process, if increased type of message X object class (MsgClassX) in the communication system, then this section handling process need redesign to increase the handling process at type of message X object class, thereby increased the repeatability of system design, complexity causes system reliability to descend.
And after using class template manager provided by the invention, if increased type of message X object class in the communication system, only need in the class template manager, register the code (for example 0x000N) of such (MsgClassX) and its correspondence, and all system flows and interface all need not be revised, when using the type message, only need provide the code (for example 0x000N) of type of message correspondence just passable, thereby improved the reusability of system module, reduced the complexity of system design, improve the efficient of system design, improved the reliability of system.