Example #1
0
QDebug operator<<(QDebug debug,
                  const Factory &rFactory)
{
    debug.nospace() << "Factory("
                    << "appenderfactories:" << rFactory.registeredAppenders()
                    << "filterfactories:" << rFactory.registeredFilters()
                    << "layoutfactories:" << rFactory.registeredLayouts()
                    << ")";
    return debug.space();
}
Example #2
0
 bool ParameterContainer::write(std::ostream& os) const{
   Factory* factory = Factory::instance();
   for (const_iterator it=begin(); it!=end(); it++){
     os << factory->tag(it->second) << " ";
     os << it->second->id() << " ";
     it->second->write(os);
     os << endl;
   }
   return true;
 }
Example #3
0
// gets client
Client* get_client()
{
    Factory *factory =
        Factory::instance();
    KLKASSERT(factory != NULL);
    Client *client = factory->getClient();
    KLKASSERT(client != NULL);

    return client;
}
///////////////////////////////////////////////////////////////
// SQUASH STRETCH 2
///////////////////////////////////////////////////////////////
// Define =====================================================
XSIPLUGINCALLBACK CStatus sn_squashstretch2_op_Define( CRef& in_ctxt )
{
   Context ctxt( in_ctxt );
   CustomOperator oCustomOperator;
   Parameter oParam;
   CRef oPDef;
   Factory oFactory = Application().GetFactory();
   oCustomOperator = ctxt.GetSource();

   oPDef = oFactory.CreateParamDef(L"blend",CValue::siDouble,siPersistable | siAnimatable,L"",L"",1,0,1,0,1);
   oCustomOperator.AddParameter(oPDef,oParam);
   oPDef = oFactory.CreateParamDef(L"driver",CValue::siDouble,siPersistable | siAnimatable,L"",L"",0,-100000,100000,0,24);
   oCustomOperator.AddParameter(oPDef,oParam);

   oPDef = oFactory.CreateParamDef(L"driver_min",CValue::siDouble,siPersistable | siAnimatable,L"",L"",0,-100000,100000,0,1);
   oCustomOperator.AddParameter(oPDef,oParam);
   oPDef = oFactory.CreateParamDef(L"driver_ctr",CValue::siDouble,siPersistable | siAnimatable,L"",L"",5,-100000,100000,0,1);
   oCustomOperator.AddParameter(oPDef,oParam);
   oPDef = oFactory.CreateParamDef(L"driver_max",CValue::siDouble,siPersistable | siAnimatable,L"",L"",10,-100000,100000,0,1);
   oCustomOperator.AddParameter(oPDef,oParam);

   oPDef = oFactory.CreateParamDef(L"axis",CValue::siInt4,siPersistable | siAnimatable,L"",L"",0,0,2,0,2);
   oCustomOperator.AddParameter(oPDef,oParam);

   oPDef = oFactory.CreateParamDef(L"squash",CValue::siDouble,siPersistable | siAnimatable,L"",L"",0,-1,1,-1,1);
   oCustomOperator.AddParameter(oPDef,oParam);
   oPDef = oFactory.CreateParamDef(L"stretch",CValue::siDouble,siPersistable | siAnimatable,L"",L"",0,-1,1,-1,1);
   oCustomOperator.AddParameter(oPDef,oParam);

   oCustomOperator.PutAlwaysEvaluate(false);
   oCustomOperator.PutDebug(0);
   return CStatus::OK;
}
Example #5
0
///////////////////////////////////////////////////////////////
// NULL 2 CURVE
///////////////////////////////////////////////////////////////
// Define =====================================================
XSIPLUGINCALLBACK CStatus sn_null2curve_op_Define( CRef& in_ctxt )
{
   Context ctxt( in_ctxt );
   CustomOperator op;
   Parameter param;
   CRef pdef;
   Factory oFactory = Application().GetFactory();
   op = ctxt.GetSource();
   pdef = oFactory.CreateParamDef(L"blend",CValue::siDouble,siPersistable | siAnimatable,L"",L"",0,0,1,0,1);
   op.AddParameter(pdef,param);
   pdef = oFactory.CreateParamDef(L"u",CValue::siDouble,siPersistable | siAnimatable,L"",L"",.5,0,1,0,1);
   op.AddParameter(pdef,param);
   pdef = oFactory.CreateParamDef(L"imin",CValue::siDouble,siPersistable | siAnimatable,L"",L"",0,0,1,0,1);
   op.AddParameter(pdef,param);
   pdef = oFactory.CreateParamDef(L"imax",CValue::siDouble,siPersistable | siAnimatable,L"",L"",1,0,1,0,1);
   op.AddParameter(pdef,param);
   pdef = oFactory.CreateParamDef(L"omin",CValue::siDouble,siPersistable | siAnimatable,L"",L"",0,0,1,0,1);
   op.AddParameter(pdef,param);
   pdef = oFactory.CreateParamDef(L"omax",CValue::siDouble,siPersistable | siAnimatable,L"",L"",1,0,1,0,1);
   op.AddParameter(pdef,param);
   pdef = oFactory.CreateParamDef(L"soft_blend",CValue::siDouble,siPersistable | siAnimatable,L"",L"",.5,0,1,0,1);
   op.AddParameter(pdef,param);
   pdef = oFactory.CreateParamDef(L"upv_mode",CValue::siInt4,siPersistable | siAnimatable,L"",L"",0,0,100000,0,10);
   op.AddParameter(pdef,param);

   op.PutAlwaysEvaluate(false);
   op.PutDebug(0);
   return CStatus::OK;
}
Example #6
0
  void G2O_ATTRIBUTE_CONSTRUCTOR init_types_slam2d(void)
  {
    Factory* factory = Factory::instance();
    //cerr << "Calling " << __FILE__ << " " << __PRETTY_FUNCTION__ << endl;

    factory->registerType("VERTEX_SE2", new HyperGraphElementCreator<VertexSE2>);
    factory->registerType("VERTEX_XY", new HyperGraphElementCreator<VertexPointXY>);

    factory->registerType("EDGE_PIOR_SE2", new HyperGraphElementCreator<EdgeSE2Prior>);

    factory->registerType("EDGE_SE2", new HyperGraphElementCreator<EdgeSE2>);
    factory->registerType("EDGE_SE2_XY", new HyperGraphElementCreator<EdgeSE2PointXY>);
    factory->registerType("EDGE_BEARING_SE2_XY", new HyperGraphElementCreator<EdgeSE2PointXYBearing>);
    factory->registerType("EDGE_SE2_MULTI", new HyperGraphElementCreator<EdgeSE2Multi>);

    factory->registerType("EDGE_SE2_XY_CALIB", new HyperGraphElementCreator<EdgeSE2PointXYCalib>);

    HyperGraphActionLibrary* actionLib = HyperGraphActionLibrary::instance();

    actionLib->registerAction(new VertexSE2WriteGnuplotAction);
    actionLib->registerAction(new VertexPointXYWriteGnuplotAction);
    actionLib->registerAction(new EdgeSE2WriteGnuplotAction);
    actionLib->registerAction(new EdgeSE2PointXYWriteGnuplotAction);
    actionLib->registerAction(new EdgeSE2PointXYBearingWriteGnuplotAction);

#ifdef G2O_HAVE_OPENGL
    actionLib->registerAction(new VertexSE2DrawAction);
    actionLib->registerAction(new VertexPointXYDrawAction);
    actionLib->registerAction(new EdgeSE2DrawAction);
    actionLib->registerAction(new EdgeSE2PointXYDrawAction);
    actionLib->registerAction(new EdgeSE2PointXYBearingDrawAction);
#endif

  }
