Beispiel #1
0
CPath::CPath(const wxString& filename)
{
	// Equivalent to the default constructor ...
	if (!filename) {
		return;
	}

	wxCharBuffer fn = filename2char(filename);
	if (fn) {
		// Filename is valid in the current locale. This means that
		// it either originated from a (wx)system-call, or from a
		// user with a properly setup system.
		m_filesystem = DeepCopy(filename);
		m_printable  = Demangle(fn, filename);
	} else {
		// It's not a valid filename in the current locale, so we'll
		// have to do some magic. This ensures that the filename is
		// saved as UTF8, even if the system is not unicode enabled,
		// preserving the original filename till the user has fixed
		// his system ...
		fn = wxConvUTF8.cWC2MB(filename);
		m_filesystem = wxConvFile.cMB2WC(fn);

		// There's no need to try to unmangle the filename here.
		m_printable = DeepCopy(filename);
	}

	wxASSERT(m_filesystem.Length());
	wxASSERT(m_printable.Length());
}
Beispiel #2
0
CPath& CPath::operator=(const CPath& other)
{
	if (this != &other) {
		m_printable = DeepCopy(other.m_printable);
		m_filesystem = DeepCopy(other.m_filesystem);
	}

	return *this;
}
Beispiel #3
0
DWORD SerialPort::ReadExisting(int8_t* const msg, DWORD* charsRead) const {
	// Get Comm state
	DWORD errors;
	COMSTAT stat;
	if (!ClearCommError(_handle, &errors, &stat))
		return GetLastError();

	// If no characters are waiting
	if (stat.cbInQue == 0) {
		return 0;
	}

	// Create this read operation's OVERLAPPED structure's hEvent.
	OVERLAPPED osReader = { 0 };
	osReader.hEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr);
	if (osReader.hEvent == nullptr) {
		return GetLastError();
	}

	// Issue read
	DWORD toRead = min(maxRead, stat.cbInQue);
	int8_t* buffer = new int8_t[toRead];
	if (!ReadFile(_handle, buffer, toRead, charsRead, &osReader))
		return GetLastError();

	// Copy buffer to msg
	DeepCopy(buffer, *charsRead, msg);
	// Report success
	return 0;
}
CoefficientSpectrum::CoefficientSpectrum( const CoefficientSpectrum& srcCS ){
	this->m_lambda = 0;
	this->m_v = 0;
	this->m_dim = 0;

	DeepCopy(srcCS);
}
Beispiel #5
0
vtkSmartPointer<vtkGridAxes3DActor> RendererImplementationBase3D::createAxes()
{
    double axesColor[3] = { 0, 0, 0 };
    double labelColor[3] = { 0, 0, 0 };

    auto gridAxes = vtkSmartPointer<vtkGridAxes3DActor>::New();
    gridAxes->SetFaceMask(0xFF);
    gridAxes->GenerateGridOn();
    gridAxes->GenerateEdgesOn();
    gridAxes->GenerateTicksOn();
    gridAxes->EnableLayerSupportOff();

    // we need to set a new vtkProperty object here, otherwise the changes will not apply to all faces/axes
    auto gridAxesProp = vtkSmartPointer<vtkProperty>::New();
    gridAxesProp->DeepCopy(gridAxes->GetProperty());

    gridAxesProp->BackfaceCullingOff();
    gridAxesProp->FrontfaceCullingOn();
    gridAxesProp->SetColor(axesColor);

    gridAxes->SetProperty(gridAxesProp);

    for (int i = 0; i < 3; ++i)
    {
        FontHelper::configureTextProperty(*gridAxes->GetLabelTextProperty(i));
        FontHelper::configureTextProperty(*gridAxes->GetTitleTextProperty(i));
        gridAxes->GetLabelTextProperty(i)->SetColor(labelColor);
        gridAxes->GetTitleTextProperty(i)->SetColor(labelColor);
    }

    // Will be shown when needed
    gridAxes->VisibilityOff();

    return gridAxes;
}
Beispiel #6
0
wxString Demangle(const wxCharBuffer& fn, const wxString& filename)
{
	wxString result = wxConvUTF8.cMB2WC(fn);

	// FIXME: Is this actually needed for osx/msw?
	if (!result) {
		// We only try to further demangle if the current locale is
		// UTF-8, C or POSIX. This is because in any other case, the
		// current locale is probably the best choice for printing.
		static wxFontEncoding enc = wxLocale::GetSystemEncoding();

		switch (enc) {
			// SYSTEM is needed for ANSI encodings such as
			// "POSIX" and "C", which are only 7bit.
			case wxFONTENCODING_SYSTEM:
			case wxFONTENCODING_UTF8:
				result = wxConvISO8859_1.cMB2WC(fn);
				break;

			default:
				// Nothing to do, the filename is probably Ok.
				result = DeepCopy(filename);
		}
	}

	return result;
}
//
/// Merges the functional groups of another menu descriptor into this menu
/// descriptor.
///
/// Popups are DeepCopied and are then owned by this menu
/// Group counts are merged too.
//
bool
TMenuDescr::Merge(const TMenuDescr& srcMenuDescr)
{
  int thisOffset = 0;
  int srcOffset = 0;

  for (int i = 0; i < NumGroups; i++) {
    if (srcMenuDescr.GroupCount[i] != 0) {
      // Delete same menu group in the dest. menudescr.
      for (int j = GroupCount[i] - 1; j >= 0; j--) {
        DeleteMenu(thisOffset+j, MF_BYPOSITION);
      }
      GroupCount[i] = 0;

      if (srcMenuDescr.GroupCount[i] > 0) {
        DeepCopy(*this, thisOffset, srcMenuDescr, srcOffset, srcMenuDescr.GroupCount[i]);
        srcOffset += srcMenuDescr.GroupCount[i];
        GroupCount[i] += srcMenuDescr.GroupCount[i];
      }
    }

    if (GroupCount[i] > 0)
      thisOffset += GroupCount[i];
  }
  return true;
}
Beispiel #8
0
/* Tricky: when an instance table is copied, we want to do a deep
 * copy, not a reference copy.  Otherwise, the new higher-level object
 * will share a table with the original.  Aside from being confusing,
 * this breaks the global table, which assumes that we have a one-to-
 * one mapping between tables and objects. */
