Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)

app-kersten/slot.hh
Go to the documentation of this file.
00001 #ifndef slot_hh
00002 #define slot_hh
00003 
00004 #include "toolbox/inputParam.hh"
00005 
00006 namespace concepts {
00007 
00008   // ************************************************************* InputSlot **
00009 
00014   class InputSlot : public InputParameter {
00015   public:
00017     InputSlot(InOutParameters& input);
00021     virtual std::ostream& letters(std::ostream& os) const;
00023     virtual std::ostream& arguments(std::ostream& os) const;
00025     virtual std::ostream& description(std::ostream& os) const;
00030     virtual int input(int opt, const char* optarg);
00034     const unsigned long long slotWidthReciprocal() const { return slot_; }
00035   protected:
00036     virtual std::ostream& info(std::ostream& os) const;
00037   private:
00039     unsigned long long slot_;
00040   };
00041 
00042   InputSlot::InputSlot
00043   (InOutParameters& input) : InputParameter(input), slot_(0) {
00044     input_.addDouble("slotwidth", 0.0);
00045   }
00046 
00047   std::ostream& InputSlot::letters(std::ostream& os) const {
00048     return os << "w:n";
00049   }
00050 
00051   std::ostream& InputSlot::arguments(std::ostream& os) const {
00052     return os << "[-w SLOT] [-n]";
00053   }
00054 
00055   std::ostream& InputSlot::description(std::ostream& os) const {
00056     os << "  SLOT        : slot width is 2^(-w), where w is given integer (0)"
00057        << std::endl
00058        << "  -n  no slot, full ring" << std::endl;
00059     return os;
00060   }
00061 
00062   int InputSlot::input(int opt, const char* optarg) {
00063     int info = 0;
00064     switch(opt) {
00065       case 'w': 
00066         if (atoi(optarg) >= 0) {
00067           slot_ = 1;
00068           for(int i = 0; i < atoi(optarg); ++i)
00069             slot_ *= 2;
00070           input_.addDouble("slotwidth", double(1.0)/slot_);
00071         } else info = 2; break;
00072 
00073       case 'n':
00074         slot_ = 0;
00075         input_.addDouble("slotwidth", 0.0);
00076         break;
00077       default: info = 1; break;
00078     }
00079     return info;
00080   }
00081 
00082   std::ostream& InputSlot::info(std::ostream& os) const {
00083     os << "InputSlot(";
00084     return arguments(os) << ")";
00085   }
00086 
00087 } // namespace concepts
00088 
00089 #endif // slot_hh

Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)