void ListChecker::buildup (Factory &f, std::string const& templateParameter)
{
	structure = f.get(templateParameter);
	CheckerPtr c = f.get(templateParameter);
	if (!c.get()) throw "Could not create structure of template Parameter";

	// recursive handling code would belong here, but we don't have config
	// at the moment in ListChecker...
	c->buildup(f, "");

	structure = move(c);
}
Example #8
0
int main()
{
    Factory *fac = new Factory();
    int num;
    for(;;)
    {
        cin >> num;
        
        fac->GetCar(num);
    }
    return 0;
}
  RangeSet AddGT(BasicValueFactory &BV, Factory &F, const llvm::APSInt &V) {
    PrimRangeSet newRanges = F.GetEmptySet();

    for (PrimRangeSet::iterator i = begin(), e = end(); i != e; ++i) {
      if (i->Includes(V) && i->To() > V)
        newRanges = F.Add(newRanges, Range(BV.Add1(V), i->To()));
      else if (i->From() > V)
        newRanges = F.Add(newRanges, *i);
    }
    
    return newRanges;
  }
Example #10
0
        void construct(Factory &the_factory)
        {
            SuperCoder::construct(the_factory);

            m_coefficients_storage.resize(the_factory.max_symbols());
            for(uint32_t i = 0; i < the_factory.max_symbols(); ++i)
            {
                m_coefficients_storage[i].resize(
                    the_factory.max_coefficients_size());
            }

        }
        void initialize(Factory& the_factory)
        {
            SuperCoder::initialize(the_factory);

            m_offset = the_factory.elimination_offset();

            // The offset and the symbols that we actually plan to decode
            // cannot supersede the maximum symbols which can be stored
            // in the decoder.
            assert(the_factory.elimination_offset() + the_factory.symbols()
                   <= the_factory.max_symbols());
        }
