From: <ba...@us...> - 2008-06-12 13:11:13
|
Revision: 99 http://scstudio.svn.sourceforge.net/scstudio/?rev=99&view=rev Author: babicaj Date: 2008-06-12 06:11:09 -0700 (Thu, 12 Jun 2008) Log Message: ----------- Comments augmented Modified Paths: -------------- trunk/src/check/checker.h trunk/src/data/msc.h Removed Paths: ------------- trunk/src/data/msc_path.h Modified: trunk/src/check/checker.h =================================================================== --- trunk/src/check/checker.h 2008-06-02 15:22:03 UTC (rev 98) +++ trunk/src/check/checker.h 2008-06-12 13:11:09 UTC (rev 99) @@ -92,6 +92,7 @@ * Returns MscPathPtr with violating example if there is any in hmsc * otherwise HMscPathPtr is undefined. * @param hmsc - HMsc to be checked + * @param mapper - ChannelMapper which is chosen as delivery semantic */ virtual HMscPtr check(HMscPtr hmsc, ChannelMapperPtr mapper)=0; }; @@ -117,14 +118,15 @@ * Returns BMscPtr with violating example if there is any in bmsc otherwise * BMscPtr is undefined. * @param bmsc - BMsc to be checked + * @param mapper - ChannelMapper which is chosen as delivery semantic */ virtual BMscPtr check(BMscPtr bmsc, ChannelMapperPtr mapper)=0; }; /** - * Abstra class whose purpose is to decide whether two Messages belongs to the - * same channel or not and assign to a message ID of channel ehich the message - * belongs to. + * Abstract class whose purpose is to decide whether two Messages belongs to the + * same channel or not and assign to a message ID of channel which the message + * belongs to. This class shortly defines delivery semantic. */ class ChannelMapper { @@ -171,10 +173,14 @@ * * Usefull if you need to have the same functionality of the original mapper, * but you don't want to work with all registered events by the original one. + * This approach may increase efficiency in some cases. */ virtual ChannelMapperPtr copy()=0; }; +/** + * Basic implementation of ChannelMapper. + */ template<typename MessagePart> class GeneralMapper:public ChannelMapper { @@ -185,15 +191,18 @@ protected: + /** + * Common instance of GeneralMapper. + */ static counted_ptr<GeneralMapper<MessagePart> > m_instance; /** - * Holds channels' IDs + * Holds identificators of channels represented by MessagePart of MscMessage. */ std::map<MessagePart,size_t> m_channels; - + /** - * Hidden constructor. + * Use GeneralMapper::instance() to obtain instance of GeneralMapper */ GeneralMapper(){}; @@ -265,6 +274,15 @@ }; +/** + * Used in GeneralMapper template to decide whether two messages belongs to the + * same channel (delivery semantic). + * + * For decision send and receive instances' labels are used. + * + * To see delivery semantic of this class see operator<() and same_channel() + * methods of this class. + */ class SRMessagePart { @@ -301,6 +319,15 @@ } }; +/** + * Used in GeneralMapper template to decide whether two messages belongs to the + * same channel (delivery semantic). + * + * For decision send and receive instances' labels and message label are used. + * + * To see delivery semantic of this class see operator<() and same_channel() + * methods of this class. + */ class SRLMessagePart { std::string m_sender; Modified: trunk/src/data/msc.h =================================================================== --- trunk/src/data/msc.h 2008-06-02 15:22:03 UTC (rev 98) +++ trunk/src/data/msc.h 2008-06-12 13:11:09 UTC (rev 99) @@ -86,8 +86,8 @@ typedef counted_ptr<CoregionArea> CoregionAreaPtr; -typedef void* AttributePtr; -typedef std::map<std::string,AttributePtr> AttributePtrMap; +typedef void* AttributeP; +typedef std::map<std::string,AttributeP> AttributePMap; /** @@ -101,10 +101,10 @@ * It is neccessary to ensure to remove any attribute if the attribute is no * more required. * - * @warning individual attributes are of type AttributePtr, i.e. type control + * @warning individual attributes are of type AttributeP, i.e. type control * is left up to piece of code using these attributes */ - AttributePtrMap m_attributes; + AttributePMap m_attributes; protected: @@ -156,14 +156,15 @@ /** * Returns attribute of MscElement e. * - * T is type of attribute. + * If attribute is not set value of def is copied into its value and is + * returned. T is type of attribute. * @param name - attribute name * @param def - default value of attribute */ template<class T> T& get_attribute(const std::string& name, const T& def) { - AttributePtrMap::iterator i = m_attributes.find(name); + AttributePMap::iterator i = m_attributes.find(name); T* a; if(i!=m_attributes.end()) { @@ -180,7 +181,7 @@ /** * Sets attribute of MscElement e. * - * T is type of attribute. + * Value of def is copied as value of this attribute. T is type of attribute. * @param name - attribute name * @param val - value of attribute to be set */ @@ -194,13 +195,14 @@ /** * Removes attribute of MscElement e. * - * Deletes correT is type of attribute. + * Removes attribute with specified name from m_attributes map and deletes it + * from memory too. T is type of attribute. * @param name - attribute name */ template<class T> void remove_attribute(const std::string& name) { - AttributePtrMap::iterator i = m_attributes.find(name); + AttributePMap::iterator i = m_attributes.find(name); if(i!=m_attributes.end()) { delete static_cast<T*>(i->second); @@ -238,21 +240,32 @@ */ std::string m_label; - /** - * This is an abstract class. - */ - Msc(){} + Msc() + { + } + Msc(const std::string& label) + { + m_label = label; + } + public: + virtual ~Msc(); + /** - * Virtual destructor. + * Getter for m_label */ - virtual ~Msc(); + void set_label(const std::string label) { + m_label = label; + } - void set_label(const std::string label) { m_label = label; } - - const std::string& get_label() { return m_label; } + /** + * Setter for m_label + */ + const std::string& get_label() { + return m_label; + } }; @@ -269,9 +282,8 @@ public: - BMsc(const std::string& label="") + BMsc(const std::string& label=""):Msc(label) { - m_label = label; } BMsc(BMsc* original) @@ -320,8 +332,15 @@ public: - void set_label(const std::string label) { m_label = label; } - const std::string& get_label() { return m_label; } + void set_label(const std::string label) + { + m_label = label; + } + + const std::string& get_label() + { + return m_label; + } }; @@ -411,11 +430,9 @@ m_start = start; } - HMsc(std::string label) + HMsc(const std::string& label):Msc(label) { - this->set_label(label); - StartNodePtr start(new StartNode); - m_start = start; + m_start = new StartNode; } /** * Removes all nodes inside Deleted: trunk/src/data/msc_path.h =================================================================== --- trunk/src/data/msc_path.h 2008-06-02 15:22:03 UTC (rev 98) +++ trunk/src/data/msc_path.h 2008-06-12 13:11:09 UTC (rev 99) @@ -1,161 +0,0 @@ -/* - * scstudio - Sequence Chart Studio - * http://scstudio.sourceforge.net - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License version 2.1, as published by the Free Software Foundation. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * Copyright (c) 2008 Jindra Babica <ba...@ma...> - * - * $Id: $ - */ - -#ifndef _MSC_PATH_H -#define _MSC_PATH_H - -#include <list> -#include "data/msc.h" -#include "data/counted_ptr.h" - -class PathNode; -class HMscPathNode; -class BMscPathNode; - -typedef counted_ptr<PathNode> PathNodePtr; -typedef std::list<PathNodePtr> PathNodePtrList; - -typedef counted_ptr<HMscPathNode> HMscPathNodePtr; -typedef counted_ptr<BMscPathNode> BMscPathNodePtr; - -/** - * Describes structured path through Hmsc. - * - * As same as Hmsc is structured, path through that structure is designed to be - * structured too. I.e. path is list of particular nodes, where these nodes - * contains either Bmsc or nested MscPath. - */ -class MscPath{ - - /** - * Start nodes of current level of structure. - */ - PathNodePtrList m_start_nodes; - -public: - - /** - * Getter for m_start_nodes. - */ - PathNodePtrList& get_start_nodes() - { - return m_start_nodes; - } - -}; - -/** - * Element of path. - */ -class PathNode{ - - /** - * ReferenceNode which path goes through. - */ - ReferenceNodePtr m_node; - - /** - * Successors of this node. - */ - ReferenceNodePtrList m_successors; - - -protected: - - PathNode(ReferenceNodePtr node) - { - m_node = node; - } - -public: - - /** - * Setter of m_node. - */ - void set_node(ReferenceNodePtr node) - { - m_node = node; - } - - /** - * Getter for m_successors. - */ - ReferenceNodePtrList& get_successors() - { - return m_successors; - } - - virtual ~PathNode() - { - - } - -}; - -/** - * PathNode which isn't more structured - contains only Bmsc. - */ -class BMscPathNode:public PathNode{ - - /** - * Bmsc that is represented by this PathNode. - * - * It need not to be exactly BMsc refferenced by the m_node but should describe in - * appropriate way significant part of the BMsc for intended purposes of whole - * MscPath. It should be undefined if MscPath doesn't care about communication in - * the m_node. - */ - BMscPtr m_bmsc; - -public: - - BMscPathNode(ReferenceNodePtr n):PathNode(n) - { - - } - -}; - -/** - * PathNode which is more structured - contains other MscPath. - */ -class HMscPathNode:public PathNode{ - - /** - * Start nodes of current HMsc. - */ - PathNodePtrList m_start_nodes; - -public: - - HMscPathNode(ReferenceNodePtr n):PathNode(n) - { - - } - - /** - * Getter for m_start_nodes. - */ - PathNodePtrList& get_start_nodes() - { - return m_start_nodes; - } - -}; -#endif /* _MSC_PATH_H */ - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |