00001 #ifndef FUNCTION_ANNOTATION_H_INCLUDED_
00002 #define FUNCTION_ANNOTATION_H_INCLUDED_
00003 
00004 #include <iostream>
00005 #include <string>
00006 
00007 enum WAIT_CONSTRUCT {
00008   NO_WAIT = 0,
00009   UNCONDITIONAL_WAIT = 1,
00010   CONDITIONAL_WAIT = 2,
00011   LOOPED_WAIT = 3,
00012   WORST_WAIT = 4
00013 };
00014 
00015 struct AnnotatedTime {
00016 
00017   AnnotatedTime():
00018     units_(0),
00019     magnitude_(0),
00020     event_notification_(false),
00021     sc_zero_time_(false)
00022   { }
00023 
00024   int units_;
00025   long long magnitude_;
00026   bool event_notification_;
00027   bool sc_zero_time_;
00028 };
00029 
00030 bool operator==(const AnnotatedTime &lhs, const AnnotatedTime &rhs);
00031 
00032 struct WaitAnnotation {
00033 
00034   WAIT_CONSTRUCT wait_type_;
00035   AnnotatedTime *annotated_time_;
00036 };
00037 
00038 struct FunctionAnnotation {
00039 
00040   FunctionAnnotation(
00041       char *function_name,
00042       bool is_conflict_free,
00043       WAIT_CONSTRUCT wait_type,
00044       AnnotatedTime *annotated_time):
00045     function_name_(function_name),
00046     is_conflict_free_(is_conflict_free),
00047     wait_type_(wait_type),
00048     annotated_time_(annotated_time)
00049   { }
00050 
00051   std::string function_name_;
00052   bool is_conflict_free_;
00053 
00054   WAIT_CONSTRUCT wait_type_;
00055   AnnotatedTime *annotated_time_;
00056 
00057   friend std::ostream& operator<<(std::ostream& os, const FunctionAnnotation& fa)
00058   {
00059     os << "Function name:    " << fa.function_name_ << std::endl
00060        << "Is conflict free: " << fa.is_conflict_free_ << std::endl
00061        << "Wait type:        ";
00062 
00063     switch(fa.wait_type_) {
00064 
00065       case NO_WAIT:
00066         os << "NO_WAIT" << std::endl;
00067         break;
00068       case UNCONDITIONAL_WAIT:
00069         os << "UNCONDITIONAL_WAIT" << std::endl;
00070         break;
00071       case CONDITIONAL_WAIT:
00072         os << "CONDITIONAL_WAIT" << std::endl;
00073         break;
00074       case LOOPED_WAIT:
00075         os << "LOOPED_WAIT" << std::endl;
00076         break;
00077       case WORST_WAIT:
00078         os << "WORST_WAIT" << std::endl;
00079         break;
00080     }
00081 
00082     if(fa.annotated_time_->event_notification_) {
00083       os << "Time:             event" << std::endl;
00084 
00085     } else if(fa.annotated_time_->sc_zero_time_) {
00086       os << "Time:             sc-zero_time" << std::endl;
00087 
00088     } else {
00089       os << "Time:             " << fa.annotated_time_->units_ << ", ";
00090 
00091       switch(fa.annotated_time_->magnitude_) {
00092 
00093         case 1:
00094           os << "SC_FS" << std::endl;
00095           break;
00096         case 1000:
00097           os << "SC_PS" << std::endl;
00098           break;
00099         case 1000000:
00100           os << "SC_NS" << std::endl;
00101           break;
00102         case 1000000000:
00103           os << "SC_US" << std::endl;
00104           break;
00105         case 1000000000000l:
00106           os << "SC_MS" << std::endl;
00107           break;
00108         case 1000000000000000l:
00109           os << "SC_SEC" << std::endl;
00110           break;
00111       }
00112     }
00113     return os;
00114   }
00115 };
00116 
00117 #endif 
00118 
00119