Example #12
0
Layer* Layer::GetLayer(Vertex* data, string position)
{
    if(!data)
        return NULL;

    Vertex* field = get(LAYOUT, ANY)->get(FIELD, position);
    if(!field)
        return NULL;
    Vertex* req = field->Vertex::get(REQUEST)->get();

    FactoryMap* layer_factories = dynamic_cast<FactoryMap*>(get(FACTORYMAP, LAYER_FACTORIES));
    Factory* factory = NULL;

    // Get the Layer and basic Layout type
    if(req->get()->name() == ANY)
    {
        factory = layer_factories->GetFactory(data);
        if(!factory)
            factory = dynamic_cast<Factory*>(layer_factories->get(FACTORY, ANY));
        req = req->get(factory->get(OUTPUTTYPE)->get()->name());
    }
    else if(req->size() > 1)
    {
        Vertex* tmp_req;
        uint i = 0;
        while((tmp_req=req->get(++i)) != NULL)
        {
            factory = layer_factories->GetFactory(tmp_req->name());
            if(factory && factory->IsValidInput(data))
            {
                req = tmp_req;
                break;
            }
            else
                factory = NULL;
        }
    }

    if(!factory)
    {
        factory = layer_factories->GetFactory(req->get()->name());
        if(!factory)
            return NULL;
    }

    // Create the Layer
    factory->execute(data);
    Vertex* layer = data->Vertex::get(LAYER, ANY);
    // The position is needed further for layout handling
    layer->name(position);
    return dynamic_cast<Layer*>(layer);
}
int main(int argc, char *argv[])
{
    Factory *fac = new ConcreteFactory();
    Product *p = fac->CreateProduct();

    //在ConcreteProduct类中添加一个非接口中的方法,Product类指针肯定不能直接访问。
    //但是可以使用向下类型转换成具体子类ConcreteProduct的指针,,就可以访问ConcreteProduct的所有成员。
    // 但向下类型转换并不总是能够成功,也并不安全。最好还是将接口提取到抽象类Product中.lizheng 20111110 自我理解
    ConcreteProduct *cp = dynamic_cast<ConcreteProduct *>(p);
    cp->test();
    system("pause");
    return 0;
}
Example #14
0
Vrui::ToolFactory* LayerToggleTool::init()
{
  Factory* factory = new Factory(
    "CrustaLayerToggleTool",
    "Layer Visibility Toggler",
    dynamic_cast<Vrui::ToolFactory*>(Vrui::getToolManager()->loadClass("CrustaTool")),
    *Vrui::getToolManager());
  factory->setNumButtons(1);
  factory->setButtonFunction(0, "Toggle layer visibility");
  Vrui::getToolManager()->addClass(factory, Vrui::ToolManager::defaultToolFactoryDestructor);
  LayerToggleTool::factory = factory;
  return factory;
}
Example #15
0
// 1)为了提高内聚(Cohesion)和松耦合(Coupling) ,我们经常会抽象出一些类的公共接口以形成抽象基类或者接口。
//    这样我们可以通过声明一个指向基类的指针来指向实际的子类实现,达到了多态的目的。
//    这里很容易出现的一个问题 n 多的子类继承自抽象基类,我们不得不在每次要用到子类的地方就编写诸如 new  ×××;的代码。
//    这里带来两个问题 
//		1)客户程序员必须知道实际子类的名称(当系统复杂后,命名将是一个很不好处理的问题,为了处理可能的名字冲突,
//		   有的命名可能并不是具有很好的可读性和可记忆性,就姑且不论不同程序员千奇百怪的个人偏好了。 ) ,
//		2)程序的扩展性和维护变得越来越困难。 
// 2)还有一种情况就是在父类中并不知道具体要实例化哪一个具体的子类。
//	  这里的意思为:假设我们在类 A 中要使用到类 B,B 是一个抽象父类,在 A 中并不知道具体要实例化那一个 B 的子类,但是在类 A的子类 D中是可以知道的。
//	  在 A中我们没有办法直接使用类似于 new  ×××的语句,因为根本就不知道×××是什么。 
//	  
int main(int argc, char* argv[])
{
	Factory* fac = new ConcreteFactory1();  //这不是new了子类吗? 工厂
 
	Product* p = fac->CreateProduct(); //创建产品  不需要指明具体产品了

	Factory* fac2 = new ConcreteFactory2();  //这不是new了子类吗? 工厂

	Product* p2 = fac2->CreateProduct(); //创建产品  不需要指明具体产品了

	printf("Hello World!\n");
	return 0;
}
Example #16
0
void CChildFrame::OnPortCreate( UINT nID ) 
{
	int portIndex = nID - ID_RESOURCE_PORT_BEGIN;
	
	Factory * pFactory = Port::portFactory( portIndex );
	ASSERT( pFactory );

	Port * pDoc = dynamic_cast<Port *>( pFactory->createWidget() );
	ASSERT( pDoc );

	pDoc->SetModifiedFlag();
	pDoc->SetTitle( CString("New ") + pFactory->className() );
	pDoc->createView();
}
Example #17
0
void calculatorApplicationMain()
{
	initFactory(&calculatorFactory, calculatorOnTimer);
	
	Sheet *winCalculator = prepareSheet();
    prepareWindowSheetCal(winCalculator);
    loadWindowSheet(winCalculator);
	(*calculatorProcess).mainWindow = winCalculator;

	while (TRUE) {
		calculatorFactory.deselectButton(&calculatorFactory);
		calculatorFactory.doProcessEvent(&calculatorFactory);
	}
}
Example #18
0
void mathematicsApplicationMain()
{
	initFactory(&mathematicsFactory, mathematicsOnTimer);
	
	Sheet *winMathematics = prepareSheet();
    prepareWindowSheetMath(winMathematics);
    loadWindowSheet(winMathematics);
	(*mathematicsProcess).mainWindow = winMathematics;

	while(TRUE) {
		mathematicsFactory.deselectButton(&mathematicsFactory);
		mathematicsFactory.doProcessEvent(&mathematicsFactory);
	}
}
Example #19
0
//------------------------------------------------------------------------------
EphemerisFile* FactoryManager::CreateEphemerisFile(const std::string &ofType,
                                                   const std::string &withName)
{
   Factory* f = FindFactory(Gmat::EPHEMERIS_FILE, ofType);
   
   if (f != NULL)
      return f->CreateEphemerisFile(ofType, withName);
   
   #ifdef DEBUG_FACTORY_MANAGER
   MessageInterface::ShowMessage("Could not find Factory for %s\n", ofType.c_str());
   #endif
   
   return NULL;
}
Example #20
0
void dataGraphApplicationMain()
{
	initFactory(&dataGraphFactory, dataGraphOnTimer);
	
	Sheet *winDataGraph = prepareSheet();
    prepareWindowSheetGraph(winDataGraph);
    loadWindowSheet(winDataGraph);
	(*dataGraphProcess).mainWindow = winDataGraph;

	while(TRUE) {
		dataGraphFactory.deselectButton(&dataGraphFactory);
		dataGraphFactory.doProcessEvent(&dataGraphFactory);
	}
}
  RangeSet AddGE(BasicValueFactory &BV, Factory &F, const llvm::APSInt &V) {
    PrimRangeSet newRanges = F.GetEmptySet();

    for (PrimRangeSet::iterator i = begin(), e = end(); i != e; ++i) {
      // Strictly we should test for includes *V - 1, but no harm is
      // done by this formulation
      if (i->Includes(V))
        newRanges = F.Add(newRanges, Range(V, i->To()));
      else if (i->From() >= V)
        newRanges = F.Add(newRanges, *i);
    }

    return newRanges;
  }