LuaClass::LuaClass( const LuaClass &cpy ):
	LuaTable(cpy)
{
	if( !IsSet() )
		return;

	DeepCopy();
}
Beispiel #9
0
ParserMgr::ParserMgr(const ParserMgr& other)
    : _inputMgr(other._inputMgr), _log(other._log),
      _modelData( MakeModelData() ), _modelMgr(other._modelMgr)
{
#ifdef DEBUG_PM_FUNC
    ScopeTracker st("ParserMgr::ParserMgr(const ParserMgr&)", std::this_thread::get_id());
#endif
    DeepCopy(other);
}
  inline
  DeepCopy( const ExecutionSpace& exec, void * dst , const void * src , size_t n )
  {
    exec.fence();
//    hc::completion_future fut = DeepCopyAsyncROCm (dst,src,n);
//    fut.wait();
//    DeepCopyAsyncROCm (dst,src,n);
    DeepCopy (dst,src,n);
  }
Beispiel #11
0
void Mask::CreateBoundaryImageInRegion(const itk::ImageRegion<2>& region, BoundaryImageType* const boundaryImage,
                                       const HoleMaskPixelTypeEnum& whichSideOfBoundary) const
{
  // Create a binary image of the mask
  unsigned char holeColor = 255;
  unsigned char validColor = 0;
  UnsignedCharImageType::Pointer fullBinaryImage = UnsignedCharImageType::New();
  CreateBinaryImageInRegion(region, fullBinaryImage, holeColor, validColor);

  // Extract the relevant region from the binary image
  UnsignedCharImageType::Pointer binaryImage = UnsignedCharImageType::New();
  binaryImage->SetRegions(region);
  binaryImage->Allocate();
  CopyRegion(fullBinaryImage.GetPointer(), binaryImage.GetPointer(), region, region);

  // Extract the relevant region from the mask
  Mask::Pointer extractedRegionMask = Mask::New();
  extractedRegionMask->SetRegions(region);
  extractedRegionMask->Allocate();
  CopyRegion(this, extractedRegionMask.GetPointer(), region, region);

  // Since the hole is white (we have specified this at the beginning of this function),
  // we want the foreground value of the contour filter to be black.
  // This means that the boundary will be detected in the black pixel region,
  // which is on the outside edge of the hole like we want. However,
  // The BinaryContourImageFilter will change all non-boundary pixels to the background color,
  // so the resulting output will be inverted - the boundary pixels will be black and the
  // non-boundary pixels will be white.

  // Find the boundary
  typedef itk::BinaryContourImageFilter<UnsignedCharImageType, UnsignedCharImageType> binaryContourImageFilterType;
  binaryContourImageFilterType::Pointer binaryContourFilter = binaryContourImageFilterType::New();
  binaryContourFilter->SetInput(binaryImage);
  binaryContourFilter->SetFullyConnected(true);

  if(whichSideOfBoundary == HoleMaskPixelTypeEnum::VALID)
  {
    // we want the boundary pixels to be in the valid region.
      binaryContourFilter->SetForegroundValue(validColor);
      binaryContourFilter->SetBackgroundValue(holeColor);
  }
  else if(whichSideOfBoundary == HoleMaskPixelTypeEnum::HOLE)
  {
    // we want the boundary pixels to be in the hole region.
      binaryContourFilter->SetForegroundValue(holeColor);
      binaryContourFilter->SetBackgroundValue(validColor);
  }
  else
  {
    throw std::runtime_error("An invalid side of the boundary was requested.");
  }

  binaryContourFilter->Update();

  DeepCopy(binaryContourFilter->GetOutput(), boundaryImage);
}
Beispiel #12
0
LuaClass &LuaClass::operator=( const LuaClass &cpy )
{
	LuaTable::operator=(cpy);

	if( !IsSet() )
		return *this;

	DeepCopy();

	return *this;
}
Beispiel #13
0
void QuoteInterface_TDF::InitOpenSetting(TDF_OPEN_SETTING *settings, const ConfigData &cfg)
{
    if (cfg.Logon_config().quote_provider_addrs.empty())
    {
        MY_LOG_ERROR("TDF - quote provider's address is empty");
        return;
    }
    // tcp://192.168.60.23:7120
    const std::string &addr_cfg = cfg.Logon_config().quote_provider_addrs.front();
    std::string ip_port = addr_cfg.substr(6);
    std::size_t split_pos = ip_port.find(":");
    if ((split_pos == std::string::npos) || (split_pos + 1 >= ip_port.length()))
    {
        MY_LOG_ERROR("TDF - parse quote provider's address error: %s", addr_cfg.c_str());
    }

    MY_LOG_DEBUG("ip_port: %s", ip_port.c_str());

    std::string addr_ip = ip_port.substr(0, split_pos);
    std::string addr_port = ip_port.substr(split_pos + 1);

    //MY_LOG_DEBUG("ip: %s, port: %s, user: %s, pw: %s", addr_ip.c_str(),  addr_port.c_str(), cfg.Logon_config().account.c_str(), cfg.Logon_config().password.c_str());
    //MY_LOG_DEBUG("subscriptions: %s", DeepCopy(FormatSubscribString(cfg.Subscribe_datas()).c_str()));

    memset(settings, 0, sizeof(TDF_OPEN_SETTING));

    strncpy(settings->szIp, addr_ip.c_str(), sizeof(settings->szIp) - 1);
    strncpy(settings->szPort, addr_port.c_str(), sizeof(settings->szPort) - 1);
    strncpy(settings->szUser, cfg.Logon_config().account.c_str(), sizeof(settings->szUser) - 1);
    strncpy(settings->szPwd, cfg.Logon_config().password.c_str(), sizeof(settings->szPwd) - 1);

    settings->pfnMsgHandler = &QuoteInterface_TDF::QuoteDataHandler;
    settings->pfnSysMsgNotify = &QuoteInterface_TDF::SystemMsgHandler;

    settings->szMarkets = DeepCopy("SZ-2;SH-2;"); // subscibe two market
    settings->szSubScriptions = DeepCopy(FormatSubscribString(cfg.Subscribe_datas()).c_str());

    settings->nTime = 0;

    settings->nTypeFlags = DATA_TYPE_TRANSACTION | DATA_TYPE_ORDER | DATA_TYPE_ORDERQUEUE;
}
//
/// Merges the functional groups of this menu descriptor and another menu descriptor
/// into an empty menu.
///
/// Popups are DeepCopied and are then owned by the destMenu.
//
bool
TMenuDescr::Merge(const TMenuDescr& srcMenuDescr, TMenu& dstMenu)
{
  int thisOffset = 0;
  int srcOffset = 0;

  for (int i = 0; i < NumGroups; i++) {
    if (srcMenuDescr.GroupCount[i] > 0) {
      DeepCopy(dstMenu, srcMenuDescr, srcOffset, srcMenuDescr.GroupCount[i]);
      srcOffset += srcMenuDescr.GroupCount[i];
    }
    else if (srcMenuDescr.GroupCount[i] == 0 && GroupCount[i] > 0) {
      DeepCopy(dstMenu, *this, thisOffset, GroupCount[i]);
    }
    // else don't copy either

    if (GroupCount[i] > 0)
      thisOffset += GroupCount[i];
  }
  return true;
}
Beispiel #15
0
DWORD SerialPort::Read(int8_t** const msg, const DWORD charsToRead, DWORD* const charsRead) const {
	// Create the overlapped event. Must be closed before exiting to avoid a handle leak.
	OVERLAPPED osReader = { 0 };
	osReader.hEvent = CreateEvent(nullptr, TRUE, FALSE, nullptr);
	if (osReader.hEvent == nullptr)
		return GetLastError();

	// Issue read
	DWORD toRead = min(maxRead, charsToRead);
	int8_t* buffer = new int8_t[toRead];
	if (!ReadFile(_handle, buffer, toRead, charsRead, &osReader))
		return GetLastError();

	// Copy to msg
	DeepCopy(buffer, toRead, *msg);

	return 0;
}
GLMesh::GLMesh(const GLMesh &other) {
  DeepCopy(other);
}
GLMesh &GLMesh::operator=(const GLMesh &other) {
  DeepCopy(other);
  return *this;
}
Beispiel #18
0
wxString CPath::GetPrintableString() const
{
	return DeepCopy(m_printable);
}
Beispiel #19
0
wxString CPath::GetPrintable() const
{
	// Copy as c-strings to ensure that the CPath objects can safely
	// be passed across threads (avoiding wxString ref. counting).
	return DeepCopy(m_printable);
}
 inline
 DeepCopy( const ExecutionSpace& exec, void * dst , const void * src , size_t n )
 {
   exec.fence();
   DeepCopy (dst,src,n);
 }
