19 March - 23 March 2012
Doing budget for the project. Other that that, do the slide presentation for proposal presentation on week 12. Need to know what need to be said to the assessors. Quite afraid. Might be see supervisor for more info.
19 March - 23 March 2012
12 March - 16 March 2012
template <class ST, class CT>
struct Message
{
public:
typedef ST SubjectType;
typedef CT CodeType;
Message() : subject(), code() {}
Message(SubjectType s, CodeType c) : subject(s), code(c) {}
SubjectType subject;
CodeType code;
};
Observer and Notifier are paramaterized. Different instantiations of Message will lead to different instantiations of Observer and Notifier (and MessageMap andMessageSource, for that matter), so it's important to understand it well. The good news is that there isn't much to Message -- just two typedefs, two data members and a two constructors. The typedefs serve to "publish"Message's parameters to other code. Inside Observer and Notifier those typedefs are used to instantiate code (for example, MessageMap has a member that is a map of Message<>::CodeType to PMethod function pointers). You can easily create a substitute for Message so long as it adheres to the basic "interface" shown here.Message types are fairly lightweight, containing just two data members only one of which is likely to be a pointer. Still, we don't want to make a lot of copies of them, or repeatedly construct and destruct them. I stopped short of adding a private copy constructor and assignment operator, for flexibility, but they might be well advised if your code or user data types are large or complex.Message instantiation with a code type of int and a subject type of const Foo*:typedef Mm::Message<const Foo*, int> MyMessage;In this example, I chose a const subject type to illustrate the need for the non-default constructor. There are situations where aspects (code, subject or user data) of a message type should always be considered non-volitile. It is possible in those cases to make the subject and or code types const, and hence protect them from modification outside initialization. However, since a const public member cannot be assigned outside of the initializer, a non-default constructor is required. Specializing
Message is possible and probably the best way to add user-defined data to messages. For example:typedef Mm::Message<const Foo*, int> MyMessage;
struct PingMessage : public MyMessage
{
PingMessage() : MyMessage() {}
PingMessage(MyMessage::SubjectType s, MyMessage::CodeType c)
std::list<Bar*> responders;
}
template <class M> struct Observer { public: typedef M MessageType; virtual Result OnMessage(const MessageType& message) { return Result(R_OK); } virtual Result Goodbye(const MessageType::SubjectType s) { return Result(R_OK); } };
Observer defines the interface of the client. That is, messages are passed to and handled by objects implementing the Observer interface appropriate to the message type. Observer is templatized on the message type, so each type of message will have an insulated, non-overlapping interface. It is expected that users of Intercom will create implementations of this interface, or use the concrete MessageMap described below.OnMessage() is called each time a message dispatched on behalf of a subject to which the observer is registered. The observer receives a const reference to a message of the type used to instantiate the template (MessageType), and is generally expected to return some status though it goes unused in Intercom at the moment.Goodbye() is not described by Gamma, though is often found in practice. This method is called when the registration of the observer is revoked from a particular subject and will no longer get notifications. The method provides the observer with a convenient opportunity to do finalization or cleanup without having to define a protocol specific to the purpose.5 March - 9 March 2012
Message, Observer and Notifier. In addition to the core templates, MessageMap provides a concrete implementation of Observer, andMessageSource provides a specialization of Notifier more consistent with the Gamma, et. al. definition of 'Subject'. Each of templates is parameterized on at least the message type and can be specified at compile-time. I've used typedefs everywhere possible which should make it easy to substitute alternate implementations. ![]() |
| The core of Intercom is made up of a set of loosely coupled parameterized classes (templates) |
27 February - 2 March 2012
A program that translates source code into object code. The compiler derives its name from the way it works, looking at the entire piece of source code and collecting and reorganizing the instructions. Thus, a compiler differs from an interpreter, which analyzes and executes each line of source code in succession, without looking at the entire program. The advantage of interpreters is that they can execute a program immediately. Compilers require some time before an executable program emerges. However, programs produced by compilers run much faster than the same programs executed by an interpreter.
Every high-level programming language (except strictly interpretive languages) comes with a compiler. In effect, the compiler is the language, because it defines which instructions are acceptable.
Because compilers translate source code into object code, which is unique for each type of computer, many compilers are available for the same language. For example, there is a FORTRAN compiler for PCs and another for Apple Macintosh computers. In addition, the compiler industry is quite competitive, so there are actually many compilers for each language on each type of computer. More than a dozen companies develop and sell C compilers for the PC.
A C++ compiler first checks all the syntaxes which are being used in a program. If the syntax is correct then compiler generates an assembly code for assembler.
At the highest level, it takes c++ source code and converts it into code that the machine will understand.
As we all know without compiler we are not able to make a program error free the compiler is resposible to check the syntax from right to left compilation.it tally code with the predefined files which are already defined with the compiler then our source file after the syntax checking is converted into object file ready to execute. When we compile file it send a message to operating system a message 0 or 1,if compiler found program error free then it send message and return o to operating system and for error return 1.