int main()
{
    double baseAmount = 100000;

    Factory* fact = Factory::get();

    SupplementaryPayment* sp = fact->createSP();
    double amountToTax = sp->calculate(baseAmount);

    Tax* tax = fact->createTax();
    cout << tax->calculate(amountToTax) << endl;

    return 0;
}
bool OptimizableGraph::load(istream& is, bool createEdges) {
  set<string> warnedUnknownTypes;
  stringstream currentLine;
  string token;

  Factory* factory = Factory::instance();

  while (1) {
    int bytesRead = readLine(is, currentLine);
    if (bytesRead == -1)
      break;
    currentLine >> token;
    if (bytesRead == 0 || token.size() == 0 || token[0] == '#')
      continue;

    // do the mapping to an internal type if it matches
    if (_renamedTypesLookup.size() > 0) {
      map<string, string>::const_iterator foundIt = _renamedTypesLookup.find(
          token);
      if (foundIt != _renamedTypesLookup.end()) {
        token = foundIt->second;
      }
    }

    HyperGraph::HyperGraphElement* element = factory->construct(token);

    if (!element) {
      if (warnedUnknownTypes.count(token) != 1) {
        warnedUnknownTypes.insert(token);
        cerr << CL_RED(__PRETTY_FUNCTION__ << " unknown type: " << token)
            << endl;
      }
      continue;
    }

    if (dynamic_cast<Vertex*>(element)) { // it's a vertex type
      Vertex* v = static_cast<Vertex*>(element);
      int id;
      currentLine >> id;
      bool r = v->read(currentLine);
      if (!r)
        cerr << __PRETTY_FUNCTION__ << ": Error reading vertex " << token << " "
            << id << endl;
      v->setId(id);
      if (!addVertex(v)) {
        cerr << __PRETTY_FUNCTION__ << ": Failure adding Vertex, " << token
            << " " << id << endl;
        delete v;
      }
    } else if (dynamic_cast<Edge*>(element)) {
Example #24
0
   /*!
    * \class CreateNewCellCommand
  * \author Ingemar Axelsson
    *
    * \brief Command for creating a new cell.
    */
   void CreateNewCellCommand::execute()
   {
      try
      {
   CellCursor *cursor = document()->getCursor();

   Factory *fac = document()->cellFactory();

   //This does not work.
   if(cursor->currentCell()->isClosed())
   {
      if(cursor->currentCell()->hasChilds())
      {
         cursor->currentCell()->child()->setReadOnly(true);
         cursor->currentCell()->child()->setFocus(false);
      }
   }
   else
   {
      cursor->currentCell()->setReadOnly(true);
      cursor->currentCell()->setFocus(false);
   }

   cursor->addBefore(fac->createCell(style_));

   if(cursor->currentCell()->isClosed())
   {
      if(cursor->currentCell()->hasChilds())
      {
         cursor->currentCell()->child()->setReadOnly(false);
         cursor->currentCell()->child()->setFocus(true);
      }
   }
   else
   {
      cursor->currentCell()->setReadOnly(false);
      cursor->currentCell()->setFocus(true);
   }

    //2006-01-18 AF, set docuement changed
    document()->setChanged( true );
      }
      catch(exception &e)
      {
      // 2006-01-30 AF, add exception
      string str = string("CreateNewCommand(), Exception: \n") + e.what();
      throw runtime_error( str.c_str() );
      }
   }
Example #25
0
///////////////////
//Class Constructor
Kinematics::Kinematics(ModelPlane * parent)
{
	parentObj = parent; // ModelPlane class pointer
	forceInput.x = 0;
	forceInput.y = 0;
	forceInput.z = 0;
	torqueInput.x = 0;
	torqueInput.y = 0;
	torqueInput.z = 0;
	// Read kinematics related parameters from parameter server
	if(!ros::param::getCached("airframe/m", mass)) {ROS_FATAL("Invalid parameters for -m- in param server!"); ros::shutdown();}
	double j_x, j_y, j_z, j_xz;
	if(!ros::param::getCached("airframe/j_x", j_x)) {ROS_FATAL("Invalid parameters for -j_x- in param server!"); ros::shutdown();}
	if(!ros::param::getCached("airframe/j_y", j_y)) {ROS_FATAL("Invalid parameters for -j_y- in param server!"); ros::shutdown();}
	if(!ros::param::getCached("airframe/j_z", j_z)) {ROS_FATAL("Invalid parameters for -j_z- in param server!"); ros::shutdown();}
	if(!ros::param::getCached("airframe/j_xz", j_xz)) {ROS_FATAL("Invalid parameters for -j_xz- in param server!"); ros::shutdown();}

	// Calculate inertia matrix...
	J[0] = j_x; J[1] = 0; J[2] = -j_xz;
	J[3] = 0; J[4] = j_y; J[5] = 0;
	J[6] = -j_xz; J[7] = 0; J[8] = j_z;

	int res = is_pos_def(J);
	if (!(res==0)) {
		switch (res) {
			case -1:
				ROS_FATAL("Matrix of inertia is singular");
				ros::shutdown();
				break;
			case -2:
				ROS_FATAL("Matrix of inertia is not positive definite");
				ros::shutdown();
				break;
			default:
				break;
		}

	}

	// ... and its inverse
	double G = j_x*j_z-pow(j_xz,2);

	Jinv[0] = j_z/G; Jinv[1] = 0; Jinv[2] = j_xz/G;
	Jinv[3] = 0; Jinv[4] = 1/j_y; Jinv[5] = 0;
	Jinv[6] = j_xz/G; Jinv[7] = 0; Jinv[8] = j_x/G;
	// Create a Factory object and make it build an integrator
	Factory factory;
	integrator = factory.buildIntegrator(parentObj);
}
Example #26
0
void MainWindow::startGame()
{
    Factory *factory = new Factory(ui->gameScreen);

    Worker *worker1 = new Worker("Cathal");
    Worker *worker2 = new Worker("Liam");
    Worker *worker3 = new Worker("Killian");

    factory->addWorker(worker1);
    factory->addWorker(worker2);
    factory->addWorker(worker3);


    factory->startDay();
}
Example #27
0
//------------------------------------------------------------------------------
Subscriber* FactoryManager::CreateSubscriber(const std::string &ofType,
                                             const std::string &withName,
                                             const std::string &fileName)
{
   Factory* f = FindFactory(Gmat::SUBSCRIBER, ofType);

   if (f != NULL)
      return f->CreateSubscriber(ofType, withName, fileName);
   
   #ifdef DEBUG_FACTORY_MANAGER
   MessageInterface::ShowMessage("Could not find Factory for %s\n", ofType.c_str());
   #endif
   
   return NULL;
}
Example #28
0
        void initialize(Factory& the_factory)
        {
            SuperCoder::initialize(the_factory);

            m_coeffcients_elements = the_factory.symbols();

            m_coefficients_length =
                fifi::elements_to_length<field_type>(the_factory.symbols());

            m_coefficients_size =
                fifi::elements_to_size<field_type>(the_factory.symbols());

            assert(m_coefficients_length > 0);
            assert(m_coefficients_size > 0);
        }
        void initialize(Factory& the_factory)
        {
            SuperCoder::initialize(the_factory);

            std::fill_n(m_status.begin(), the_factory.symbols(),
                        symbol_decoding_status::missing);
        }
        void construct(Factory &the_factory)
        {
            SuperCoder::construct(the_factory);

            m_status.resize(the_factory.max_symbols(),
                            symbol_decoding_status::missing);
        }