Beispiel #21
0
CPath::CPath(const CPath& other)
	: CPrintable()
	, m_printable(DeepCopy(other.m_printable))
	, m_filesystem(DeepCopy(other.m_filesystem))
{
}
void CoefficientSpectrum::operator=( const CoefficientSpectrum &s2 ) {	
	DeepCopy( s2 );
}
Behavior::Behavior(Behavior& other)
{
    DeepCopy(other);
}
Beispiel #24
0
				CopiedRow(const Row& row) :
						m_ref(NULL)
				{
					DeepCopy(row);
				}
bool NPCType::Load(iResultRow &row)
{
    csString parents = row.GetString("parents");
    if(!parents.IsEmpty()) // this npctype is a subclass of another npctype
    {
        csArray<csString> parent = psSplit(parents,',');
        for(size_t i = 0; i < parent.GetSize(); i++)
        {
            NPCType *superclass = npcclient->FindNPCType(parent[i]);
            if(superclass)
            {
                DeepCopy(*superclass);  // This pulls everything from the parent into this one.
            }
            else
            {
                Error2("Specified parent npctype '%s' could not be found.",
                       parent[i].GetDataSafe());
                return false;
            }
        }
    }

    name = row.GetString("name");
    if(name.Length() == 0)
    {
        Error1("NPCType has no name attribute. Error in DB");
        return false;
    }

    ang_vel = row.GetFloat("ang_vel");

    csString velStr = row.GetString("vel");
    velStr.Upcase();

    if(velStr.IsEmpty())
    {
        // Do nothing. Use velSource from constructor default value
        // or as inherited from superclass.
    }
    else if(velStr == "$WALK")
    {
        velSource = VEL_WALK;
    }
    else if (velStr == "$RUN")
    {
        velSource = VEL_RUN;
    }
    else if(row.GetFloat("vel"))
    {
        velSource = VEL_USER;
        vel = row.GetFloat("vel");
    }

    collisionPerception   = row.GetString("collision");
    outOfBoundsPerception = row.GetString("out_of_ounds");
    inBoundsPerception    = row.GetString("in_bounds");
    fallingPerception     = row.GetString("falling");

    csRef<iDocumentSystem> xml = csPtr<iDocumentSystem>(new csTinyDocumentSystem);
    csRef<iDocument> doc = xml->CreateDocument();
    const char* error = doc->Parse(row.GetString("script"));
    if(error)
    {
        Error3("NPCType script parsing error:%s in %s", error, name.GetData());
        return false;
    }
    csRef<iDocumentNode> node = doc->GetRoot();
    if(!node)
    {
        Error2("No XML root in npc type script of %s", name.GetData());
        return false;
    }
    
    // Now read in behaviors and reactions
    csRef<iDocumentNodeIterator> iter = node->GetNodes();

    while(iter->HasNext())
    {
        csRef<iDocumentNode> node = iter->Next();
        if(node->GetType() != CS_NODE_ELEMENT)
            continue;

        // This is a widget so read it's factory to create it.
        if(strcmp(node->GetValue(), "behavior") == 0)
        {
            Behavior *b = new Behavior;
            if(!b->Load(node))
            {
                Error3("Could not load behavior '%s'. Error in DB XML in node '%s'.",
                       b->GetName(),node->GetValue());
                delete b;
                return false;
            }
            behaviors.Add(b);
            Debug3(LOG_STARTUP,0, "Added behavior '%s' to type %s.\n",b->GetName(),name.GetData() );
        }
        else if(strcmp( node->GetValue(), "react" ) == 0)
        {
            Reaction *r = new Reaction;
            if(!r->Load(node,behaviors))
            {
                Error1("Could not load reaction. Error in DB XML");
                delete r;
                return false;
            }
            // check for duplicates and keeps the last one
            for(size_t i=0; i<reactions.GetSize(); i++)
            {
                // Same event with same type
                if(!strcmp(reactions[i]->GetEventType(),r->GetEventType())&&
                    (reactions[i]->type == r->type)&&
                    (reactions[i]->values == r->values))
                {
                    // Check if there is a mach in affected
                    for(size_t k=0; k< r->affected.GetSize(); k++)
                    {
                        for(size_t j=0; j< reactions[i]->affected.GetSize(); j++)
                        {
                            if(!strcmp(r->affected[k]->GetName(),reactions[i]->affected[j]->GetName()))
                            {
                                // Should probably delete and clear out here
                                // to allow for overiding of event,affected pairs.
                                // Though now give error, until needed.
                                Error4("Reaction of type '%s' already connected to '%s' in '%s'",
                                       r->GetEventType(),reactions[i]->affected[j]->GetName(), name.GetDataSafe());
                                return false;
                                // delete reactions[i];
                                //reactions.DeleteIndex(i);
                                //break;
                            }
                        }
                    }
                }
            }

            reactions.Insert(0,r);  // reactions get inserted at beginning so subclass ones take precedence over superclass.
        }
        else
        {
            Error1("Node under NPCType is not 'behavior' or 'react'. Error in DB XML");
            return false;
        }
    }
    return true; // success
}